Coming up with a good sample project for this series wasn’t easy. It had to be small enough to be easy to comprehend and look into, yet it also has to make it clear why i prefer the MVP approach over the MVVM approach, which isn’t easy to do when you have a very simple sample. There has to be business logic, and it has to be encapsulated by a Service Layer. But i obviously wanted to avoid having to use a database and go through everything to get all of that working while still being easy to download and play around with it. The Service Layer has been implemented very quickly, and is not representative of a real Service Layer. It doesn’t use a database, it holds its data statically in memory (and doesn’t even care about thread-safety of this data either) and i didn’t even write tests for any of it. It’s just a simple Service Layer, implemented with a Request/Response Service Layer. It accepts Requests and returns Responses with DTO’s (not entities obviously) to the client. That’s it. The client code has been written entirely using Test Driven Development. Apart from the Views, everything is tested and the tests are obviously also included in the downloadable Visual Studio solution. Some tests were written after a piece of code was written, but most of the tests were written before the actual code was written. I hope you go through the tests to see just how much UI logic you can actually cover quite easily. I also hope you’ll notice that the large majority of tests is very short and focused, which would be harder to achieve when using MVVM. If you have questions regarding the implementation of the User Controls or their tests, it might be better to hold off on asking them until i’ve published the posts that cover writing the implementations and the actual tests. You can always ask questions if you want of course, but odds are high that i’m gonna cover the answer to your question in one of the future posts anyway. One more important thing: the client in this sample is Silverlight, not WPF. You can apply all of these ideas to WPF programming as well obviously.Read more: The Inquisitive Coder – Davy Brion's Blog
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment