DoFactory Architecture Design
I just have a question on the architecture. I always thought that the service must call the repository. In the solution the have ActionService and a repository. Lets say I want to get all the customers then in my controller I would call the repository's GetCustomers method. This will then call ActionService's GetCustomer's method. And then lastly another GetCustomers method is called in the customer data access object. Is this right? Is it best practices to do it this way, or is your service implementation something different to my understanding of a service? How I understand it is as follows. A service like CustomerService has a Save method. In this method logic is applied, when everything is a success then the repository's Save method is called.
Any comments on the way that they implemented things in the Patterns in Action?
Brendan Vogt, Dec 31, 2010
I can't really answer for the DoFactory guys, but I do know what you are talking about in this case. And I assume you are referring to the MVC implementation. This implementation is done this way, as far as I can see, to allow the controllers to be testable.
Since the application gets a reference to the WCF service, they could have made a reference to the WCF service proxy directly in the controllers, but then you wouldn't have an easy way of testing them.
By wrapping the WCF service inside local repositories, you can test your controllers without affecting the rest of the application.
In my applications, when I use the PIA pattern, I take it a step farther and decorate the local models with DataAnnotations for form validation.
I've built this functionality into my code generator so it builds all this stuff for you.
I know it seems like a lot of stuff that may be redundant, but the way this application is separated, it kinda needs to be this way, or something close to it in order to provide maximum flexibility and testability.
And if you were to time it, round trip, page requests take only milliseconds.
This isn't the only way to do things, but it is one way. It's really up to you to see if it fits your needs.
I hope this answered your question.
King Wilder, Jan 01, 2011
This helps a lot. Thanks Dan...
Sep 10, 2010