Good2Read: ASP.NET 2.0 Website Programming: Problem – Design – Solution

If you have been programming for a while you have come to understand that the only way to keep up with the ever growing amount of technology Redmond throws at us is to read…constantly…without stopping.  The fact that everybody and their mother seems to be writing nowadays doesn’t help the situation either.  Over the years I’ve come to identify authors and publishers that seem to produce quality books on a variety of subjects.  Authors like like Carli Watson, Rockford Lhotka, Steve McConnell (to name a few) put out quality on everything they write.

A new face in the good authors line up is Marco Bellinaso.  Marco wrote ASP.NET 2.0 Web Site Programming which turned out to be a great book I always recommend to someone that knows some ASP.NET and wants to take their development of enterprise level applications to the next level.  Marco has done an excellent job at outlining what I think should be the path every developer takes in identifying the problem at hand, designing the application and providing a solution to the client.  Reading Marco’s book is a delight for the one seeking how serious development is done.  It is the kind of book that you wear out from frequent reading because it could easily become part of one’s library of reference books.

If you are looking for a sound approach to the world of web development look no further, you have arrived.  Reading this book you’ll learn concepts like how UML design fits in the overall planning stage, how designing a  Data Access Layer (DAL) and a Business Logic Layer (BLL) prior to any UI implementation (what a concept right?) is the key to an application that can withstand the test of time and much more.  Marco’s conversational writing approach makes the learning of these important concepts simple to understand and implement.

Good2Read: The ADO Entity Framework

I recently started playing with the ADO Entity Framework. In a nutshell, the EF creates a model representation of all your data (tables) and turning it into classes (objects). So your Employee table with columns like FirstName, LastName etc, is turned into an Employee class with properties such as FirstName, LastName, etc. Though there is a learning curve I actually was performing CRUD against the database very quickly and got used to the LINQ to Entities way of querying the database with ease. Though I have my reservations (i.e. stored procedure support is kind of convoluted to implement) I’m hoping this is the first iteration of something that will be a good tool to have, not a hindrance, in developing data centric applications.

Links

Good2Read: ASP.NET WebForms vs MVC

Dino Esposito, and if you don’t know who he is you need to read more, has an excellent article on the July issue of the MSDN Magazine where he compares WebForms and ASP.NET MVC.

If you haven’t taken the plunge into the MVC pool, below are some pros and cons of both WebForms and ASP.NET MVC.

WebForms

Pros:

  • Third party controls
  • As close as stateful forms as an app can get with viewstate, postbased and the event-driven paradigm.
  • No need to know HTML, CSS, etc.  Just know .NET and you are ready to go.

Cons:

  • Hard to  test
  • HTML abstraction hinders browser compatibility
  • Hard to integrate with javascript frameworks such as jQuery, PrototypeJS, etc.
  • Lack of parameters in links when using viewstate tends to yield pages that rank lower on search engines.

ASP.NET MVC

Pros:

  • Separation of concerns (SoC) architecture
  • Ideal for Test Driven Development (TDD)
  • Complete script and CSS freedom due to simpler markup

Cons:

  • Full control of HTML, Javascript and CSS might be seen as a weakness for some.
  • Requires familiarity of the MVC pattern.  One needs to know how Models, Views and Controllers work together.

So when it is all said and done, it comes down to using the right tool to address a particular issue.  Don’t get stuck with only a hammer in hand because then everything you’ll see will look like a nail.

Skills2Know: The Views folder Web.config file

The Views Web.config allows you to set the defaultLanguage, masterPageFile and pageBaseType attributes all within the config file globally so that you don’t have to have it listed within each view.  So your web config would have the following…

<configuration>
  <system.web>
    <compilation defaultLanguage="C#" />
    <pages
        masterPageFile="~/Views/Shared/Site.master"
        pageBaseType="System.Web.Mvc.ViewPage"
        userControlBaseType="System.Web.Mvc.ViewUserControl">
    </pages>
  </system.web>
</configuration>

And you won’t have to list these declarations in the actual view:

<%@ Page Language="C#" 
  MasterPageFile="~/Views/Shared/Site.Master" 
  Inherits="System.Web.Mvc.ViewPage" %>

This file also allows you to add namespaces includes to it and not having to do it within the view itself.

    <pages>
      <namespaces>
        <add namespace="Haack.Mvc.Helpers" />
      </namespaces>
    </pages>

So as you can see this approach stays true to the old cliché, less is more.