views:

449

answers:

6

I’m in the situation that I have to design and implement a rather big system from the bottom. I’m having some (a lot actually) questions about the architecture that I would like your comments and thoughts on.

I don’t hope that I’ve written too much here, but I wanted to give you all an idea of what the system is.

Quick info about the applications, read if you want: I can’t share much detail about the project, but basically it’s a system where we offer our customer a service to manage their users. We have a hotline where the users call and our hotline uses an (windows) application (intranet) to manage the user’s data, etc. The customer also has a web application where they can see reports, information about their business and users, and the ability to modify their data. Modifying data is not just user data like address and so, but also information about the products/services the user has, which can be complicated.

The applications will be built on Microsoft .NET Framework 4, with a MS SQL Server 2008 database. There will be a few applications that have to access this database, such as:

  • Intranet application (used by us and our hotline)
  • Customer web application type 1
  • Customer web application type 2
  • Customer web application type n different applications)

Now my big problem is what .NET parts I should use for such a system. For the “backend” I’ve considered using Windows Communication Foundation: Possible WCF solution Would WCF be a good choice?

The intranet application will be an application that has to edit lots of records in the database. It has to be easy to navigate using the keyboard (fast to work with). Has a feature such as “find customer, find that, lookup this, choose this and update that”. What would be the best choice to develop this application in? Would it be WPF or good old Windows Forms? I don’t need all of the fancy graphics features in WPF, like 3D, but the application has to look nice (maybe something like the new Visual Studio/Office tools).

And the same question goes for the web pages. They have much the same work to do, but not as many features as the intranet application, and not the same amount of data (much less).

That is my questions for now. I’m hoping to get a discussion going that will open my eyes to some of these technologies, helping me decide architecture to go with.

I would like to say thanks in advance, and let you all know that any thoughts will be much appreciated.


Edit 1: It seems like many agree that we should use WCF. When introducing an ORM mapper in the data layer, and a service layer using WCF, there must be a performance hit? Do you have any comments on this?

Another question that keeps popping up is how we handle authentication and roles. The intranet application has “master” access (no limitations). However, when a customer retrieves information from the web application about their users, what is returned depends on what their “service level” is and a few other parameters related to the customer. What is the best way to handle this? Are there any patterns/ best practices?

+3  A: 

This design looks eminently feasible.

WCF is a good candidate for the service layer, it's nice to see some ORM-age going on and you have a good reason to have a form-based and a web-based UI.

WPF can (essentially) behave like a Windows Form. However, MS recommend it over Win Forms if you are writing something new.

ASP.NET MVC is a great candidate for web-based stuff - the pages are stateless and you have much more control over the page.

Check out individual "WPF VS WinForms" type discussions for more detail.

