Thursday, July 23, 2009

Page Life Cycle and Basic C#

As a Java web application developer transitioning to ASP.NET / C# (or rather doing it properly as I covered it briefly at uni), I thought it would be good to document my learning as I discover differences and similarities along the way.

I began by looking into the ASP.NET Page Life Cycle the apparent equivalent of the JSF application lifecycle consisting of the Postback and ViewState concepts. Also of interest is securing the view state and best practices for state management.

I then moved on to start re-looking at the syntax and capabilities of C#. In terms of transition from Java it at first feels like home from home i.e. curly brackets, semi-colons, substitute import for using, package for namespace. However there are some interesting differences. For example using strings in a switch statement is something Java developers must have tried at least once. Getters and setters can be implemented as Auto-Implemented Properties and is being discussed for Java 7 and object initialisation overcomes the need to create several many overloaded constructors. String.IsNullOrEmpty is useful and something typically implemented in a common/utility library.

Agreeing upon a directory layout in Java is a common task for development teams so it felt quite nice to be told by ASP.NET that I should place my code in the App_Code folder.

I was also surprised by the amount of .NET 3rd party tools available on the marketplace. In Java, you are often overwhelmed by choice when it comes time to decide on a framework or tool to invest in. Choice is good, however if you are unfortunate enough to make the wrong choice, it can also be dangerous. When I came to comment my code I thought I would not have to make a choice over which route to take, but it appears I may have to. Sandcastle is the obvious choice or should I opt for something like Document! X?

That's it for now, more to come...

No comments: