Thursday, January 17, 2008

The much awaited .NET Framework source code is finally available

The source code of .NET Framework is finally available under a read only reference license, enabling programmers to browse the source code and debug their programs more deeply and effectively.

It seems that now the code of .NET Framework is so mature that they are releasing it for public. Let’s see how the proponents of open source perceive it.

Currently the following libraries have their source code available for browsing and debugging.

  • NET Base Class Libraries (including System, System.CodeDom, System.Collections, System.ComponentModel, System.Diagnostics, System.Drawing, System.Globalization, System.IO, System.Net, System.Reflection, System.Runtime, System.Security, System.Text, System.Threading, etc).
  • ASP.NET (System.Web, System.Web.Extensions)
  • Windows Forms (System.Windows.Forms)
  • Windows Presentation Foundation (System.Windows)
  • ADO.NET and XML (System.Data and System.Xml)

More and more libraries are said to be included in the above list.

You can refer to the the post by Shawn Burke on how to configure your Visual Studio 2008 to debug the .NET Framework Source Code.

Wednesday, January 09, 2008

FireBug + YSlow for Mozilla Firefox: A must use tool for all Web2.0 developers

I have been very keen in improving the response time of web applications and used to postmortem the web applications from the perspective of their initial load time, overall network traffic created, number of requests sent and the overall network traffic created to perform an action and a number of other parameters.

In order to perform this postmortem, the Mozilla add on in the name of Firebug comes in picture and really provide very useful and good enough information on the overall network traffic created, contents of each of the user request / server response, runtime inspection and modification in the CSS, HTML and Javascript of the currently viewed web page, JavaScript Debugger support for the java script statement “debugger;”, DOM Inspector and much more.

Thus, using this tool (Firebug; Mozilla Firefox Add-on), a Web 2.0 developer can very easily analyze which user action creates how much traffic behind the scenes using AJAX, which user action is performed at the client side, how much requests are generated for each user action, what’s the size of request / response for a user action and other such stuff related with the debugging of Java Script, modification in CSS and DOM Inspection. So, I would recommend every web developer who is involved in evaluating the different UI controls to be used in web applications or other such tasks related to improving the overall user experience of a web application to try this add-on; FireBug on FireFox. A snapshot of this tool, is shown below.

There is in add-on in FireBug in the name of YSlow. That provides information on how to improve the performance of your website. This add-on is by Yahoo Developer Network and automates the verification of all the Consideration for High Performance Websites in this single tool. This not only verifies and ranks the website against the said Best Practices for High Performance websites, but also provides information on what’s wrong and what you can do to improve the performance. A snap shot of the YSlow Addon of Firebug is shown below.

Something similar but with relatively lesser features is the IE Developer Toolbar, which Internet Explorer centric Web 2.0 developers, should definitely have a look at and experiment with. [Added: 22nd April 2008]

Another easy to use tool out there for Internet Explorer to perform a similar analysis of web applications (a bit buggy on I.E 6 at least on my machine) is the Web Development Helper by Nikhil Khotari. Below is the snapshot of that.

Tuesday, January 08, 2008

ASP.NET 3.5 Extensions Preview: Dynamic Data Websites Part 1, Engineering Data Centric Web Application from End-to-End

I hope you have gone through my last post that lists all pre-requisites for this tutorial and have prepared the development environment, on how to get hands on with these tutorials and walkthroughs on the newly added features in ASP.NET 3.5 Extensions Preview.

Here comes the very first tutorial in the series that’s on the Dynamic Data Websites. The reason for starting the ASP.NET 3.5 Extensions Preview tutorial series with this Dynamic Data Websites feature is to demonstrate how quickly you can engineer a data centric web application with the newly added features of ASP.NET 3.5 Extensions Preview. You will learn that the overall code required to be written by the end developer is reduced to the extent that one merely needs to write a few lines for any custom business rules or any customized view of the data which one may require as per the custom needs.

The pre-requisite, the portion I will not be covering in this tutorial for engineering a data centric web application from end-to-end is the designing of the database. I will assume that you have your database designed, tables and relationships with Primary and Foreign Keys created. The database I will be using for my tutorials as stated in the last post is the well known, Microsoft provided “Northwind” database.