Sohnee
Can you tell me anything about the performance hit you have with a data layer with an ORM, and on top of that a service layer with WCF?
Tommy Jakobsen
There is a small cost of using an ORM compared to well written "direct" code (note, it will perform much better than a lot of poorly written "direct" code that I've come across). Similarly, putting a service between the ORM and the UI will have a small cost. Both of these are most likely negligible compared to the savings you will make developing and maintaining the code - certainly your end-users would not be able to tell the difference.
Sohnee
Thank you Sohnee. What I hoped to hear :-)
Tommy Jakobsen
Ray Burns
@Ray Burns - I think you've found your stats from "number of developers who have Silverlight installed" rather than "number of internet users who have Silverlight installed". I think you need to look at this in terms of domain specific languages, in which case ASP.NET MVC wins out for web use, especially by the time HTML 5 gets formalised.
Sohnee
No, it is **50% of all internet users** who have Silverlight: All stats sites agree on that figure +/- 5%. Your statement about ASP.NET MVC as a DSL (as if Silverlight weren't) betrays total ignorance of Silverlight and XAML. HTML/JavaScript is shockingly primitive - caveman stuff - compared to XAML/C#. HTML5 barely moves it ahead to the stone age, if that. If this isn't blindingly obvious to you, you've never done any significant Silverlight or WPF development. ASP.NET MVC hides some of the ugliness and inflexibility of HTML/JavaScript but leaves most of it.
Ray Burns
@Ray Burns, totally agree -- standards-based web technologies have only recently evolved to the point that UIs are competitive with desktop UIs ... of ten years ago. I understand people's concerns about closed systems, but Silverlight is much less of a closed system than Flash. I see this plainly in terms of UX -- Silverlight allows me to create a high quality UX within timeframes that would be impossibly short using standards-based web technologies. My clients and their users benefit as a result.
Ben M
@Ray Burns - source your statistics. If you are so sure of them, tell us where you got them from. It honestly sounds more like 50% of Windows users to me - not 50% of internet users. There is definitely some clause in there. In any case, it doesn't change my answer as the great thing about MVC / MVP architecture is that you could drop a different UI over the same logic if you so wished.
Sohnee
For example as of today riastats.com says 57% and statowl.com says 50%. You can also see the breakdown on each site. riastats indicates that as of today MacOS has about 40% Silverlight penetration and Windows has 60%. Every other stats site I've found has had similar data. Are you aware of one that says differently?
Ray Burns
You are wrong about being able to quickly drop a different UI over the same logic. ASP.NET MVC code is extremely ASP.NET-specific and would require a major rewrite to drop a Silverlight UI on it. For one thing, Silverlight runs on the client side not on the server. For another, Silverlight's advanced data binding makes 95% of the code in ASP.NET MVC unnecessary. It is obvious you have never done any significant Silverlight or WPF development. Try it and you'll be amazed at the incredible productivity gains.
Ray Burns
@Ray Burns - statowl says 43%, which is MUCH lower than 50%. It all states that it collects data from its own network of websites, so you need to understand how that skews the data. Similarly, the RIA data is collected from "109 sites over the past 30 days" - sites that use RIA stats code. I'm not trying to be picky, I'm just trying to help you to be balanced. I use plugins on many sites, mostly to serve rich media. I'm not anti-plugin at all. I have actually developed WPF using the Prism framework, so I do know quite a lot about it. I'm just not blinkered by a single technology.
Sohnee
@Ray Burns (continued). Important stat number 1. 100% of internet users have HTML. Number 2. Your claim that "All stats sites agree on that figure +/- 5%" - even the two number you quoted are 7% different, and that's before you take into account the mistake you made on statowl, which means that it is 14% different. If anyone has anything credible to say, please contribute - but I'm not continuing a pointless discussion.
Sohnee
@Sohnee: Sorry, **you are the one who misread statowl.com**. The 43% number you cited is their average for the past six months. Their number for *this* month is 50% as I stated. Also, my "50% +/- 5%" was an accurate statement in April. THIS month the numbers are about 3% higher. If I were writing this month probably would have said "53% +/- 5%". If the stats continue to increase at this rate, next year it will be "86% +/- 5%". Yes, any statistics site will be skewed somewhat, but these sites have made a valiant effort to get accurate data. Check their history and credentials.
Ray Burns
@Ray Burns, you're in danger of splitting hairs here. Even 90% penetration is too low for a public facing service. You face losing customers unccessarily. Internal applications are another matter.
James L
Sorry, I was responding to Sohnee's repeatedly questioning figures that are well-established. You say "Even 90% penetration is too low for a public facing service", but I disagree. Many large public facing services have been using Silverlight for years, and now it is used on thousands of sites. Time has proven that most people will download a small plugin when necessary to view a site they want to use. It is the fact that Silverlight sites are becoming so common that is driving the huge surge in its market penetration, which apparently will be near that of Flash within a year.
Ray Burns
More to the point: If you choose ASP.NET MVC and your competitor chooses Silverlight, you will end up with the 10% of the market who don't install Silverlight this year, and they will end up with the other 90% because of their higher quality application, faster time to market, etc.
Ray Burns
+1  A: 

If your team doesn't already have experience with WPF, I would recommend sticking with WinForms for the desktop client, assuming you have schedule pressure (and what project doesn't?) WPF is extremely powerful, but it also has a steep learning curve. I've been using it for relatively small, low-visibility projects and it's given me the freedom to really learn how the technology should be used rather than trying to hack together something together as if it were just WinForms with prettier controls.

I don't have much experience with WCF, but my understanding is that there is a lot of learning curve there, as well. As with WPF, it's a matter of what your team knows and how much time you're able to invest in learning a new technology.

Dan Bryant
Actually we have that luxury that we already have a working product, so we have the time to introduce a few new technologies. And we would really like to use some of the newer technologies, so the learning curve doesn’t really mean that much to us. I would like to hear some alternatives to my proposed solution as well, with pros/cons.
Tommy Jakobsen
If you have the time to invest in the learning curve, then by all means, dive into WPF. It's a wonderful technology and may well completely change the way you approach development. I'm just now starting to get over the worst part of that climb and I'm already finding myself working on our WinForms projects and thinking "this would be so much cleaner if I could do this with data binding and templating..."
Dan Bryant
WPF does indeed sound very nice. How about developing the customer web application in WPF?
Tommy Jakobsen
I don't have any experience with the web-based technologies, but I'm sure others here will have comments.
Dan Bryant
+3  A: 

Have you considered Silverlight + RIA Services? -- it's a natural choice for an n-tier system with a rich user interface. You could use it for both the intranet and client-facing applications.

