Hello .NET World

I have been a Java world resident for more than seven years now. I was recently introduced to .NET as we developed a web application using ASP.NET framework. Here are some of the things that stood out the most for me. I hope they can serve as a short and high-level introduction to someone who needs to transition as well.

High Level of Abstraction

One of the goals of ASP.NET is to hide the low-level implementation details of HTTP and HTML. As such, the framework provides a component-based, event-driven programming model for the web. Having worked with Struts (v1) before, this is completely different. Having worked with Barracuda in the past (another servlet-based presentation framework), this seemed somewhat familiar. There are 2 concepts that I think are at the heart of ASP.NET and need to be understood before anything else: the postback mechanism and the page lifecycle. Together they explain how HTTP requests are processed by the ASP.NET IIS server, and how HTTP responses are returned from it.
Briefly, the postback is a technique meant to deal with the stateless limitations of HTTP. The ASP.NET framework devised a way of serializing the state of various UI components. This serialized value – called View State – is rendered in a hidden input field, submitted to the server on subsequent requests, and used by the framework to recreate the page. The page lifecycle refers to the sequence of steps involved in processing a web form or page. They correspond to different events raised by the ASP.NET runtime once a request is submitted to the server and routed to its corresponding handler or page controller. You can plug into the processing flow at any stage (e.g. Page.Init, Page.Load, Button.Click etc) by overriding the equivalent event handler.

Support for AJAX

The ASP.NET AJAX framework is designed to allow developers to implement AJAX functionality in a transparent and integrated way with little knowledge of scripting, while bringing more structure to the world of JavaScript. The main component is the UpdatePanel which allows refreshing partial areas of a page – wrapping content in an UpdatePanel will cause the server to target markup to the area of the DOM occupied by the panel. I find it extremely helpful in cases where a page is composed of multiple areas that require asynchronous updates triggered by various user events. This is not easy to manage in a traditional JavaScript way.

In addition, AJAX.NET AJAX Control Toolkit provides an entire set of AJAX-enabled components – they combine server-side and client-side behavior to help create a rich, interactive user interface.

Support for Web Services

It is extremely easy to create web services in .NET using Visual Studio – it’s just another component that you can add to your project, and the framework will generate all necessary artifacts. There is no need to deal with SOAP or WSDL unless you a have a reason to – for example if you need more control over the messages your service supports. In the Java world, Spring-WS offers one of the easiest ways to expose or consume web services. I find that it requires a bit more configuration work and more XML-level involvement.

Code Generation

Microsoft provides many tools designed to assist the development process and increase productivity. For example, you can create your web pages by ‘dragging and dropping’ UI controls onto a designer surface area. Code gets generated behind the scenes. This was new to me, and I was pleasantly surprised by the quality of the generated code and by how easy it is to switch between the two views – designer and code view. It may not always work very well in case where the page is created in a more dynamic way or if you use third-party UI controls that do not know how to render themselves in the designer. In these cases I tend to work with code directly.

A New Programming Language

We chose C# for our project. To a Java developer, this feels very familiar. C# deserves an article by itself, but Overall, it does take all good things from Java and C++ and adds a few of its own: delegates, properties, attributes, extension methods are some of them.

Development Environment

Microsoft did a great job with Visual Studio. It integrates a variety of tools you might need during development (a database client, database diagram generator, class diagram generator, etc) and the performance is excellent. One key-stroke (F5) will build and deploy the entire application. For our medium-sized project, this takes about 1 second.

Overall

Philosophy-wise, my feeling is that Microsoft is more focused on integrating everything while the Java philosophy is more about decoupling, separating everything. For example, I feel that there is no emphasis on creating a layered architecture in .NET (of course it can be designed into the application), in which software in any tier can be independently upgraded or replaced. I also feel that the ASP.NET framework is great if you’re willing to play along with it. As soon as you need something different, it can be quite a struggle. (this makes me wonder if there’s such a thing as too much abstraction; usually the things that make our life easier are also the things that make it more complicated). I did miss the ‘open-source’ factor. The fact that you don’t have access to source code can be quite frustrating at times, but the documentation, in general, is good enough to compensate for it. One nice surprise was that many tools and frameworks available in Java, have a .NET equivalent (Spring.NET, log4net, Quartz.NET, NHibernate)

People often ask me – do I prefer a .NET versus a Java-based solution. The answer does not come easily. First of all, there are a variety of factors that may come into play when evaluating a technology for developing a web application (and this can be an entire article in itself). But, I think it’s safe to say for now, that for a small to medium application, I would choose .NET. For a large enterprise application I would choose Java. At the end of the day, both .NET and J2EE provide everything you need to get the job done.

  1. Good overview! The View State in particular is a strange beast. It doesn’t behave the way you think it does. Here are a couple of articles that describe its nuances:

    http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/truly-understanding-viewstate.aspx
    http://geekswithblogs.net/FrostRed/archive/2007/02/17/106547.aspx

    Dmitri Vassilenko
    Jun 24th, 2010
  2. The article has reminded me about the older debate between Sun Microsystems’ J2EE vs. Microsoft’s .NET (Java vs. C#, or James Gosling vs. Anders Hejlsberg…).

    At Jonah Group we are using both platforms nicely!

    Michael Vasilian
    Michael Vasilian
    Jul 7th, 2010

Add a comment

Comment feed
The better to greet you with
No one will ever see this
Your pride and joy
The reason this comment form exists

The crew behind ASOT

We're a team of interactive, software, and business intelligence experts skilled in the design, construction, and management of online enterprise systems.

Visit The Jonah Group site

Get in touch with us