I am trying to figure out the difference between MVC and 3-tier architecture. I know that MVC, in big applications, applies to the presentation tier of 3-tier architecture:
If I'm right, what's the difference between the Model layer of MVC and the Logic tier of 3-tier Architecture?
Another way to think of it is that MVC can act as the presentation layer of your 3 tier architecture.
To specifically answer your question, in MVC the Model is a representation of your data. the View presents and acts on your data and the Controller marshals your Models between the rest of your architecture (perhaps the BL of your 3 tier architecture) and the Views.
I basically treat the MVC Model as the Entities in the Layered Architecture. I have thought about this sometime back and have written about it here.
http://serena-yeoh.blogspot.com/2011/12/mvc-and-layered-architecture.html
You can also get a sample implementation in code from here
http://layersample.codeplex.com/
Related
I am new in MVC and little confuse and want to ask about differences and purposes of both.
MVC model and Business Logic layer (BLL) in tier Architecture.
What is the purpose and need to use BLL? some say they exchange the data between Presentation layer and data access layer. except these elaborate the BLL purpose.
So, we create properties in both MVC Model and BLL. So mention the proper difference and similarities if it has with the relevant code or example
Thanks
To me the M in MVC is about the view model used by the view. Each view has its dedicated view model, that contains all information needed by the view.
These view models are built in the controllers based on the DTO's that you receive from your back-end.
The BLL you are talking about is more the business layer on the back-end, which you don't know in your front-end logic. Often people use a domain driven approach or this layer.
First, it is already clear to me that the most important point of MVC is the separation of responsibilities. Lately I have been reading some articles/Q&A in the web to understand the differences between most popular MVC implementations. Examples:
Architecture more suitable for web apps than MVC?
http://joel.inpointform.net/software-development/mvvm-vs-mvp-vs-mvc-the-differences-explained/
If I got it right, people say that the major difference between MVC and MVP is that there is no communication between model and view layers in MVP, controller works as a mediator between both. However, I do not see this restriction in MVP original paper: http://www.wildcrest.com/Potel/Portfolio/mvp.pdf, it just seems to add details to the MVC model, in the form of selections, commands and an interactor.
It seems to me that MVP is just an overloaded MVC acronym which may mean one of two MVC patterns: passive view or supervising controller.
Could someone clarify this?
I currently have a web application that is based upon a 3 Tier architecture. I wish to change my Presentation layer from using Web Forms to MVC4.
Now I have done some research and from what I read I understood that the View represents the .aspx of a Web Form. The Controller represents the Code Behind (.cs) of a Web Form.
The problem that I have is that I do not see any use for the Model. This is because I can directly call methods from the Business Logic Layer directly from the Controller making the purpose of the Model useless.
Is there something that I am misunderstanding? If so what are you views on implementing an MVC design patter for the presentation layer in a 3 layer architecture?
In a simple application the model in MVC can simply be the DTOs from the Application or Business Layer. In this case you're right, you probably don't need a separate model in the UI.
MVVM is a Microsoft design pattern that existed before ASP.Net MVC. Can anyone through light on differences between MVVM and the new MVC pattern?.
Can anyone throw light on differences between MVVM and the new MVC pattern?.
Yes: When using ASP.NET MVC the MVC pattern uses the controller to render the model directly into the view. This is perfectly acceptable for trivial projects with a small number of objects. Where this can become a problem is that the concerns of the UI layer can bleed through to the underlying (domain) model.
When using MVVM then you are adding an abstraction between the Model and the View, which is of course the ViewModel. This allows the author to project into the view an object that is most readily consumed by the view. The ViewModel can contain things which would be out of place in the (domain) Model. The cost associated here is that you need to have mapping logic which transposes the data from the model to the View Model. Tools like AutoMapper can assist with this chore.
A simple example of this might be the Model doesn't require certain fields as required, but a particular View does. Rather than baking this logic into the user interface, if it is attached to the ViewModel, then other UI's can consume the same VM without having to duplicate logic that was baked into the first user interface.
MVC and MVVM are actually quite different. There seems to be a fair bit of misunderstanding of MVVM when talked about with ASP MVC. The practice of making 'View Models' in MVC, which are specific classes to feed views, while good practice is not true to the spirit of MVVM, and in fact is just a cleaner version of MVC.
MVVM is more suited to the desktop using WPF or similar, or purely in the browser using a JavaScript framework such as knockout.js. The pattern is quite different to MVC and involves views being 'subscribed' to the model.
I would venture to suggest that MVVM is Microsoft's design pattern and ASP.NET MVC, which is farily recent, is a specific implementation by Microsoft (that doesn't necessarily adhere to either MVC or MVVM but is similar). And as suggested by Reed, MVC has been around since the 70's.
Both MVC & MVVM are architectural patterns. MVC has its roots way back to Smalltalk. ASP.NET MVC is Microsoft's implementation of the MVC pattern using ASP.NET framework.
Both the patterns deal with separation of concerns. MVC is more to do with the interaction of various commonly used layers in an application like Model (data layer), View (presentation layer) and Controller (business logic layer).
With advanced databinding capabilities of WPF and Silverlight, MVVM was more suited and publicised as the next big thing. Martin Fowler generalized these patterns as presentation patterns in his Enterprise Application Architecture book.
One advantage I see in using a ViewModel is that it allows you to test the application code better using unit tests. Because of this reason I find MVVM or at least the ViewModel bit of it being used quite often in ASP.NET MVC applications as well.
I'm making my way through the early Data Access Tutorials on Microsoft's ASP.NET website and it occurred to me that this all seems awfully similar to what I have read about separating your logic and presentation code using the MVC pattern. As a newbie I have yet to implement the MVC pattern but I'm curious as to how these two design structures differ and if I should be focusing my attention on one or the other, particularly in the context of web design.
MVC addresses more than just data access. In MVC, both the DAL and BLL is incorporated into the Model. The view defines how the model data is presented to the user, while the controller is what responds to user inputs (GET/POST on the web).
An alternative to MVC is a classic N-tier architecture where you have a presentation layer, a business layer, and a data access layer. In this architecture, the components of the view and controller are wrapped together in the presentation layer. WebForms/WinForms is an example of the N-tier architecture, while ASP.Net MVC is an example of MVC in the Microsoft space.
The link you've posted for the Data Access Tutorial is implementation of MVC pattern. MVC pattern is a concept, implementation can differ; you have this in ASP.NET whereas in Java there's one framework called Struts, which is an implementation MVC.
DAL & BLL patterns differ from the MVC pattern in terms of concepts; but NOT this specific implementation. MVC is actually achieved through usage of DAL, BLL & View Patterns.