Ben M
I haven't heard much about RIA Services. Can you point me to a good article on why to use it instead of WCF? Personally I'm not a big fan of web sites written entirely in Silverlight. Why would you choose Silverlight over WPF?
Tommy Jakobsen
@Tommy RIA Services actually uses WCF, so you wouldn't be using it instead of WCF.
Daniel Plaisted
I see. Ben, could you say anything about why you think I should consider RIA Services?
Tommy Jakobsen
Mainly because RIA Services is designed to enable exactly the scenario you describe. WCF services are much lower-level, and you'd end up duplicating a lot of what RIA Services already provides. See http://www.silverlight.net/getstarted/riaservices/
Ben M
And as for why I would choose Silverlight over WPF: it's a browser plugin vs. a 30+ meg, 10-20 minute install for the WPF-enabled framework. Why wouldn't you do an entire business website in Silverlight, when you would consider writing it in WPF instead? You'll find the former much more web-friendly...
Ben M
I think it should be pointed out that Silverlight actually contains a sub-set of what is available in WPF and it runs in a strict sand-box - these might be good reasons to prefer WPF over Silverlight.
Sohnee
For the intranet application, all our users have an up-to-date windows installation (Windows XP/Vista/7 with newest .NET Framework). If not, they can easily update, so running WPF applications should not be a problem. Regarding web, all our customers will need the Silverlight plugin which makes me think that ASP.NET MVC is a better choice. I still can't see the big advantage of choosing Silverlight.
Tommy Jakobsen
I don't know who your customers are, but according to RIAStats.com, 50% of systems already have Silverlight installed. As to the advantage, that depends on the kind of user interface you want to create; Silverlight makes it easy to develop the level of interactivity you'd find in a traditional desktop application.
Ben M
Very interesting Ben. I didn't know of RIAStats.com. But I'm still not sure why Silverlight would suit me better than MVC. I do not need all the animation capabilities. Just simple forms thats easy to edit. Do you know of any samples where I can see such sites in Silverlight?
Tommy Jakobsen
Try http://www.silverlight.net/community/samples/silverlight-samples/ -- there's a lot of stuff there, from plain old forms development to more visually exciting interfaces.
Ben M
+2  A: 

As Sohnee mentioned above, I think your logical architectural approach is pretty solid and I think WCF is "the choice". I'm sure you'll get your share of opinions on presentation technologies and ORM. I'll offer a couple of items on the service layer, which is where I spend a lot of my time in applications very similar to yours:

  • If you haven't already, start looking at AppFabric. It's where Microsoft is going with hosting WCF services and provides you a lot of benefits such as high-speed instrumentation and service management that you don't get out of the box with WCF now.
  • Think about what type of protocol (and consequently WCF bindings) you'll be able to use based upon your network infrastructure and those of your business partners. If you can use TCP as a high-speed transport, you'll be in great shape, as long as it will work with your network.
  • Consider integrating MSMQ into your logical architecture to provide queuing and guaranteed delivery. Juval Lowy has some excellent materials on MSMQ integration in his WCF books.
  • Start thinking now about your service interfaces and service versioning strategy. Decisions made early on in these areas become nearly immutable once they are shared with business partners.
  • With multiple business partners involved, think about how you're going to secure these services. Microsoft's P&P group just issued some pretty good guidance on claims-based identity and access control that might be really useful to you based upon your integration scenarios.

Hope this helps. Feel free to post a follow-up if you need more info.

Thomas Beck
You raised a lot of concerns that I haven’t really been thinking about yet. Thank you. I will be looking more into these technologies and return when I have more questions. Do you know of any articles that describe best practices of using the technologies you’re mentioning? WCF protocols (especially this one), AppFabric, MSMQ, etc.
Tommy Jakobsen
Juval Lowy's book and MSDN articles cover WCF and MSMQ pretty well. AppFabric is upcoming technology. There were a couple of good presentations about it at this years PDC. You can go to the PDC conference site and get the videos and slides.
Thomas Beck
Thank you Thomas. I will take a closer look.
Tommy Jakobsen
Can I ask you what your view on RIA Services is?
Tommy Jakobsen
Pro's are: Silverlight-based, builds on top of WCF, and plays really well with other frameworks (Brad Abram's 26 part intro to RIA Services shows this flexibility). My concern is tying myself to a particular framework's way of doing things and being stuck when the framework changes. Were I to use RIA Services, I'd develop WCF services that meet the business need, independent of RIA, and then bolt RIA on top. You loose some of the RAD benefits of RIA but buy yourself presentation layer decoupling, which is pretty important in my mind. Brad has a tutorial for this "Part 8 - WCF Data Source"
Thomas Beck
That is exactly my concern by choosing such frameworks. I will have to look more into it before choosing whether or not to use it. But right now I'm not so sure that I will.
Tommy Jakobsen
A: 

I would start from defining the functional requirements as they are likely to shape your architecture. You mentioned about customer applications changing data but indirectly -- via some approval system. I think one of the most important thing here is how will you represent that changes waiting for approval.

