Tuesday, March 8, 2011

Anything Ruby can do MVC3 can do better. jQuery can do anything better than Flex.

It has taken Microsoft quite some time to catch up to the benefits of Ruby on Rails, Flex and PHP, and they have been doing a great job combining the best of all worlds. MVC3, the soon to be released Entity Framework 4.1, NuGet, and HTML5/jQuery have created a buzz with developers.

Model-View-Controller (MVC) Framework created by Microsoft adheres to a design pattern that tries to keep web application development modular. Controllers are designed to handle HTTP requests and perform CRUD operations on a data model; View pages try to separate business logic and data layers from the presentation layer. Developers can tell MVC to scaffold View pages based on their Controller Actions, and the View will usually have access to public members of a data model; Database communication can be written within Controller Actions but, in an effort to keep the business logic and data layers modular, the developer can choose to reference methods of a repository that perform CRUD operations on the database. In my opinion, the business logic layer is not fully modular and cannot always be restrained to the Controller. Therefore, it is of best practice to keep a web application architecture document. This documentation should clarify a developer's or team's intent on using any design patterns or agile development methodologies and specify how they are used.

The MVC Framework arms .Net Developers with a global url routing system similar to that offered in Ruby on Rails. What this means is that you can write custom rules (or use the default rule: /Controller/Action{/Optional ID}/) to hide the true url path of your web pages and map the request to a Controller Action, which handles the loading of a particular View and passes in an optional ID parameter. Developer can also start building in MVC on top of an existing web site, leaving their older web pages untouched.

The latest version of the MVC framework is MVC3. Within it, Microsoft has added support for Razor syntax as an alternative to using native C# syntax for coding in the View Engine. Razor is another feature borrowed from Ruby and, not only is it faster to write and easy to learn, it is much easier on the eyes. Also, upon starting a new MVC3 project you will find it uses HTML5 doctype, and that jQuery Validation and jQuery Unobtrusive Validation scripts are already referenced in your Master Pages. Microsoft worked with the jQuery team to develop these scripts that provide better server-side and client-side validation of WebForm fields than did the recommended way to implement validation in MVC2. Currently, Microsoft's Entity Framework, for mapping data models to database, seems to be competing with code-first solution, NHibernate3. While I love Microsoft's Entity Framework 4.0, it does not yet offer a code-first approach to development. However, it has been announced that Entity Framework 4.1 will support code-first and I would much rather use Microsoft's implementation. I currently use EFCodeFirst (CTP5) package because it is built on top of Entity Framework 4.0, and by using it I expect an easy transition in to Entity Framework 4.1. It is nice to see Microsoft embracing the most sought-after features and, I am thankful for open-source technologies raising the bar and leaving this room for improvement.

Website and WebForms development has also become a lot more exciting. jQuery UI offers pre-made user interface elements that are very easy to implement in to the pages of a .Net MVC3 Web Application. There are also many jQuery "plugins" shared amongst developers, and some have become so good that the jQuery team has agreed to add them to their growing list of officially supported plugins. With a combination of jQuery, jQuery UI, JavaScript, CSS2.5 and HTML5, developers can create rich interactive web experiences very quickly. This creates a way for programmers to build as quickly as most drag-and-drop programs for website development allow. HTML5 offers many features that will be widely supported within the next few years, and may prove to be some tough competition for Adobe Flash. Personally, I have been shifting away from use of Flash whenever possible and putting my efforts towards HTML/jQuery. The reason for this is to develop cross-browser and cross-platform solutions and reduce dependency on browser plugins. And Adobe.. please stop charging so much for the Flash IDE. It crashes on me at least once a day!

No comments:

Post a Comment