Reputation: 7795
I am new to design patterns, but I have been trying hard to implement some in the last year. I started at a new organization, and all the code was contained in the form. Since I got here, I've been trying to use an MVC approach for our .NET 2.0 application.
Other developers have started to see the need for this approach, and we are reaching a point where we want to agree upon a design pattern that we will all follow. And while I have been trying to learn, I'm not sure I know which pattern is the best to implement. Here are some of our design constraints:
Please let me know if you have other questions. I appreciate your help.
Thanks!
Upvotes: 7
Views: 1360
Reputation: 3649
I think a layered approach is best here. I would start at the bottom with a Data Access Layer (DAL) using the Entity Framework or NHibernate. Then you can put a business logic layer on top of that and then put a service layer on top of that. All the while both your windows and web apps can use each layer as it comes on line. I'm reading Microsoft .NET: Architecting Applications for the Enterprise by Dino Esposito right now and it is very helpful with these types of problems.
Here's a diagram of what I'm talking about:
Upvotes: 6
Reputation: 92805
This is a prime example for what a service layer is used for:
(Article with more indepth descriptions of the various layers)
You can stick with your MVC architecture, but now the controller calls upon your service layer (a seperate class library project in your solution), for any business logic methods. It sits on top of the domain and repository and allows you to perform business related actions between any project using the service layer.
This way your business rules aren't spread all over in your controller and your controller is left to do its job: retrieve and organize data to be passed into the view.
In this way, you can have your client application and your web application both reference the same service layer project and share the business logic code between them.
Upvotes: 7