lundi 25 janvier 2016

POCOs, DTOs, DI in an N-Layered ASP.NET MVC Application

Did I just throw a bunch of concepts and technologies that I want to learn about ?

  • First Problem (Writing maintainable code)

    No, I need DI to follow best practice as the applications I'm building are starting to get complicated and I need to write more organized and maintainable code.

  • Second Problem (My POCOs are heavy)

    My application has large & complex entities and when I read about DTOs they seemed like a good practice instead of using POCOs all over the place

You can help me by proposing a project structure keeping in mind the below points from my long research:

  • I found out that I can implement MVVM but the articles about this topic is really limited without including WCF and other components that will distract me while I'm just getting started.
  • I'm not sure if I got this right or wrong but POCOs are meant to be used by the Bussiness Layer only ? For communication betwen DL and Views I should use DTOs.
  • I should have a separate layer (mapper) to populate DTOs and POCOs but I also found that AutoMappers can complicate things, while my DTOs are quite simple and I shall ask if there's any best practices about where should I place this code in my projects ?

  • Based on these points do I need a ViewModel ? or DTOs ? or both ?

  • If you can add some code to your answer along with a simple example to how the cycle will work that would be very nice.

I know some of these points or maybe all are addressed in lots of places including stackoverflow community but I couldn't really find an article or a question that addresses my exact problems and lots of articles are actually providing wrong information so I hope I can get some good advice here. Thanks!


Edit 1

To the people who will down vote this. You either have the option to do so feel free you are following the rules. or you can actually help someone who's done his research and asking a legitimate question that people write articles and books about it. I don't need a whole book just a proposed structure that you use and find it good. It's that simple! I really need some help here!

Aucun commentaire:

Enregistrer un commentaire