So let’s start with the step by step walkthrough, in this part of Dynamic Data Website walkthrough I will be covering on how to engineer a web application with the built-in templates and features as provided by Microsoft in the ASP.NET 3.5 Extensions Preview. In the next post I will demonstrate on how to customize the generated web application by incorporating custom business rules and designing custom views as per the custom needs of your business. So, let’s get started with the step by step procedure.

  1. Create a new website, by clicking the “New Web Site” item in the “File” Menu. A dialog box titled “New Web Site” appears. Select the “Dynamic Data Website” from that “New Web Site” dialog box and set the location for that new Dynamic Data Website. Here I name the website “DDWDemo” i.e. Dynamic Data Website Demo.

  2. A new website containing the files/structure as shown below is created.

  3. Now we need to add database to our web application, for that I create the App_Data folder in my web application and drag n drop the mdf file of the “Northwind” database to it.

  4. Now we have our database added to our web application. I will start with generating the Business Entities for my Northwind database, so that I map my data in the Relational World to my Object Oriented World, and doing so is facilitated by the “LINQ to SQL Classes” feature of the ASP.NET 3.5 Extensions Preview. I will create a new LINQ to SQL Classes instance, which are internally mapped to relational objects, by right clicking on my website and selecting Add New Item. I select the LINQ to SQL Classes template and name it SCM.dbml (here SCM stands for Supply Chain Management and not the Software Configuration Management) and click Add. A prompt appears asking me to automatically put the files in the App_Code folder; I click on ‘Yes’ for it, and my LINQ to SQL Classes files is added in my project. This file provides me an Object Relational Designer through which I can easily generate my DataContext Class as well as the ADO.NET Entity Classes.

  5. Now what we do is that I double click on my Northwind database in the App_Data folder, it will open the database in the Database Explorer. I expand all the tables under it, select all the tables and drag and drop them on the left pane of the SCM.dbml file, that’s the object relational designer surface to auto generate my Data Classes for all the tables I have dropped on it. It will also automatically create the relationships among the generated classes by improvising them form Primary / Foreign Key Relationships in the Database. You can view the code generated by this action by expanding the SCM.dbml file and browsing the SCM.designer.cs file. The SCM.designer.cs file will contain the definition of SCMDataContext that allows access to all tables and handles the CRUD operations on the Business Entities through LINQ queries, moreover the SCM.designer.cs file contains definition of all the business entities, which are actually the ADO.NET Entities. One thing to note about them is that these generated business entities are defined as partial classes and also provides some extensibility methods (we will learn using them in part 2 of this tutorial).

  6. So, by now we have our Business Entities defined which are directly mapped to the Tables. Now we need to present them in a good way to the user so that User can perform the CRUD (Create, Read, Update and Delete) operations on these. This is facilitated by the use of templates defined in the Dynamic Data Website template. What we need to do is to set the enableTemplates attribute of the dynamicData section in web.config file to true. I can also optionally set the dataContextType attribute of dynamicData to SCMDataContext. So here, what I have done is that I have enabled the templates for the List and Details view of all the Business Entities defined in the SCMDataContext. By default it will use the ListDetailsTemplate.aspx for all the business entities. The ListDetailsTemplates.aspx is defined in the subfolder App_Shared/DynamicDataPages so that I can customize it to give a personalized look and feel. This template uses the master page defined in the website as MasterPage.master which I can customize too for the personalized look and feel; here I customize the main heading of the website to be ‘Supply Chain Management’ instead of dynamic data controls site. Just a food for thought that the ListDetailsTemplates.aspx uses the newly introduced Dynamic Data Controls and I would recommend having a look at these templates to get some idea on how it’s utilizing the features of ASP.NET 3.5 Dynamic Data Controls behind the scenes.

  7. Now, start the web application by clicking on the Start Debugging button in the toolbar of Visual Web Developer 2008. A prompt stating the Debugging isn’t enabled, simply click OK button on it to enable debugging and a web application with the default templates appears in front of you.

So, here in this tutorial, we have learnt on how to generate a Data Centric Web Application using ASP.NET 3.5 Extensions Preview, in a few clicks. In the second part of this tutorial which I will be posting in a day or two, I will demonstrate on how you can customize the Views for some of the entities, use some other template for some other entities as well as enforcing you custom business rules in the Business Entities.

You can download the complete source code of this walkthrough as a single package from here.

Wednesday, January 02, 2008

ASP.NET 3.5 Extensions Preview: Walkthroughs, Tutorials and Code Samples

Long time, no posts!!!

With the release of ASP.NET 3.5 Extensions Preview a couple of weeks back, I have been busy in experimenting with the new features and controls added in this very first preview of ASP.NET 3.5 Extensions.

The new additions like Dynamic Data Websites, Dynamic Data Controls, LINQ to SQL, ADO.NET Data Services and their invocation using AJAX, LINQ enhancements, ASP.NET AJAX enhancements definitely added sufficient enough data points to the proponents of ‘Using ASP.NET for RAD’.

Having said all that, the ASP.NET 3.5 Extensions Preview also includes the first public preview
of the much awaited built-in ASP.NET MVC Framework as well, the final release of which is expected in first half of this year. The addition of this built-in ASP.NET MVC Framework added a sound Architectural Pattern to the ASP.NET Web Development portfolio and it not only enforces the separation of concerns but also facilitates TDD that’s the need of the hour.

Earlier this week I have been presenting the said new additions in ASP.NET 3.5 Extensions to my office colleagues in successive training / tutorial sessions titled “What’s new in ASP.NET 3.5” on each of the newly added features and they went great and, from now I will be posting the scripts / walkthroughs with code samples of all those sessions over here by this weekend, for my office colleagues in particular and rest of you in general.

I used the well know “Northwind” database in all the tutorials so that I every one has the general idea of the DB Schema. For your convenience I will be including the Database files in the sample codes of each of the tutorial as well, in order to provide you a single code sample package for each of the tutorial.

In the mean time I would recommend all of you to prepare the Development Environment for those tutorials and walkthroughs accompanying the code samples which I will be posting by this weekend. All you need to have on your system is the Visual Studio 2008 and the newly released ASP.NET 3.5 Extensions Preview. If you don’t have Visual Studio 2008 then for the time being you can go with the free Visual Web Developer 2008 Express Edition as well instead of Visual Studio 2008. You can download Visual Web Developer from here and the ASP.NET 3.5 Extensions Preview from here.

Keep your fingers crossed for Walkthroughs + Code Samples on Dynamic Data Websites, ADO.NET Data Services, LINQ and last but not the least the ASP.NET MVC Framework.