Saturday, March 5, 2011

MVC vs 3-Tier Pattern

I have had several people ask me what the difference is between MVC (Model View Controller) and Three-Tier architectural patterns. It is my intent to clarify the confusion by comparing the two patterns side-by-side. At least in part, I believe the source of some of the confusion is that they both have three distinct layers or nodes in their respective diagrams.

Three-Tier MVC
If you look carefully at each diagram you'll notice the associations (arrow connectors) between the boxes are set up a little differently.

Three-Tier

A 3-tiered system really is made up of layers (think of cake layers). The UI Layer has access to the Business Logic Layer, and the Business Layer has access to the Data Layer. But the UI Layer cannot directly access the Data Layer. In order for the UI Layer to access data, it must go through the Business Logic Layer via some kind of interface. If it helps, you could think of each layer as one big loosely coupled component with strict design rules of access between layers.

MVC (Model View Controller)

In contrast, the MVC pattern obviously does not keep a layered system. The Contoller accesses the Model (a runtime data repository) and the View. The View then accesses the Model. Exactly how does that work? The Controller ultimately is the logical decision point. What sort of logic? Typically, the Controller will retrieve, build, or modify a Model base on some triggered action. The Controller then decides which View is appropriate via some internal logic. At that point the Controller will push the Model to View.

