WCF Data Services – Design Patterns for Winforms Applications

designmvcwcfwinforms

Please excuse me as I am a bit new to the following technologies and practices. I have been given the task to create a management suite utilizing an MDI GUI. This suite will be the front end to a WCF data service. My question is, what design pattern is typically used by most professionals when designing such an application. At the moment, I have been looking into both MVC and 3-tier design patterns.

If the MVC route tends to be taken, I'm assuming that because the WCF service is added as a service reference which provides visibility to all it's classes, the model part of MVC is pretty much covered? Would it make sense to generate an interface from the WCF class?

If the 3-tier pattern is used, would it make sense to create datalayer objects for every visible WCF class (ex. PropertyDAL), and on top of that, business layer objects for each datalayer object? If this is the case, with there being over 114 classes which would be made visible, this would mean 228 additional classes which seems a bit bloated to me and not necessary.

Here is the link to the usage of MVC design pattern which has lead me to my question.

Best Answer

This is an enormous question, people have written whole books on this. I will therefore attempt to keep my answer brief.

Comparing MVC to three-tier is like comparing apples to oranges. Quite simply they have totally different usages.

MVC is a presentation pattern. It will help you design your UI, but not really any further. It has the concept of a "model" which nicely abstracts things like physical data reads, physical data writes, business rules and all bar the simplest of validation.

A three-tier approach however is a higher level pattern which covers the whole of your system. You have the concept of presentation, business and data services. So you need to think about how you build these three services, and furthermore how they talk to each other.

Interestingly, MVC and Three Tier can easily coexist. If you imagine a three-tiered system, theres absolutely nothing to stop you writing your presentation services using MVC.