Reputation: 53
So what are the benefits from creating a presentation layer (of a 3layer project) using MVC. If you can provide sources that would be nice. Thank you.
Upvotes: 0
Views: 97
Reputation: 2104
The biggest benefit to be ease of code reuse. Once you move to MVC, there are no dependencies on the presentation of your data or the storage of the actual data.
For example you could write a servlet that served up .jsp pages as your presentation layer one day, and the next day write a web service as another presentation layer to your existing Model and Controller. Like wise if you want or need to switch your DBMS. Since accessing the Model is completely separate from everything else, you would just need to re-write just your data access objects to return the data in a way your Controller can handle it.
By separating concerns into 3 distinct pieces, you also facilitate true unit testing. Your Presentation layer can be tested free of the Model or Controller, and vice-a-versa.
On a side note, I've often felt that the MVC abbreviation was inaccurate. Whenever I see it I think of it as View->Controller->Model. The presentation layer will never have Data Access code in it, and the model will never have presentation logic in it. The Controller is forced to act as a go-between.
Upvotes: 1