I'm wondering if there are any architectural frameworks out there to create desktop or standalone applications, in Java or C# for instance. It seems that there are tons of them available for web applications but I can't find many good resources on frameworks or architectural best-practices for desktop development.
Ideally I would like to know if there is any source code available of desktop applications that would be considered to have a good architecture or are built with a certain framework.
While not directly related to desktop applications if you are looking for decent source code for well written projects I asked a similar question:
Open source C# projects that have extremely high code quality to learn from.
People gave some pretty good suggestions there:
Scott Hanselman's The Weekly Source Code series (usually
managed C#)
Code written by Microsoft Patterns & Practices team.
SharpDevelop (written in C#)
Mono (most of the framework in C#)
Paint.Net (written in C#)
NHibernate (written in C#)
The Castle Project (written in C#)
xUnit (written in C#)
.Net Framework Source Code
In the lightweight app category, JSR 296 for Java (to be in future Java 7 possibly) is a framework handling the basics like resource management and actions. Lots of links here:
http://tech.puredanger.com/java7#jsr296
Scaling up a bit, you could look at various RCP frameworks like:
Eclipse RCP: http://wiki.eclipse.org/index.php/Rich_Client_Platform
NetBeans Platform: http://www.netbeans.org/products/platform/
Spring RCP: http://spring-rich-c.sourceforge.net/1.0.0/index.html
Comparison article: http://www.infoq.com/news/eclipse-rcp-netbeans-platform
UPDATE: It has been mentioned (by Mark Reinhold at Devoxx '08) that JSR 296 will be included in Java 7.
Further update: JSR 296 is dead. JavaFX is the current direction for client-side Java.
There's a new .NET architectural guidance package from Microsoft patterns & practices for WPF that is code named "Prism" -- it's basically a "next generation" Composite UI Application Block (without the SCSF tooling). It uses Dependency injection, Composite pattern throughout, etc.
There is a pretty good DNRTV screencast demoing it.
Check Microsoft's Smart Client Software Factory. It contains code samples and documentation.
Overview
This software factory provides proven
solutions to common challenges found
while building and operating composite
smart client applications. It helps
architects and developers build
modular systems that can be built and
deployed by independent teams.
Applications built with the software
factory use proven practices for
operations, such as centralized
exception logging.
The software factory contains a
collection of reusable components and
libraries, Visual Studio 2008 solution
templates, wizards and extensions,
How-to topics, automated tests,
extensive architecture documentation,
patterns, and a reference
implementation. The software factory
uses Windows Forms, Windows
Presentation Foundation, Windows
Communication Foundation, and the
Enterprise Library 3.1 – May 2007
release. With this release, the
Composite UI Application Block is
included in the software factory.
In Java, Naked Objects -- http://nakedobjects.org/home/index.shtml
JMatter -- implementation of naked objects -- http://jmatter.org/. pretty good.
both of them are open source.
On the Java side, there are several projects aimed at Rich Client Platforms (RCP is the new buzzword for 'desktop' apps):
Eclipse RCP (if you are OK using SWT
instead of Swing)
Spring RCP (which
is in the process of being
overhauled into Spring Desktop)
NetBeans RCP (which I'm not
particularly impressed with, but
that is getting some traction)
JSR 296 (Application Framework) - I
actually really like this one
Google any of the above and you'll get tons of info.
You can use some of the same approaches in client development that you use in web development, such as Model View Presenter. The System.Windows.Forms namespace has everything you need to build a client application in C#, with the rest of the .NET Framework available to provide the services you need (such as IO and remoting).
As far as source code for solid architectures in desktop apps, look at the code for Paint.NET and SharpDevelop. Both have very different approaches that will be interesting to you.
Sorry for the .NET slant of this reply. It's what I know best. :)
I would recommend CSLA .NET framework by Rockford Lhotka: http://www.lhotka.net/cslanet/Default.aspx
It comes will full source code as well as sample client applications built in ASP.NET, WinForms and WPF.
I just found the Composite Application Guidance for WPF and Silverlight which looks very interesting. It was published in February 2009.
We develop in .NET technologies here.
Our friends here working on client applications develop their software to the Model View Presenter design pattern that is often associated with Web Development. For them they find it works very well, I believe it may be worth checking out.
The Smart Client Factory (mentioned by Panos) may also be useful to you, though it's not a framework but more of a library of best practice solutions to common problems.
Specifically to organized presentation framework of ui functions we have been using infonode docking windows, that's a windowing framework using an eclipse like appearance (drag views anywhere, close them, undock them etc., skinnable of course). there's a gpl version for open source products out, altough afaik the developer licence is not that expensive ($299 each).
Check IdeaBlade's Cabana For DotNet C#.
http://www.ideablade.com/CAB.html
Cabana Sample App
The Cabana application is a simple smart client reference app with a crisp, feature-rich user experience that is easy to deploy and operate over the web. Cabana demonstrates:
An easy approach to the Composite UI Application Block from Microsoft ’s Patterns & Practices Group.
Maintainable, reusable code through UI composition.
Separation of Model (business logic and data access) from Presentation.
The Model-View-Presenter pattern.
Performance tuning.
And more.
I recently published DesktopBootstrap. It's my attempt to factor out many of the common elements of creating medium to large scale desktop apps.
You can find it here.
Related
This question is specifically related to a recommended architecture and people's previous experiences for cross-platform WP7, iOS, Android apps developed using C#, Monotouch and Monodroid respectively. I have researched previous questions here, here and here. They provide good answers but not quite what I'm looking for. I have also found this excellent question which does go into the cost benefit so there is some overlap.
I have a requirement to develop a cross-platform iPhone/iPad, WP7 and android app for a health & fitness company, which will integrate with their website. The app requires a small amount of local data storage for offline mode and synchronisation with the website when a network is available. I am a Windows (C#/C++) developer through and through and don't really want to go down the route of three Objective C, Java and C# apps, although I will if I have to. I will also be operating as tech lead and farming out some work to a team on this project.
I would like to know if anyone here has experience with cross-platform development using Monotouch, Monodroid and WP7 and to share their experience on application architecture to re-use as much code as possible. The architecture I am considering is as follows:
My question is as follows:
Has anyone here tried something like this?
Are these frameworks (Monotouch, monodroid) worth their salt for this sort of work?
Can I setup the entire project in Visual Studio 2010 with separate projects (dlls/exe) for the Monotouch, Monodroid and Wp7 target (but shared code using 'Add as Link')?
What sort of code-reuse can I realistically expect with this (or a similar) architecture? i.e. what strategies/patterns can I use to re-use local data access, webservices, and business logic?
You might want to look into the MonoCross project which is designed to help you reuse C# code with multiple presentation layers:
http://code.google.com/p/monocross/
The authors of MonoCross (ITR Mobility) have created multiple mobile cross platform solutions for a variety of customers and have written two books on the subject one is "iPad in the Enterprise" (http://amzn.to/zAhQK6) and the upcoming "Cross-Platform Mobile Development with C#" (http://amzn.to/wM6RsF).
In the meantime, you can watch Scott Olson's presentation that he did at Monospace 2011 that describes how to use MonoCross to target multiple mobile and desktop platforms at once reusing the business logic:
http://www.infoq.com/presentations/The-Rise-of-Mono-in-the-Enterprise
They enforce a strict MVC split in their code:
(source: tirania.org)
The biggest benefit of designing an application with this model is that you can run the same application with native user interfaces on each platform. You get native iOS, Android, Windows UI and they even have an ASP.NET front-end that allows you to publish Web versions of the same business logic.
This technology was used successfully by the Medtronic sample app that is showcased by Apple in their iPad business:
http://www.apple.com/ipad/business/profiles/medtronic/
I suggest you also check out Scott's blog where he posts regularly about his experiences with cross-platform architecture.
Based on your comments your requirements are for a cross-mobile platform that will integrate with their existing services, but also work offline. You are specifically interested in C# via Mono, however you have indicated that you are not discounting other approaches.
I feel that HTML / PhoneGap / JavaScript is a route that you should explore in some detail. The WP7 version of this framework has just been released, and I have had experience of releasing an application to the marketplace using this approach.
PhoneGap wraps your HTML / JavaScript code, in the case of WP7 this is loaded into local storage. This enables the application to work entirely offline. This is true for all versions (iOS, Android etc...)
Probably the biggest issue with PhoneGap / HTML5 is the same issue we have when developing complex web based applications for the browser. The tooling for JavaScript is not great and browser differences are a constant issue. However, it is a tried and tested solution.
Finally, it is possible to create an application UI that is entirely different for each platform. By using the MVVM pattern I have managed to share all my JavaScript business logic between WP7 and iOS applications whilst having a totally different UI:
Compare this to the WP7 screens:
NOTE: I plan to have the iOS version of Property Finder in the AppStore shortly, I just need to work out how to use PhoneGap Build!
Just adding another alternative to the mix - mvvmcross
This project was developed out of experiences with monocross, mvvmlight, and opennetcf.
It's quite an opinionated mvvm framework (with my opinions in it!), it includes data-binding support for Droid and Touch, and it really does encourage code reuse between the platforms.
The source is available from https://github.com/slodge/MvvmCross, it's been used in at least a couple of large projects already and it's still under active development.
There's an introductory presentation on it on slideshare: http://www.slideshare.net/cirrious/dev-evening-monotouch-monodroid-mvvm-mvvmcross-and-databinding
One of the more fully featured samples is a conference app:
The question is very hard to answer, yet I would like to share some thoughts.
The situation with the mobile development is very similar to the development at the first half of the 90s. Phone have limited resources as computers had, mobile OSes are making their baby steps, hence the ecosystem is relatively small. They have own philosophy, tools and even languages. And this is a good thing, but leads to a headache for cross-platform development. As a result, there are many attempts to clear this a bit. People build frameworks, wrappers etc. which is a kind of abstraction and abstractions are leaky. This is extremely important for mobile devices not only the performance as numbers of CPU cycles, but also the performance of the battery, which is far more important for the user.
If I were you I would build apps in a native environment especially if you have some performance considerations. Best support, tools, educational resources etc. pays for the duplicated business logic. All in all, it's not a OS or Database Management System, codebase won't be huge ;)
That being said. Regarding Monotouch and Monodroid I would be very careful since Apple blocks iPhone OS apps created by many third-party compilers and The King doesn't really care about developers. The case that mono will be flushed to the toiled by patent infringement or proprietary software vendors is very likely. This is sad for me cause C# is my favorite language.
PS. I don't believe that HTML5 for mobile will take over any time soon.
I am wondering if anyone out there on here has been able to succesfuly use the Enterprise Library to work across n-Tier Layer Structure, where the UI is of different Mediums.
I have to Design a WCF Common Library Service Layer that will be working across
the following Platforms:
Silverlight
WPF
ASP.NET MVC
Just some reference documentation or point me in the right Direction. Thought someone out there may have done the same kind of thing, but wouldn't mind a bit of help of where this may have been talked about or done before.
Thanks
Robbie
The following two projects may be interesting for you to look at:
Domain Oriented N-Layered .NET 4.0
App Sample (From MS Spain)
Layered Architecture Sample for
.NET
The p&p team created a Silverlight integration pack for the Enterprise Library. You should be able to reuse some of the application blocks that exist on the destkop, although they have a few differences to better support Silverlight.
Download and help on MSDN: Enterprise Library (Although I suggest you download and install the specific blocks you'd like using NuGet).
See this blog For a summary of high level differences with the desktop version.
Can you please tell me some tutorials/books about thinking a large application in c#.
I have worked with 3 tier, but i need something more specific:
a way to design panels, so that for specific users specific panels will load and specific dlls
a database management so that when a user modifies an entry, others can not modify that entry
should i use entity framework or should i go old school with db and class creation
any links on the above will be greatly appreciated
thanks a lot!
Kind of a broad subject but two books I would recommend giving a read regardless of what language you are doing or the specifics of your project:
Code Complete
Design Patterns
If you have specific questions about how to accomplish something I would post it on here or google it.
Sharp Architecture is just such an architecture. It's pretty detailed and a lot of work has gone into it.
NDepend documentation comes with two white books and also online blog posts and articles concerning the architecture for large .NET application:
Partitioning code base through .NET assemblies and Visual Studio projects (8 pages)
Defining .NET Components with Namespaces (7 pages)
Control Components Dependencies to gain Clean Architecture
Re-factoring, Re-Structuring and the cost of Levelizing
Evolutionary Design and Acyclic componentization
Layering, the Level metric and the Discourse of Method
Fighting Fabricated Complexity
That's not gonna be covered by a single book or tutorial.
You need to decide a UI framework, data access technology, patterns and the overall architecture. And of course you need an in-depth knowledge on .NET framework, & how the CLR works. It's nothing C# specific. Since you have UI customization (Panels) requirements, WPF is definitely a better candidate for UI framework, than WinForms.
That being said, my recommendations -
For C#: Pro C# 2010 and the .NET 4 Platform
.NET & CLR: CLR via C#
UI Framework - WPF: Pro WPF in C# 2010
Use MVVM with WPF. MVVM will keep you on track maintaining the Separation of Concern. You can follow Microsoft's Prism guideline. For large applications with sophisticated UI requirements Prism is a better choice. You might need to use Dependency Injection. MEF is there to go hand-to-hand with MVVM & Prism.
Yes, Entity Framework can handle concurrency issues, but such feature is available in almost any other data access framework. Entity Framework provides lots of other facilities, but when using it you should have clear idea of what you're doing. Otherwise you might end up with performance issues. Programming Entity Framework is definitely gonna help.
With respect to the panels/UI architecture, it might be useful to look at Prism (from Microsoft patterns & practices). It's an architecture/set of libraries to handle composite UI, where the UI is loaded at runtime and composed of independent communicating parts. One note, it is built for use with WPF or Silverlight; there is an older library with similar functionality for WinForms, called "CAB", that is no longer supported.
As far as data access, it sounds like you are looking to implement active record locking while a record is open for editing in the UI; this is an independent feature from the actual data access code you use. It might be easier to implement database-level locking if you are using straight ADO.NET versus EF, which adds layers of abstraction.
Microsoft .NET: Architecting Applications for the Enterprise - with a very good code example and there is a chapter on concurrency
Professional Enterprise .NET
ASP.NET 3.5 Website Programming: Problem - Design - Solution
I guess, there are not any online recources that could compete the complexity of these books.
My go to book with these kinds of questions is Jeffrey Richter's CLR via C# book. It takes you all the way from how your class construction impacts memory on the stack/heap to best practices for these types of discussions. Especially loading assemblies on the fly and the best way to accomplish this.
It will also bring your skills up a notch and Jeff is a great writer.
I recommend this book to EVERY C# developer I know and they always come away better. Is that what we all hope for?
Good luck!
If you want to learn fast and get to the meat of the technology fast, I would recommend getting a Pluralsight account as that would cover the technologies you would need and highlight others you may not have heard about. A monthly subscription would be about the same cost as a decent book.
Pluralsight.com
I am quite aware of both java and C# .Net .when i try to create a new windows application which are the factors that decide which technology should be opted?
I know of one thing ,for great and faster UI development Visual studio helps a lot.
There are several factors I would consider...
What are your programmers used to working with already? What third party libraries are you likely to need, what's available on both platforms?
Does platform independence matter to you?
Would LinQ be advantageous?
If you're starting from scratch, costs for the platforms?
Both platforms have strong communities around them...
Hope this helps...
Dotnet is pretty much native in Windows which obviously makes it more suited to writing Windows programs. Using Java in a Windows-only environment makes it much harder for you since it effectively just adds another unnecessary API layer.
You will soon realise that all integration points between your Java code and Windows are a bit problematic. For instance, creating installation programs, access file system, reading/writing the registry, starting/stopping services, task bar icons, using Windows GUI components (media player, IE...), help file system...
It all boils down to this imo: The Dotnet framework is much richer in terms of functionality than the Java dito, mainly becuase Java is cross-platform and thus needs a "one-size-fit-all" approach to its API. My experience is that you will only get frustrated trying to "emulate" a Windows native program in Java.
Choose the one with which you are most familiar. The two platforms are different enough that skills from one does not transfer easily to the other.
In any case, try making a trivial application in both your scenarios and see how it works for you. The initial impression is important as it is probably indicative of how well the rest of the work will be.
It also depends on what kind of windows application you want to build. If it's just a question of building a simple standalone application then, considering you know both languages equally well, I wouldn't hesitate and would go for a 100% microsoft solution, especially if you have to do specific things like accessing ActiveDirectory, the windows registry, etc.
Not that you can't do it in Java : you can always use AD through LDAP in Java for example, but the APIs are just "a bit" more complicated than the .Net ones (try to decode objectSIDs in Java without a few tricks).
Now if you have to build an enterprise app. I just feel that popular frameworks like Spring and Hibernate are always coming out after their Java counterparts (disclaimer : this is a personal opinion; I didn't do any research on this, thoroughly comparing frameworks in both languages, but that's just the feeling I have). I don't know how good the .Net implementations are though, so I don't have a point of view on that. I just remember writing .Net 2.0 apps and not liking ADO.Net at all.
My view is that the frameworks I like do exist in both languages, but they are first developed for Java, then ported to .Net.
Now I'm not the kind of developer trying to defend his favourite language over the others. If I don't have external constraints to develop, then I choose whatever language gets my app up and running faster and in the most efficient way.
...But with java you will have crossplatform application on scratch.
Also coding UI in java is not difficult - if you read some guides before and use some frameworks as swing application framework or SWT framework.
If its Exclusively for Windows then .Net is best bet.
Yeah for a pure cross platform application Java can't be beat, but if you can manage it Silverlight is a subset of WPF and a pretty compelling cross-platform proposition on its own.
Productivity-wise I think WPF has an edge as it has a nice XAML markup language that can be easily created with the built-in designer in VS.NET or integrates nicely with MS' suite of expression products.
Looking at the C# project templates in VS2008 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and .NET?
It sounds like you are trying to do several different things all at once:
Migrate your code to building in a newer version of visual studio.
Migrate your use of technology to a newer technology (ActiveX to .net)
Migrate your language (c++ to c#).
If you have a small codebase you are probably as well to start from scratch and port functionality into the new codebase as required.
For a larger codebase you need to realize that this is an expensive task both in effort and defect rate.
An order might be:
Import your code into the newer version of visual studio. Get it compiling. Review the project settings for each project.
Refactor your code to isolate the mfc and activex code as much as possible. Follow good refactoring practices especially if don't have many unit tests before you start.
Consider replacing your ActiveX layer with .net.
Consider which GUI toolkit is best for replacing MFC.
Language - consider moving first to managed c++.
Consider moving from managed c++ to c#.
Most importantly be able to justify doing all of the above!
There is no project template that will do this for you. You might as well read up and start with a usercontrol.
You would have to consider the target application that will host the control. If it is a line of business application I've heard that WPF doesn't offer great advantages over Forms. According to this blog entry however, the author believes that the killer WPF is a LOB application that leverages the graphical power afforded by WPF for data visualisation.
In the end I guess it is a cost/benefit analysis. Do you go down the WPF route and pay the cost of the learning curve for the future benefit of graphical data visualisation or do you stick with the tried and true method and risk developing an outdated application.