Friday, August 25, 2006

Is 3 Layered Architecture = MVC

Very nice discussion is going on this thread.

http://forums.asp.net/thread/1379168.aspx

At first after reading the post, I also got confused by striking similarities between two patterns thought one is design pattern other one is application pattern.
Survic has written a nice post on confusion regarding MVC.

This is one of best articulated posts that I have come across on this topic.


If you don’t understand confusion about MVC then read

First there are two documented versions of MVC
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html

Here is sample of discussion on MVC and ASP.Net in which I took part
http://forums.asp.net/2/1249964/ShowThread.aspx


If you thought that this is enough then there is a MVP pattern.

Example of
http://codebetter.com/blogs/jeremy.miller/archive/2006/07/11/147305.aspx

After that Martin Fowler splits MVP into two parts to clear confusion (But now I am more confused)
http://geekswithblogs.net/billy/archive/2006/07/20/85815.aspx
http://martinfowler.com/eaaDev/PassiveScreen.html
http://martinfowler.com/eaaDev/SupervisingPresenter.html



I always use MVC as GUI or WEB based design pattern.
MVC is a design pattern for Interactive Interfaces.(LudovicoVan corrected me)
MVC in web context is more geared towards streaming HTML to different devices that understand HTML while 3 layer architecture is independent of any technology.
http://www.martinfowler.com/eaaCatalog/
http://www.martinfowler.com/eaaCatalog/modelViewController.html

One comment was that we should implement MVC in every layer of application.
I think that I know what the poster is implying.
Generally I believe in understanding the intent of pattern and implementing it my way that suits my project. But at the same time, we have to maintain some essence of design pattern for clear communication. While I understand what the poster is implying, I think that are specific patterns (factory,fascade,process layer,Aggregation etc) to describe the patterns applicable to good enterprise distributed computing needs.

Note: I am going to revisit this post

2 comments:

survic said...

You have a way to find things to discuss!

This MVC thing prompts me to think about why MVC is so confusing, there are 5 elements:

http://survic.blogspot.com/2006/08/why-mvc-is-so-confusing.html

Vikas said...

Hi Survic,
This is one of best articulated posts that I have come across on this topic.
But you can ignore MVC only if you are streaming HTML only to Browser.
if you are streaming HTML to other devices (e.g,. Mobile,Excel,MsWord), you have to use some form of MVC.
As you said code-behind is tied to view, it is not a true controller. So from code-behind, you have to initiate a true controller and keep your code(creating and manipulating Model) there.