Many times I read the questions posted on online forums that “How should be my application design”,”Where to put entities”, “Which is the best place to put POCO classes”, “Where to put EF generated entities”, sometimes like “I am building nTier application and can you help me to place my context, entities and/or model” (sometimes questions posted with MVC tag). And people answered them very well too, but still my two cents on this topic,
So in my opinion people should read the “Domain Driven Design-Eric Evans” which helped me lot to understand the layering of the application, writing code with Domain in mind.
Layering of the application is very important part of the project design and if this part is not designed well than often you will learn words “Code Smell”, “Fatty Classes” etc. So be cautioner while design the application, give good amount of time to design it.
So how should be the good design and the answer is “it depends”, but my design should,
- Accommodate new changes, at the same time it should follow the legendary Open Close Principle.
- Pluggable Architecture with Separation of concerns, means the libraries which we build, should be plugged into another application (With MVC, WPF, Win App, WCF).
- And finally developer should DRY(Don’t Repeat Yourself). That means whatever code you have written, it should be reusable. I know most of the time it doesn’t happen but still, one should think before writing “how this piece of code can be reusable”.
To reduce Developer task,
- While making an application, should use tools like T4 templates which gives us ready made code(CRUD or Creation of Master Forms) for similar kind of modules, it will save the time of writing and testing it.
- Tools like Automapper which copies one object to another. e.g. Copying Entity to POCO or vice versa.