Hibri Marzook Musings on technology and systems thinking

The biggest win of pair programming is…

the concentration and focus achieved. While pair programming, I tend to shut out e-mail, IM , ringing phones and all the other distractions.  What I have noticed is that it is much easier to get into the “zone” where code just flows. it is very easy to get more productive, and I see myself focusing on my code for about 4 to 5 hours of my day.

Martin Fowler Talk

Today, at work I was treated to a rare opportunity to attend a talk by Martin Fowler. I may or may not get the chance to hear someone who can profoundly inspire developers. with simple( sometimes obvious) nuggets of wisdom, that will make us build better software.

The talk didn’t have a specific title, but centred around the theme of software design and how we go about it. His talk mostly focused on how keeping things simple can help build better software. This concept is obvious, but many of us loose sight of it.

look at what has already been done.

Similar problems have already been solved, someone out there knows how to solve it.  This is the basis of all the design patterns that have been collated by Eric Gamma et al and Martin Fowler himself.  Patterns are nothing new, they are not the future. They are practices that have been used in successful software in the past, and we can draw on the lessons learnt during the past 30 (or more)  years of software development.

spread knowledge backward

it’s important that older, experienced developers pass on their knowledge to new or less experienced developers. He made an interesting point on how software architects at Thoughtworks pair up with less experienced developers. A good software architect is one who does not have to make any decisions. On a related subject Martin said “burn your architecture document”. If the developers have to refer back to a document, it means that they haven’t fully absorbed the architecture of the system being built, and there are gaps in their knowledge.

keep things simple, expect and prepare for change

This is what inspired me the most. Software is soft( malleable). It always changes, expect and be ready to change. Importantly be prepared to undo change. Work with what you know, and do not worry about changes that can happen. Postpone decisions till you absolutely need to make them. Organise work into incremental chunks of changes.

There is a lot more I took away from the talk. Might take a while to digest it all :). However these are concepts that are stressed in the books listed below, specially in_ _The Pragmatic Programmer.

If you haven’t read any of Martin Fowler’s books, I strongly suggest you do so immediately, along with a few other books that will inspire ( and shock you) into being a better developer.

Patterns of Enterprise Application Architecture

Refactoring: Improving the Design of Existing Code

Domain-driven Design: Tackling Complexity in the Heart of Software

The Pragmatic Programmer

Kudos to Jason for organising the talk.

COM Exception while loading a Web Application Project

VS 2008 throws a COM Exception when loading a web application project. This happens when the project was made in VS 2005 and upgraded using the Upgrade Wizard. It loads web application projects made natively without a problem. There is a work around if this happens to you.

Via http://www.codeattest.com/blogs/martin/2008/01/comexception-loading-solution.html

“In order to load the Web Application Project you must make sure that the URL that the project is using, is valid and can be resolved. This can happen pretty often since when you download a project from source control for the first time, it is highly unlikely that you will have the web site already set up.”

 

If this happens to you, the project will not load and will be grayed out in the solution explorer. Right click and edit the project, (or edit the .csproj file in notepad) look for the WebProjectProperties element. Check if the IISUrl child element points to a valid location. The server should exists, and the virtual directory should point to the same location as the web application project.

Seen on a CC Tray near you

Click image to view large version

cctray

Scaffolding with ASP.Net

Many web applications have a back end “admin” pages to manage tables in the database.  These pages exist solely to perform CRUD operations against a single table. Sometimes with a bit of validation.

It is tedious work if you have to create and write the same code  for each table and to maintain them. To make this task somewhat easier, there are solutions that look at the database structure, and generate the data access code and the asp.net pages.

The latest and greatest of them is ASP .Net Dynamic data. This uses LINQ to SQL for data access. Its quite easy to get a site up and running using this.

Mono Rail has an ActiveRecord scaffold.  This uses Castle ActiveRecord and Nhibernate to generate the scaffold. However, this doesn’t generate the database to object model mapping automatically.  Classes that inherent from an ActiveRecord base have to be created first. Fields and relationships have to be defined in code. When this is done its all a breeze. Its a good way to get to grips with MonoRail.

 

Subsonic which I’m using on a project now, has two methods of operation. It has a set of scaffold controls which you can use on any asp.net pages to get CRUD functionality, and it also has the option to generate the asp.net pages and the data classes. The data classes generated by subsonic use the active record pattern too. The code generated by subsonic can be modified if you need to do so. After the code is generated these are normal asp.net pages to which you can add validation, combine with master pages etc..

Subsonic and Asp.Net dynamic data offer the quickest way to get up and running.  Subsonic and MonoRail offer the possibility to extend the application when things get more complex. The data classes generated can be reused when the application grows beyond a simple prototype or admin section.