Note: Because I mostly develop with .NET, Microsoft has adopted the MVC pattern for ASP.NET with their own platform (see http://www.asp.net/mvc). You can certainly use the MVC pattern without Microsoft's platform, but why reinvent the wheel? I have been very happy using it so far.

When Do I Choose Which Pattern?

First of all, these two patterns are definitely not mutually exclusive. In fact in my experience they are quite harmonious. Often I use a multi-tiered architecture, such as a three-tiered architecture, for the overall architectural structure. Then, within the UI Layer, I use MVC. Something like the diagram below.

51 comments:

  1. Hi Suma,

    I'm not sure if there is a good code example that will clearly show this. Your MVC project is your UI layer. Your business logic or mid-tier layer technically could be in your MVC project, but I prefer to have any other combination of linked projects or services externally or in your solution. This keeps some defined boundary (though not perfect) for other developers to have the UI and mid-tier layer separated. Your data layer is typically something like a database or file system. You keep your three-tier system in line by never allowing your UI and data layers to communicate directly with each other. The UI layer must make calls to the business logic layer to get data from the data layer.

    I hope that helps. Let me know if you need any further clarification.

    ReplyDelete
  2. Hi BRYAN recently i attended one interview in that they asked me what is MVC architecture and give one example to illustrate.I just explained what is MVC. but i cant able to explain the example.Can u pls put ur effort to give simple example based on MVC architecture.Thanks in advance BRYAN.

    ReplyDelete
  3. Hii This is sandeep Rath(software developer in mvc) any body wants asp.net mvc realtime projects then mail me.my mailid is sr034937@gmail.com

    ReplyDelete
  4. Hi,
    What's difference between DAL, Model and BLL in your example?

    ReplyDelete
  5. Programming is combination of intelligent and creative work. Programmers can do anything with code. The entire Programming tutorials that you mention here on this blog are awesome. Beginners Heap also provides latest tutorials of Programming from beginning to advance level.
    Be with us to learn programming in new and creative way.

    ReplyDelete
  6. Great work to sharing this. It is really a great work and the way in which u r sharing the knowledge is excellent.
    Thanks for helping me to understand advaced concepts. As a beginner in Dot Net your post help me a lot.Thanks for your informative article.
    dot net training in velachery | dot net training in chennai

    ReplyDelete
  7. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    Digital Marketing online training

    full stack developer training in pune

    full stack developer training in annanagar

    ReplyDelete
  8. I am really happy with your blog because your article is very unique and powerful for new reader.
    Click here:
    Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune

    ReplyDelete
  9. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    python training in OMR
    python training in Bangalore
    python training in rajajinagar
    Python training in btm
    Python training in usa

    ReplyDelete
  10. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
    Blueprism training in Pune

    Blueprism online training

    Blue Prism Training in Pune

    ReplyDelete
  11. Fantastic work! This is the type of information that should follow collective approximately the web. Embarrassment captivating position Google for not positioning this transmit higher! Enlarge taking place greater than and visit my web situate
    Data Science training in kalyan nagar | Data Science training in OMR
    selenium training in chennai | Data Science training in chennai
    Data science training in velachery | Data science online training

    ReplyDelete
  12. This is beyond doubt a blog significant to follow. You’ve dig up a great deal to say about this topic, and so much awareness. I believe that you recognize how to construct people pay attention to what you have to pronounce, particularly with a concern that’s so vital. I am pleased to suggest this blog.

    java training in chennai | java training in bangalore

    java online training | java training in pune

    ReplyDelete
  13. Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  14. myTectra a global learning solutions company helps transform people and organization to gain real, lasting benefits.Join Today.Ready to Unlock your Learning Potential !Read More...

    ReplyDelete
  15. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.


    AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners

    AWS Training in Chennai |Best Amazon Web Services Training in Chennai


    Amazon Web Services Training in Pune | Best AWS Training in Pune

    ReplyDelete
  16. Selenium is one of the most popular automated testing tool used to automate various types of applications. Selenium is a package of several testing tools designed in a way for to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms and for the same reason, it is referred to as a Suite.

    Selenium Interview Questions and Answers
    Javascript Interview Questions
    Human Resource (HR) Interview Questions

    ReplyDelete
  17. Thanks for such a great article here. I was searching for something like this for quite a long time and at last, I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays. Well written article.Thank You for Sharing with Us angular 7 training in velachery

    ReplyDelete
  18. Goyal packers and movers in Panchkula is highly known for their professional and genuine packing and moving services. We are top leading and certified relocation services providers in Chandigarh deals all over India. To get more information, call us.

    Packers and movers in Chandigarh
    Packers and movers in Panchkula
    Packers and movers in Mohali
    Packers and movers in Panchkula
    Packers and movers in Chandigarh

    ReplyDelete
  19. Dr Itua cure my HIV, I have been a ARV Consumption for 10 years. i have been in pains until i came across Dr Itua on blogs site.I emailed him about my details of my HIV and my location i explained every thing to him and he told me that there is nothing to be scared of that he will cured me, he gave me guarantee,He ask me to pay for items fees so when i'm cured I will show gratitude I did and giving testimony of his healing herbs is what I'm going to do for the rest of you out there having HIV and other disease can see the good work of Dr Itua.I received his herbal medicine through EMS Courier service who delivered to my post office within 5 working days.Dr Itua is an honest man and I appreciate him for his good work.My GrandMa called him to appreciate him and rest of my friends did too,Is a joy to me that I'm free of taking Pills and having that fat belle is a nightmare.you will understand what i'm talking about if you have same problem I was having then not now though.I'm free and healthy Big Thanks To Dr Itua Herbal Center.I have his calendar too that he recently sent me,He Cure all kind disease Like,Cancer,Herpes,Fibromyalgia,Hiv,Hepatitis B,Liver/Kidney Inflamatory,Epilepsy,Infertility,Fibroid,Diabetes,Dercum,Copd ,and also Bring back Ex Lover Back..Here his Contact .drituaherbalcenter@gmail.com Or Whats_app Number +2348149277967

    ReplyDelete
  20. Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
    Check out : machine learning training in chennai
    top institutes for machine learning in chennai
    best machine learning institutes in chennai
    artificial intelligence and machine learning course in chennai

    ReplyDelete
  21. Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement

    ReplyDelete
  22. Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
    Thanks & Regards,
    VRIT Professionals,
    No.1 Leading Web Designing Training Institute In Chennai.

    And also those who are looking for
    Web Designing Training Institute in Chennai
    SEO Training Institute in Chennai
    Photoshop Training Institute in Chennai
    PHP & Mysql Training Institute in Chennai
    Android Training Institute in Chennai

    ReplyDelete
  23. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information regarding Microsoft Azure which is latest and newest,

    Regards,
    Ramya

    Azure Training in Chennai
    Azure Training Center in Chennai
    Best Azure Training in Chennai
    Azure Devops Training in Chenna
    Azure Training Institute in Chennai
    Azure Training in Chennai OMR
    Azure Training in Chennai Velachery
    Azure Online Training

    ReplyDelete
  24. You are doing a great job. I would like to appreciate your work for good accuracy
    Regards,
    Selenium Training Institute in Chennai | Selenium Testing Training in chennai

    ReplyDelete
  25. I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.

    Microsoft Azure online training
    Selenium online training
    Java online training
    Java Script online training
    Share Point online training

    ReplyDelete
  26. Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks from every one of us.
    Selenium Training in Chennai | SeleniumTraining Institute in Chennai

    ReplyDelete
  27. Thank you so much for a well written, easy to understand article on this. It can get really confusing when trying to explain it – but you did a great job. Thank you!
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  28. It's a Very informative blog and useful article thank you for sharing with us, keep posting learn more about BI Tools Thanks for sharing valuable information. Your blogs were helpful to tableau learners. I request to update the blog through step-by-step. Also, find Technology news at
    Tableau Training

    Android Online Training

    Data Science Certification

    Dot net Training in bangalore

    Blog.

    ReplyDelete
  29. nice blog... thanks to share info about your services. This is really useful.
    Vashikaran Specialist
    Vashikaran Specialist Astrologer

    ReplyDelete
  30. This is the exact information I am been searching for, Thanks for sharing the required info with the clear update and required points. To appreciate this I like to share some useful information regarding This Topic which is the latest and newest for me.

    Regards,

    Whatsapp Group Links List

    ReplyDelete