If this is only a data-entry application, you can simply build few screens and live with it. It would be the simplest thing that can work.

On the other hand, if reasons why data changes are valuable for the business, I would consider building a solid domain model first. And then a layer of commands atop of it. Customer application would issue commands for data changes like 'Give user Xxx a pay raise' which will be approved and then processed. Such commands would be a first-class citizens in you architecture.

Szymon Pobiega
Actually, the only thing in the requirements analysis that is not perfectly clear, is how we should handle customer inputs, which are very valuable for the business. I'm wondering how this part of the domain model should look. If you have any ideas, please share them.
Tommy Jakobsen
+1  A: 

Desktop UI technology

WPF is incredibly powerful and is unquestionably best choice for the type of application you describe. If your team has no WPF experience figure on a several month learning curve, but the long-term benefits of increased productivity and maintainability make it well worth it. The only reason you might consider anything but WPF is if you have a tight deadline and your team already knows some other technology very well. Even in that case, I would consider developing the WPF version in parallel and consider the other version as just a prototype.

Some people are doing desktop development using Silverlight instead of WPF on the theory that they should use one technology instead of two. I don't agree with that argument: The two technologies are similar enough that skills and code transfer extremely well, WPF currently has many very useful features missing in Silverlight, and as Silverlight gains those features it tends to copy what is good from WPF. So in the long run any effort spent and code created while devloping WPF applications will not be wasted.

Also note that WPF can run in a browser just as well as Silverlight. When I create web applications for clients that I know will be running Windows I choose WPF over Silverlight. I am currently in the process of converting a bunch of Windows apps into WPF web apps for easier deployment.

Web UI technology

You'd be a fool to use ASP.NET MVC on a web application if you could possibly use Silverlight. Things that takes days in ASP.NET MVC take hours or minutes on Silverlight. Things that take days in Silverlight take years in ASP.NET MVC.

Silverlight's market penetration is currently around 50% and growing at 2-3% per month, and it will run on 99% of desktop machines. By next year penetration may be at 85% or higher. You have to weigh the risk that a few users won't download Silverlight and won't access your application against the risks associated with ASP.NET MVC: With ASP.NET MVC your application will cost a lot more to develop, take longer to get to market, have fewer features and less "richness".

That said, if there was a contract I really, really, really wanted and the client wasn't comfortable using Silverlight, I would probably fall back to ASP.NET MVC as my second choice. But only if the web section of the application was relatively small.

Communications technology

WCF is a good choice for serving up your data. It is currently better than the competition, plenty fast, and integrates well with Silverlight, XBAP, and WPF. If you have no compelling reason to choose a different web services technology I would go with WCF.

As far as efficiency goes, WCF's binary formatter is just about as efficient as anything you will find, and is more efficient than typical direct database access protocols such as TDS for the usage patterns you will encounter. If you have to use the SOAP formatter for compatibility you will lose some bandwidth in the conversion to XML but otherwise it is relatively efficient.

I use a data layer called "Emerald Data Foundation" that I built myself and plan to open-source in the next few months. It uses the same objects on the web service and on the client and behaves identically whether or not it is connected to a back-end database. This works very well because you hardly realize there is a communications layer at all. Such an approach makes the data layer extremely simple.

Emerald Data Foundation also has a role-based access control mechanism that allows clients to be granted access to data based on relationships between data objects, so that, for example, a person can access only their own customer data. This is enforced at the data layer so no UI layer development can accidentally expose data that shouldn't be seen or make unauthorized updates.

Ray Burns
Thank you very much for your detailed opinions Ray. What you say about Web UI technology sounds very reasonable and I will consider using Silverlight. Can you reveal more details about how you created your role-based access control in your data layer? I’m really interested in hearing more about this.
Tommy Jakobsen
Each role lists object types and what relationship that object must have to the object representing the login to be considered in the role. For example, a "CanSeeBalances" role could apply the paths {"AccountHolder.Logins", "CorporateOwner.CEO.Logins"} to an Account. Property read access is declared via policy objects that connect a list of properties and a list of roles. Update access is controlled by policy objects as well. Also update validation code can check the login's roles relative to the object being updated or any linked object. A given role can apply to multiple object types.
Ray Burns
EDF is highly multi-tier: Each data context has a client-server relationship to a "parent" context, which can be another EDF context on the same machine or elsewhere, or can be a set of files on disk, a SQL database, or whatever. The mechanisms for moving data down to the child and changes up to the parent contain hooks for validating credentials at any level. Thus every tier in the data hierarchy has the option of validating access. This allows an offline client to reject unauthorized changes to locally cached data without having to consult the server.
Ray Burns
Very interesting. Is there a pattern for this method or any resource where I can read more detailed instructions about it?
Tommy Jakobsen