I've just started getting into the Microsoft MVC Preview 3. Its cool and I'm having heaps of fun with it. Who thought you could have multiple form tags on a page ;-)

I wrote a post earlier this year after spending a couple of weeks in Ireland with some Java developers. I originally posted it internally at work with the intention of stirring up some .NET developers in my team. Today I decided to check out what I'd written to see if added any value to Microsoft MVC framework I am using now. It doesn't, but I decided to post it publicly anyway.

Its taken a while but you knew it was coming. Having come in contact with some Java development from a .Net world I wanted post some observations and opinions. Ive really only had one day of exposure to server side Java, so Im sure this article wont be completely technically correct and Im happy for people to comment on my errors or oversights.

Firstly Ill start with the background. These boys are using Java SE (Standard Edition I guess) and not EE (Enterprise Edition). My understanding is that Java EE comes with some additional web framework elements, but I stand to be corrected on this.

Java SE at first glance actually looks like classic ASP with Java code. Just to clarify, both a server side languages and not VBScript and Javascript respectively. Both use the <% %> characters to separate the code from the response. Both can just write to the output directly. Both .jsp and .asp files can be called directly by URI and can respond (provided they are hosted on suitable web servers). So right now this looks like I should be comparing Classic ASP to Java, but thats no brainer. Java is a native OO language, platform independent and also has native support for threading; game over classic ASP.

There still is the issue that Java server side code can very quickly degenerate to the spaghetti code we have seen in classic ASP code. And it can, and would if written badly. But to be fair, any language can. In some ways being a native OO language you have the tools to protect you against this. Really its still pretty primitive for a web framework.

The comparison with the ASP.Net framework becomes a much more interesting when you add the Apache Struts framework to Java. Basically the Struts framework is an implementation of the Model View Controller (MVC) pattern. The MVC pattern has is roots in an Apple SmallTalk framework. It wasnt a framework that was used for web applications, but it did have clearly defined model, view and controller components.

MVC is a pattern to implement a system that takes requests and deliver responses. This is what HTTP is all about, all web servers do it.

The MVC pattern consists of three components. There is the Model which is the domain logic (a.k.a business logic or middle tier) and it also includes the data persistence the domain logic works with. There is also the Controller which is responsible for taking the request and routing them to the correct business logic, it then routs the output of the logic to a View. The View selected by the Controller takes the output from the domain logic and presents it to the user. These guys weren't using the standard "View" from Apache struts they used XSLT to transform XML data from the model to HTML.

ASP.Net uses a page life cycle pattern to handle the same problem. We know this well; An .aspx page is requested, the aspx page points to some page logic, which can then calls some domain logic. The page then binds data to objects capable of rendering a view of that data. It seems normal that events on the rendered page are posted back and handled by that same page code. This is vastly different to how the MVC pattern works.

_This has already got to long, so Ill post another blog soon to continue this discussion and hopefully get stuck into the inevitable debates about the merit of both.

Feel free to comment corrections, additional information or opinions.

Tarn

I hope to write some more relevant posts about my recent experiences with the Microsoft MVC framework soon. At the moment I'm having too much fun coding with it, and don't yet have much to say that Rob Connery, Scott Hanselman and Scott Gu haven't covered.