Monday, October 09, 2006

Reflections on Web Directions

I have to be the slowest blogger in the IT community. Over a week ago I attended the Web Directions conference. The conference was really good, and has inspired me in a few areas. Many other bloggers have had their say on the conference, but I may as well have mine, just for the sake of redundancy.

One of the common themes from both the Accessibility speakers (Gian Sampson-Wild and Derek Featherstone) and the User Experience speaker (Kelly Goto) was user testing, and not just asking the user what they think. Kelly Goto's quote was 'We listen to what the users "didn't say" and observed what they did'. I have also been challenged in the area of accessibility, I think the quote for me came from Derek Featherstone, and that is "The web is Accessible by default, we make it in-accessible". It has inspired me to go have a look at the way I develop, and the bad habits I've gotten into. The truth of the matter is that it is not really that much effort to get into good habbits that make web sites more accessible.

I really liked Jeremy Keith's AJAX sessions. The first session started out a little basic, but become more interesting in the last half. In the second session Jeremy discussed a technique he called "Hijax" which is aimed at ensuring accessibility, and support for down level browsers. I am looking forward to seeing how well I can apply his techniques using ATLAS. While on the topic of libraries, Jeremy did make one statement that I'm not sure I can agree with. He said that he didn't believe in using thrid party libraries for doing AJAX, firstly becasue AJAX wasn't that complicated and secondly because if something goes wrong in the library as a developer you'll need to be able to fix it. I almost agree with his first statement, but even still, I am a big fan in NOT re-inventing the wheel. If there's a library that has a great ranking control for example, and they've coded it so that it works across all browsers in your supported browser matrix, then there is a lot of testing and coding that you can potentially avoid. There are always bugs in any software, and AJAX APIs are no exception, the skill of a good developer is to be able to use an API in such a way that they can workaround any bugs in the underlying API, I've lost count how many times I've had to do this myself. Also, as a Winforms developer, I am extremely greatful that I do not have to write Win32 anymore, and I'm sure those of you who have written Win32 would agree with me. Having said that, his "hijax" mechanism of progressive enhancement is really cool, and my current goal is to go through all the ATLAS controls (the API I'm currently using) and see how I can apply this technique to them.

I went along to John Allsops talk on microformats to hopefully pickup anything I'd missed from the first time I heard it, and was inspired all over again.

One minor thing I think the organisors can improve on is something I saw at the Tech-ed conference, the "re-charge desks". The tech-ed organisors had desks with a series of power boards that people could plug their lap tops into between sessions. This would have been really good for me as my laptop is now a year and a half old, and my battery is showing its age, it wasn't even lasting 2 hours.

Worth mentioning:

  • Kelly Goto made reference to an example of an interesting User Experience project called Datelens. It is a callendaring visualisation which plugs into outlook (nothing to do with the web at all). I downloaded it and it's quite interesting, definately worth a look. Also it is written in .Net 1.1, which must have been quite an acheivement, and I think with WPF just around the corner, there will be a lot more of these types of user experience applications about.
  • The inaugural McFarlane proze for Excellence in standards based web design was awarded to http://www.museum.vic.gov.au/caughtandcoloured/. This site is really worth checking out. It is especially interesting to me because it is written in ASP.Net demonstrating that it is possible to write high quality standards compliant accessible web sites using ASP.Net.
  • - The last speaker of the conference was Mark Pesce (inventor of VRML, explained some of his concepts of social software, and described a project he worked on that attempted to aggregate your social behavior patterns and create social network models simply by using the ability of a blue tooth enabled phone. I thought there’d be some people at readify quite interested in this sort of stuff. http://relationalspace.org/

tags: wd06

Sunday, September 17, 2006

ATLAS Data Applications and Down-level support

I must confess that aslthough I am excited by the whole AJAX phenonenon, and the rich client experience that it provides for the majority of desktop browsers, I sometimes feel concerned about those that for whatever reason aren't able to experience the full beauty of a javascript enabled client. There are two main groups of people that are missing out

  1. Users with certain accessibility needs (often browsers and tools designed for people with disabilities have to run without the javascript support we usually take for granted) and
  2. PDA users (This is an increasing market, and to date only 1 browser has implemented any kind of javascript engine for devices, .

So I am always looking for ways to enhance these users experience.

My AJAX toolkit of choice (more through accident than intent) is ATLAS (Microsofts library). ATLAS contains a data enabled control called a ListView which is quite powerful. It works on a client side JavaScript based object model and the best way to get to know it is to read the data section of the ATAS documentation.

 

So the idea is, get a funky ATLAS based website working, and then attempt to create a version of that website as quickly as possible that can be used by people who can't (or won't) use javascript (similar to what google does with gmail).

 

I decided to make the sample as simple as possible without loosing anything along the way. I decided to create a Shopping List, that simply contains a quantity (double) and an item (string).

The bueaty of the ListView in ATLAS is that it can use the System.Component model similar to other databinding in ASP.Net 2.0. So the first step in creating a webservice that derives from Microsoft.Web.DataService (refer to the ATLAS documentation for more details).  I then create my ListView templates and hook it all up using XML-Script, and pretty it upwith any CSS I may care to add. The result can be seen here (Please forgive me I'm not a graphic artist). Once this is done, I needed to create a Non-ATLAS version of the same page. As my webservice already uses the System.Component model, it was extremely easly to add a GridView control, select an Object DataSource and wire it up, and away it goes. All in all it took me abou 10 minutes to create the NON-Atlas page. It would have taken me another 2 minutes to enable things like edit/delete, but for the moment I wanted to keep it the same as the ATLAS version, this may be the subject of a future post. The only significant difference between the two pages is the presence of a select link on the NON-ATLAS enabled version whereas the ATLAS version manages the select operation simply by handling the mouse click.

 

Once you have these two pages it is simply a matter of choosing your favourite way to direct users with different broswser capabilities to the correct site.

Sunday, August 20, 2006

ajax gotcha for new players

Being fairly new to the "Brave New World" of ajax, this week I fell into a fairly common trap that gets new players. I studiously looked around for the best practice implementation of making an http request using javascript and came up with the following javascript function which allows the user to make the http request, specify a callback function, and even goes the extra mile of implimenting timeouts (I guess the only other thing I really should do is implement an OnErrorCallback).


function MakeRequest(url, timeout,
onCompleteCallback, onTimeoutCallback)
{
var completeCallback = onCompleteCallback;
var timeoutCallback = onTimeoutCallback;

var xmlHttp=createXMLHttpRequest();

if (xmlHttp)
{
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState == 4)
{
window.clearTimeout(timeoutId);
if (xmlHttp.status == 200 ||
xmlHttp.status == 304)
{
completeCallback(
xmlHttp.responseText);
}
}
};

xmlHttp.open("GET",url,true);

var timeoutId =
window.setTimeout(function()
{
if (callInProgress(xmlHttp))
{
xmlHttp.abort();
timeoutCallback('timeout');
}
} , timeout);

xmlHttp.send(null);
}
}

function callInProgress(xmlHttp)
{
switch ( xmlHttp.readyState )
{
case 1, 2, 3:
return true;
break;

// Case 4 and 0
default:
return false;
break;
}
}


function createXMLHttpRequest() {
if(window.XMLHttpRequest) {
try {
xmlHttpRequest = new XMLHttpRequest();
} catch(e) { return null; }
} else if(window.ActiveXObject) {
try {
xmlHttpRequest =
new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlHttpRequest =
new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { return null; }
}
} else return null;
return xmlHttpRequest;
}


I then wanted to call a .Net HttpHandler, and lets just say for arguments sake that the htp handler looks like this


public class Handler : IHttpHandler
{

public void ProcessRequest (HttpContext context)
{
System.Threading.Thread.Sleep(6000);
context.Response.ContentType = "text/plain";
context.Response.Write(Guid.NewGuid().ToString());
}

public bool IsReusable
{
get
{
return false;
}
}
}


so the call from javascript would simply look something like this



MakeRequest(
'Handler.ashx?cookie=abcd&another=xyz',
20000, onRequestComplete,
onRequestTimeout);

function onRequestTimeout(response)
{
alert('timeout');
}

function onRequestComplete(response)
{
alert(response);
}



The problem as I found out through good old wikipedia relates to the internet explorers caching of the "GET" http command as described in this article on HMLHttpRequest.
As discussed in the article, there are a number of ways around this, switch to using POST or ensure that you switch the caching off in the http headers. I chose the former.

Sunday, August 13, 2006

Automatic updates + Automatic Reboots

Is it only me or does anyone else find this really frustrating.

message

I got this in the middle of reading my email this morning, and I really didn't want to reboot in 5 minutes. I would have quite hapoily rebooted in half an hour or so when I'd finished what I was doing. The fact that the restart later button was there but disabled just added to the insult.

I think from a layer 8 perspective, Microsoft need to be really careful when forcing reboots. If this happens too frequently, it may be frustrating enough that people actually turn Automatic Updates off, making their systems progressively less secure and vulnerable.

Saturday, August 12, 2006

Web Directions

On thursday night I went along to a Web Directions preview night where 2 of the speakers from the upcomming Web Directions conference Ben Barren from gnoos and John Allsop from westciv were giving previews of their presentatoins at the conference. It was a good night, I particularly enjoyed Johns talk on . This is a topic that I have been interested in for a while now, and may have more to say about it later.

Unlike other events I attend, where I know a fair few people, this event I only found one person I'd met before was Nigel Watson, an Architect Advisor from Microsoft. So it was good to make new contacts and expand my circle beyond the sphere of the Melbourne .Net developer and SQL Server sphere. I got to meet Cameron Adams whose book "The Javascript Anthology" I am currently half way through, and also met the people from westciv who write the best damn web standards online training courses in existance.

When I first heard about the web directions conference, I thought that as much as I'd love to go along, I probably wouldn't be able to attend given that I was already attending Tech Ed at the end of August, and I'd be pushing it a little if I asked my employer to pay for another conference and let me have the time off so close after Tech Ed. As the saying goes, "the best layed plans of mice and men gang aft aglay", there was a lucky door prize drawn at the end of the night, which was a free ticket to attend the Web Directions conference. Guess who won........ So now all I have to do is convince my employer to let me have a couple of days off to attend..... that shouldn't be too hard.

Thursday, July 13, 2006

Stepping through ATLAS Javascript files

I'm trying to debug an application I'm writing using ATLAS, and I'm wnating to know why my attempts to make browser client magic happen are resulting in java script errors. Fortunately Visual Studio provides a level of debugging for java script files which means that if you're in debug mode when a java script error occurs, you'll automatically be taken to the point in the code where the problem occured and given some useful things like a stack trace and a variable watch window. You can also set break points in your own code, however, if you have registered the scriptsw using an Atlas Script manager as is advised when writing ASP.Net applications


<atlas:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>


you will not be able step into any of the ATLAS libraries you happen to be using as the debugger complains that the source files are not available. This is because of the way the ATLAS scrip manager embeds the java script.

today I found myself thinking that it would be handy to be able to step into these files to find out what's going on prior to the error.

To solve the problem

  1. Copy the necessary java script files from the install location into your project and mark them as "Embedded Resource". In my case Atlas.js and AtlasUIDragDrop.js

  2. Comment out or remove the Atlas Script Manager component

  3. Add the script files as you would add any normal java script file (ie with the <script> tag)



Once you have done this you should be able to step into the ATLAS java script files to your hearts content, but be warned you might find it a little scarey in there.

The only problem with this is that it won't work for Server Side Atlas controls, such as UpdatePanel or Extender controls, but if you're not using them, or if you can comment them out while you debug stuff, then you're set.

Thursday, July 06, 2006

Google Maps and sustainable transport

I have found a great site that is a mashup of google maps. http://www.bikely.com. The idea is you can search the user entered database for the best way to get between various points by bike. The website also allows you to sign in and create your own bike route so you can share your favourite rides with others. You can even put comments at each point that appear as pop-ups on the map. I'll have to start riding my bike more so that I can contribute.

Tuesday, June 27, 2006

Browser Version hell

Those familiar with the concept of DLL hell and have experienced it first hand often point to web based applications as the savior for such deployment issues, and to an extent they're correct. However, as the push for a richer client experience from web applications grows, and as the technologies that enable it mature, DLL hell is being replaced by Browser version hell. We are all aware that Internet Explorer and the Mozilla based browsers (firefox) have their own peculiarities, but even beyond that are the versions of these browsers. In fact, IE 6 has been particularly slammed for some of its, shall we say "non-standard" behaviour. As a result of this I have been a big fan of firefox that is considerably more standards compliant. This has lead to web designers targeting firefox first, and then tweaking sites as needed for other browsers.

For the past 6 months or so I have been neglecting firefox a little in order to try out the all new IE 7 in its various beta forms. IE 7 is supposed to be far more standards compliant, amongst adding other features users of firefox and other browsers take for granted. So as a result, I haven't updated firefox for a while, and using firefox version 1.0.7 I was testing out a new Atlas based control called the collapsible panel control, and the bad news is, It doesn't work. The area that should display when the panel is expanded is displayed completely blank. Upgrading to version 1.5.04 fixes the problem completely. Now admittedly the Atlas Control Toolkit is very much in a pre-release state, but it does raise a very pertinent question.

Where should web developers draw the line and say I'm not going to support versions of browser X before version Y, and how should web sites indicate that a user should upgrade their browser? Also, how many different versions of browser X should we be realistically expected to test under? This I believe is different to the idea of degrading nicely (ie what should happen if a browser doesn't support Java Script or only supports a limited subset of Java Script). All I can say is that I hope the team at Microsoft fix the problem with the control for firefox Version 1.0.7.

Monday, June 26, 2006

Web Application Projects and SQL Express Data Sources

I have been struggling today with some SQL Express related data issues. I have been trying to use a combination of Web Application Projects and ATLAS, as I am convinced that Microsoft have completely stuffed up with their "Web Site" style projects, I really don't want to use them. So to do this you simply create a new Web Application Project, and then copy all the necessary settings from the sample ATLAS web.config file into your own web.config file, and ALL is fine... that is until you want to do something with SQL Express. Regardless of ATLAS, the standard approach is to add a new item to the project and select a SQL Database. This uses SQL Express in a mode called "User Instances". This is designed to allow you to treat the databases primary file (mydatabase.mdf) as though it is just that, a file (impressive if you know what's really going on under the hood and understand how SQL Server normally works), and this is how all the Microsoft demos go, except that they use Web Sites instead of Web Application Projects. The theory is then to add tables, and create a DataSet off these tables. So I thought it would just be a simple matter of creating a Web Application Project, and then following exactly the same logic. WRONG!!!!!!

My first efforts yielded the following error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0122: MyWebApplicationProject.Properties.Settings' is inaccessible due to its protection level

This is because the default way of storing the connection string is to use the Properties folder and create an entry in the Setteings.Settings file. In this case there is a class called MyWebApplication.Properties.Settings. This has a protection level of "internal" meaning that only code from within the same assembly can refer to it. The code attempting to access it is NOT in the same assembly so it fails compilation.... DOH.

Next step was to attempt to rework it so that it got the connection string from the web.config file. After correcting all the places where I found a reference to the connection string, I received the following error.

Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Projects\AtlasApp\AtlasApp\App_Data\App_Data\Tasks.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Better, at least this time it's compiling. After spending entirely too much time attempting to figure out why SQL Server User Instances were failing, I eventually re-read the error message, and noticed the path it was attempting to access. C:\Projects\AtlasApp\AtlasApp\App_Data\App_Data\Tasks.mdf

Notice the two App_Data directories. Yep, so simply exclude the App_Data part of the path in the connection string and away it goes, everything now works.

The reason I write this article is because I found very little documentation on the problems. Problems which I thought would be occurring quite frequently if people are using Web Application Projects, but alas the only mentions I have found are a recognition by Microsoft that there are problems, and a vague promises of a white paper on the issue from Microsoft.

In conclusion, I've had quite a frustrating day, and I think Microsoft still have some work to do on Web Application Projects.

Friday, May 26, 2006

using a custom database for persisted SQL Server ASP.Net session state

I am in the process of upgrading a major project from ASP.Net 1.1 to ASP.Net 2.0, and my ideal is to have 2 versions of the web application able to be run so that I can compare what's going on in the .Net 2.0 version to what should go on according to the .Net 1.1 version. This doesn't seem too difficult, just use a different web folder right? Well, this would be the case except that we're using SQL Server persisted session state and although they use a different schema between .Net 1.1 and .Net 2.0, the default database name is the same "ASPState". After a bit of fiddling around I eventually solved the problem.

Step 1 run the following command line from the appropriate .Net 2.0 directory replacing ASPState_2_0 with the database name you wish to use

aspnet_regsql -S localhost -E -ssa
dd -sstype c -d ASPState_2_0


This creates the session state database with the appropriate schema in the specified database name instead of the default.

Step 2 modify the following line in the web.config file accordingly

<sessionState mode="SQLServer" allowCustomSqlDatabase="true" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=localhost;Initial Catalog=ASPState_2_0;Trusted_Connection=Yes;" cookieless="false" timeout="15" />

Step 3 Manually give the ASPNet user (or whatever user you are running the ASP.Net web application as the appropriate priviledges on the database tables in the newly created session state databse.

MEDC 2006

Just got back from the MEDC 2006 conference where I was lucky enough to recieve an I-Mate SP5 simply for attending.
sp5

The sessions were all very interesting, my personal favourite was probably the session on performance in the compact framework.

The other interesting thing I learnt is that people are actually reading my blog. Well, if that's the case I might have to buck up my ideas and actually put some half decent content on.

Wednesday, May 24, 2006

A new and exciting project

This week I started a new and very exciting project. I can't really give away all the details as the project is still in the planning phase, but what I can say is that it will be a Web 2.0 project. Now I know Web 2.0 can sound like a bit of a buzz word and as such looses meaning, but I think this article by O'Reily explains Web 2.0 in a way that cuts through most of the marketing hype.

The Web 2.0 concepts that we are thinking of using in this project involve the idea of Mash Up's of a few different services, the idea of collaboration and collective intelligence, technologies such as ATLAS (AJAX for ASP.Net) and the concept of the quick release cycle.

It is interesting that I have ended up on this project. I must be the least experienced ASP.Net developer at Readify, and the last time I did anything commercially for the WEB (almost 2 years ago now), was firmly rooted in Web 1.0 mindset. Since then I have been firmly stuck on the Rich Client side of the divide writing Pocket PC and Desktop style applications. The team lead on this project has suggested that this is probably a good thing as we can take my experience designing and working with rich UI's and not be limited in my thinking of what is capable on the web. We are all getting really excited about the potential of this project, and I will give more details as the project progresses.

Monday, May 08, 2006

To Train or Be Trained... That is the question

Over the past 15 months I have been consulting to QSR and it has been a fantastic experience. The only issue has been that since I've been there I have worked exclusively on a winforms .Net 2.0 application. This has meant that my ASP.Net 2.0 skills were fairly rudamentry, and weren't improving beyond the tiny bit of time I've been able to allocate to professional development on the bus on the way to work.
So I decided to do the Readify Professional .Net which has been recently re-vamped for .Net 2.0. So I rang Chris Hewitt who was instructing the course to tell him of my intention. Chris's paraphrased reply was something like ... "You've been using .Net 2.0 for over a year now, you know more about .Net 2.0 than I do, you can teach some of the course".

So this is how I ended up teaching three modules of a course I was originally intending to sit. The 3 modules I taught were Generics (one of my favourite .Net 2.0 features), Click Once (on Chris's suggestion) and refactoring. It is my goal to to be trained up to a point where I can teach the course myself, and it was good sitting under Chris who has extensive teaching experience. I have always enjoyed teaching ever since I supported myself through uni by tutoring high school maths and physics, and I know it is one of the best ways to ensure your own grounding of the material. The thing that scares me the most is questions. I know I shouldn't be scared, we aren't expected to know everything, and in the rare cases when Chris didn't know the answers, it proved to be a real journey of discovery for allpf us as we attempted to find the answers to these questions.

Tuesday, May 02, 2006

Click Once Deployment Gotcha

In attempting to prepare for a module I am teaching tomorrow, I am putting Click Once through its paces, and I'm finding there are some strange issues. I have been struggling with an unusual error for half the night.

I am Publishing my files to a local site, then openning up internet explorer, navigating to the site and then attempting to Install the application. The application contains a 4 files that require downloading, and it uses SQL Server Express. The Install starts out fine, it then decides it needs to momentarily open a browser window. Now my default browser is Fire Fox, and it decides to open this. At this point firefox decides to prompt me for a username and password. Why I don't know, but seconds after typing in my credentials, it brings up an error saying that it cannot download the application as there are missing files. The install fails.

I eventually figured out that if I change my default browser back to be internet explorer, the problem goes away. Hope this helps someone.

Monday, April 24, 2006

SQL Server Express with Advanced Services

As an avid user of SQL Server Express, it would be remiss of me not to herald the release of the much anticipated SQL Server Express Edition with Advanced Services with a blog post. This adds SQL Server Reporting Services and SQL Server Full text search as well as its very own version of management studio into the mix which now gives it a distinct advantage over its predecessor MSDE.

IMHO the only thing that is now missing from SQL Express is SSIS. I think that adding SSIS to SQL Express would allow people to enter more data quicker and would therefore come up against the size and performance related restrictions of SQL Server Express, and would cause people to upgrade to other SKU’s of SQL Server sooner.

Tuesday, April 11, 2006

SQL Server 2005 installation problems on various CPU's

As I have become the unlikely SQL Server 2005 "expert" at the company I am currently consulting to, I have been investigating a wide number of installation issue with SQL Server Express. There are a few main categories these problems fall into.

1. Installation of beta versions of SQL Server 2005 or the .Net Framework 2.0 (solution uninstall all beta versions of SQL Server 2005 or .Net 2.0, and if you've installed beta versions of Visual Studio 2005, see http://msdn.microsoft.com/vstudio/support/uninstall/default.aspx)
2. The CPU is NOT fully Pentium III compatible
3. Various issues ranging from disk space to memory to OS service pack level etc...

In this post I want to deal with problem #2, The CPU compatibility problem.
There seem to be a number of CPU's that claim some kind of Pentium III compatibility, and as the hardware and software requirements for SQL Server 2005 state, Pentium III is the minimum hardware requirement.

However, for whatever reason, the SQL Server installer does not check CPU compatibility too thoroughly as we have seen a in a number of cases that the installer will issue a Hardware warning, but happily allow the user to continue to attempt to install SQL Server 2005 but will in the very final stages of the install refuse to start the SQL Server service. I'm not sure of all of the reasons why this error potentially occurs, but I know 1 definite problem is that SQL Server insists on the cache prefethching instructions of the Pentium III CPU. This is missing in a fair amount of CPU's that claim compatibility with Pentium III's. I have asked the guys at Microsoft about the minimum hardware warning, and they confess it is a problem, and are reviewing whether they are going to be more specific in the future, however, I think there needs to be some kind of list of all the different CPU's that one might reasonably expect to be able to install SQL Server 2005 on, but don't seem to have the ability to. So here it is, or at least the results of my research, if anyone else has seen similar problems, please leave a comment with the CPU specs and any links to discussions about the problem on various forums.

Via Eden - http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=304355&SiteID=1

500 MHz AMD Family 5, Model 8, Stepping 12 processor (AMD-K6-2) - http://www.sqljunkies.com/Forums/ShowPost.aspx?PostID=167¬ification_id=421614&message_id=421614

VIA Ezra 800Mhz processor - http://www.sqljunkies.com/Forums/ShowPost.aspx?PostID=167¬ification_id=421614&message_id=421614

Microsoft Virtual PC For Mac OS 7.0.2 (This emulates a Pentium II) http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.mac.virtualpc&tid=90715b2e-77ba-4f8a-a189-daee29467ff0&cat=en_US_595a5881-be4a-4db4-97b0-5f3a78602e23&lang=en&cr=US&sloc=en-us&m=1&p=1

Transmeta - http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=17395&SiteID=1 and http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=cee0915a-6039-4ca6-aa0c-1b76285d4ac3

Saturday, March 25, 2006

Teddy Bear code reviews

I have been a big advocate of peer code reviews for some time now (see my previous post on peer code reviews), and I feel very lucky to have been a consultant at a company for the past year and a bit that firmly believe in peer code reviews. As my time comes close to winding up at this company, I am faced with the prospect of going to consult for a company that does not have the same attitude to peer code reviews, and I've been wondering what my approach should be.

My first thought is to attempt to convince the managers at whatever company I end up at that peer reviews are a good idea, and explain the development to the overall development life cycle, and show them the graphs that explain the cost of fixing bugs at various points throughout the software development life cycle, this in my opinion should be enough to convince any decent manager that an extra 2 hours in development is better than an the 20 hours of test/dev/management time if a bug makes it into system test, or worse if it makes it into the wild and is reported by a user. However, being experienced with the way management works, and knowing that not all managers listen to common sense or think that developers shouldn't write bugs in the first place, I've been trying to think how I will attempt to maintain my code quality in such an environment.

I'm not sure how well known the concept of teddy-bearing has become, but the urban myth starts with a development team that had a team lead who was as a developer pretty useless. The developers however, found he was great for one thing. If you were stuck on a programming problem, you could call him over and ask him to have a look. Because he was so useless, the developers would have to step him through the bits of the code that were causing the problem. In the process of explaining the problem at a level that the team lead could understand, the developer would quite often see his/her mistake and be able to fix it right there in front of the team lead which made the team lead feel as though he was immensely important. When this team lead eventually moved on to bigger better and greater things, the team was at a loss to know how they would fix these hard to find bugs, until one day, one of the developers who was stumped on a problem picked up a teddy bear that was lying around the office and sat it on his desk started explaining the problem to the teddy bear. They found that the teddy bear was every bit as effective as the team lead, and had the added advantage of having better people skills. The teddy bear become an office legend and was invited to all the office parties where legend has it he told far better jokes than the old team lead.

From this the concept of teddy-bearing was born, and is used whenever you encounter the phenomenon of explaining your code to someone in order to find a problem, and find the problem yourself with no real constructive input from the person you asked to help.

So what does that have to do with code reviews? Well, I'm a big fan of the whole subversive style of process improvement. If management won't buy source control, install subversion and maintain your own repository, if the team doesn't believe in unit testing download nunit and write your own, if there is no nightly build process, download nant and do it yourself. So if there are no code reviews, buy yourself a teddy bear, give it a name, and sit it on your desk. Fellow colleagues will probably think you are a little unusual, but you're a geek, people generally think you're more than a little unusual anyway.

When you get to a stage where you are completing a chunk of work, sit the teddy-bear beside you and talk it through your code. A lot of the psychology of a code review will be there, and in reality you will have one of the toughest reviewers you can possibly have..... Yourself.

Wednesday, March 01, 2006

QSR Releases NVivo7

The company I have been consulting to for the past year and a bit (QSR) have today released the product we have been working on, their flagship product NVivo 7.

I'd also like to add that it was released on time, and without stressing out the entire team for months leading up to the release. Just goes to show what good project management and appropriate resource allocation can do.

Friday, February 24, 2006

Testing for developers from the Braider Tester

A blog that I read from time to time has some great resources for testers. The blog is called The Braidy Tester. You may ask why I a developer is reading such a blog, well, I am interested in the entire SDLC, and always like to know what's going on when I throw the next build over the fence to the testers, and also, I don't think it hurts developers to be aware of how to be better testers themselves for testing their own code changes. A fact which The Braidy tester appears to agree with given a recent article on Testing For Developers

Thursday, January 26, 2006

The spin detection machine

Interesting concept, a piece of software that detects the amount of spin in a speech. The model is based on analysing the frequency of various kinds of words in a speech and professes to be able to detect levels of deception and insincerity in English text. I must confess, I'm more than a little skeptical. I just think there are so many variables, ie the speakers/speech writers proficiency with the English language, different styles of speech writing, different topics, different audience. All of these things change the way we use language and shape what we say.

I guess the ultimate test will come when they decide to commercialise the software and produce a website dedicated to selling it..... and then run the software over the site. I guess this could be seen as an extension of the halting problem.

Friday, January 20, 2006

Arguments for continuous integration

The company I’m currently consulting to are pretty good when it comes to their internal development systems, although one of the main areas I can see for improvement is in continuous integration. They currently have a full build process is manually initiated, and works pretty well. I really think they need to go to the next step, that of continuous integration.

A couple of days ago I was checking in some very subtle but serious changes to the way we accessed SQL Server (we switched to use User Instances so that we could run as an LUA user). We were all a bit nervous about this change because although it was a relatively minor change, it was a significant unknown, in fact I was the only one who had any idea of how user instances worked. So as part of the code review, the reviewer asked me to run all of the unit tests just to be sure we hadn’t inadvertently broken anything, and sure enough a whole heap of them just curled up and died a horrible death. Being the insecure person that I am I immediately rushed to the conclusion that it was my changes and started questioning my own understanding of user instances. When running the application, I was able to reproduce the error under certain conditions on my machine, but no-one else was able to reproduce the error on their machine. The next day I spent the best part of the morning looking at the problem and eventually discovered that firstly the reason I could reproduce it on my machine was because I was using an obscure (non-default) option in the application, and secondly that the bug occurred with or without my changes from the night before. Armed with this information I then went to the team lead who then spent the next half of the day going back through labels in our source control attempting to find the release that this bug first occurred in. He eventually found it to be due to a check-in about 4 or 5 days prior. This indicated 2 things, firstly people had not been running even the effected unit tests for their check-ins, and secondly if we had continuous integration, and unit tests were run automatically at the point of check-in, we would not have wasted a day and a half of development time tracking down the origin of the bug. I told the development manager that this incident re-affirmed my faith as a unit-test evangelist.

SQL Sever & file permissions

In the course of trying to track down a problem running the application i'm involved in developing at the moment, I stumbled across the following article describing what SQL Server does with file permissions when it attaches to a database file.
The article states that for security reasons it changes the file permissions so that if a file has been placed in an insecure folder, then it attempts to protect it from someone without the privileges from moving or deleting it.
It seems to me to be a little mis-guided. Firstly, I would assume that it's the responsibility of the DBA, to place all database files in an appropriate place with appropriate permissions to the various users that require access. The secure by default paradigm is all well & good, but there is no way to turn this behavior off. Secondly, it doesn't really achieve anything. If a DBA has been dumb enough to place a vitally important database file in a folder that anyone has full control over, then if SQL Server is not attached, the user can easily cut & paste the folder wherever they want which will have the same effect as moving the original file.

Maybe i'm not seeing something here, I can't really see the need for this.

Saturday, January 14, 2006

New toy

Well, I'm now the proud new owner of an O2 XDA Atom.

I have been hanging out since my XDA II started playing up, but I wanted to hold out for a Windows Mobile 2005 device.

So far, mostly I have been impressed. I love the ability to switch between lanscape and portrait screen modes, I love the in-built wi-fi, I adore the tiny size (in comparisan to the XDAII) and it seems there have been some improvements to the predictive text which makes it easier to enter data into, but there are a few things I haven't been so impressed with.

Maybe it's just buggy early release software, but I have had three occasions so far where the phone has stopped responding to the on/off button. I have also not had any luck what so ever with the devices alarm. I have had almost a week now where it has not woken me up even though I have set it. My partner says I should read the manual, but I'm sorry, it goes against every rule of usability and good design if I have to read a manual in order to set the freakin alarm clock. I'm happy to read the manual for other more complex tasks, but not to set the alarm clock.

Anyway, I will persevere and hope a firmware update is close. I'm also hoping to get back into some Pocket PC Development, I'm really keen to put sql mobile and the new version of the .Net Compact Framework through their paces.

Tuesday, December 06, 2005

Answer to question posed at VSLive

The thing I was most nervous about at my VSLive presentation was question time. I had an ingenious plan to avoid question time... I had timed my presentation, and it went for just over 1 hour, but in the words of a famous poet... "The best layed plans of Mice, Men (and Geeks) gang aft aglay". People from the audience stopped me mid-way through to ask questions. Most of the questions I was able to answer, but there was one that I said "I think the answer is yes, but I'll get back to you". The question was... "Does SQL Express support bulk copy?", and after some testing the answer is "Yes". As mentioned in my presentation (slides available here) SQL Express does not support SSIS (The replacement for DTS), however after testing, the bcp utility works fine. The following script can be used to verify that both import and export work fine.


use tempdb

-- Create a test table
create table BulkTest
(TestKey INT NOT NULL,
TestData NVARCHAR(50) NULL,
CONSTRAINT BulkTest_PK_Constraint PRIMARY KEY (TestKey ASC)
)

-- Add some test data
INSERT INTO BulkTest
(TestKey, TestData)
VALUES
(1, 'This is just some test data')

INSERT INTO BulkTest
(TestKey, TestData)
VALUES
(2, 'This is some more test data')

INSERT INTO BulkTest
(TestKey, TestData)
VALUES
(3, 'It is important to have test data')

-- perform bulk Export using bcp command line utility
-- bcp tempdb.dbo.BulkTest out BulkTest.dat -T -c -S ServerName\SQLExpress

delete from BulkTest

-- perform bulk Import using bcp command line utility
-- bcp tempdb.dbo.BulkTest in BulkTest.dat -T -c -S ServerName\SQLExpress

select * from BulkTest

Saturday, December 03, 2005

VSLive Seminar post mortem

Well, my VSLive presentation was on Wednesday, and I personally was quite pleased with how it all went. I must confess, I was a little nervous, but I didn't let my nerves get the better of me. I had really positive feedback from people after the seminar, and even one request for the source code for my Photo Album Demo... enjoy! The demo sort of loses a bit by distributing it in this form, as it was more about the process of building it and displaying the Visual Studio integration features of SQL Server Express. There are only 5 lines of user written code in the project, and they are all to do with implementing Drag-Drop on the picture box so that you can add the photos to the database, the rest is all IDE generated.

There was one point that given the discussions after the seminar, I feel I should clarify. I went into a bit of detail describing the SQL Express only feature "User Instances" or RANU (Run As a Normal User). I do think it is an interesting feature and I can see some real potential for it, however, from the discussions after the seminar, it appears that I didn’t stress enough, that User Instances are optional (in the connection string "User Instance = true"). You don't need to use it, in fact, I would suggest that in the majority of usage scenarios, you will use SQL Server Express in your traditional Database server scenarios where you have a dedicated server machine that a DBA logs on to allowing her to perform maintenance tasks like Attaching databases etc... multiple clients would then log onto the database from their own machines with only the privileges they require to perform the tasks they need to. User Instances are only really required when you want to deploy an application in a single user type scenario, and you want to deploy the database file along with the executables and have the user (who by best practice in security, should NOT be an administrator on their own machine) attach dynamically to the database. I hope this clears things up.

For a really good, in depth article on User Instances, see Roger Wolter's msdn article on SQL Express User Instances.

By the way if any of the people in the seminar find my blog, please feel free to leave any feedback on my performance, I would like to know how to improve my presenting.

Monday, November 07, 2005

VS2005 SQL Server 2005 RC/RTM Gotcha with MARS

For those who are familiar with MARS (Multiple Active Result Sets) and have been excitedly using them with versions of visual studio 2005 prior to the the june CTP, you may be interested to know that there has been a change in the default behaviour.

MARS is OFF by default, and any code written to use it as in this code project article will cause an exception if you don't explicitly add the following to your connection string "MultipleActiveResultSets=true".

The exception you will receive is "There is already an open DataReader associated with this Connection which must be closed first".

Another resource of interest is "Getting the MARS Sample working in the june CTP".

Saturday, November 05, 2005

Blogging on Blogging

I don't usually blog about blogging, I find it a little too self referential for my liking, but last weekend I was talking to a friend about blogs and he told me he didn't particularly like the idea. His explanation of why he didn't see blogs as a valuable social construct went along the lines that on one side of the spectrum you had articles in journals which had high peer review, but were extremely narrow in scope. Blogs were at the complete opposite end of the spectrum, extremely wide in scope, but absolutely no peer review.

This got me thinking, and caused me to re-read the article that got me into blogging in the first place. I find it strange that whenever I mention Joi Ito, or his paper "Emergent Democracy" even to active bloggers, I get blank looks. I think it's a must read for any serious blogger. In the paper Joi Ito argues for the emergent nature of blogging and related social technologies. By emergent it is taken to mean the "self organising ability of complex systems". In refutation to my friends objection to blogs, I'd like to quote directly from the paper.

"Noise in the system is suppressed, and signal amplified. Peers read the operational chatter at Mayfield's creative network layer. At the social network layer, bloggers scan the weblogs of their 150 acquaintances and pass the information they deem significant up to the political networks. The political networks have a variety of local maxima which represent yet another layer. Because of the six degrees phenomenon, it requires very few links before a globally significant item has made it to the top of the power curve. This allows a great deal of specialization and diversity to exist at the creative layer without causing disruptive noise at the political layer."

I concede that any individual blog article by any individual blogger in and of itself has not been peer reviewed, and this is the way it should be. However the blogsphere by its very nature will self organise in such a way that it will give the effect of peer review / critique. I don't think we have reached utopia yet (my entry in this years "understatement of the year competition"), and I believe that there is still a way to go, still new technologies that are required, different online social structures to be explored, but when I originally read "Emergent Democracy" I was captured by the vision.

Friday, October 07, 2005

Speaking at VS Live

Well, this one hit me out of the blue. I have been asked to speak at the Sydney VS Live conference on SQL Server Express.

My fellow colleague Greg Low dobbed me in for this one, he made the assumption that because I've been working on a commercial project with SQL Server Express since January of this year, I might actually know something about it.

It's all very exciting, but I'm a bit nervous about it all, I haven't done any public speaking for quite some time now. I have a few ideas on what I want to talk about, but I'd love some feedback as to what other people want to hear about SQL Server Express.

DB Performance tip

Normally when I think of DB Performance, I usually concerntrate on indexes, query structure, etc... all of which are quite important, but I have started listening to an msdn web cast series called "A Primer to Proper Sql Server Development" by Kimberly Trip, and in the very first episode was able to find the answer to a performance issue that had been puzzling me and the developers I'm currently working with for some months now.

The problem was that our application that is using SQL Express was having some serious performance issues. It was slow to start up, it took ages to save to the database the first few times, but then things seem to pick up a little, but not quite as much as would be ideal. Any one want to guess what the problem was????? I know all you SQL Server guru's out there have it already, but for the benefit of those who don't.... pre-allocating the size of the log file fixed the problem quite nicely.

We were already pre-allocating the size of our primary datafile to 4MB, so when we used the CREATE DATABASE ... FOR ATATCH statement, the logfile would be created by default at 25% the size of the primary datafile.... 500KB. The application is very database intensive, and filled up the log file very very quickly, and by default, the logfile would auto grow by 10% of it's original size... which would fill up very quickly again, and then auto grow by another 10% etc.... Of course this growing of the log file is quite costly, and we found that by setting the log file to be 4MB by default, with a 4MB file growth, we were able to achieve quite a significant improvement. We cut the initial loading by half, and the first few saves are now instantaneous.

If your working with SQL Server, then I'd highly recommend the web case series, there are lots of other useful tips and hints.

Tuesday, September 13, 2005

Pointless rant against the full sale of Telstra

As Telstras last few remaining shares are sold off at the hands of a party that really should be there to protect rural Australia from the whims of narrow minded economic rationalism, I'd like to take this opportunity (not so much as a eulogy, however apt the metaphor, more as an exercise in futility) to express a few of my (increasingly pointless) objections.

The free market, according to the economists, is meant to maximize profit. Ignoring the fact that there are no guarantees about how that profit will be distributed, there are a number of axioms that underpins this assumption. One of those axioms is that there are no externalities, or at least if there are, they are compensated. This is quite a big assumption even for some of the simplest economic transactions, but when we come to communications, this axiom doesn't even begin to stand up.

There are numerous externalities most of which are so intangible they can't even begin to be compensated. One of the externalities that most concerns me is that communications is such a valuable resource resource not only to building communities, but also to business in general. The governments 2 billion dollar trust fund is to get current services to the bush, however, being a technology professional, I know how quickly communications technologies change. Telstra are even struggling to get adequate mobile coverage to rural areas, let alone other technologies such as broard band internet. The communications technologies of tomorrow is what will drive business, and without the power to regulate the egalitarian dispersion of these technologies, certain sectors of the community that, those that a privatized company can't see immediate profits to pass on to their share holders. This I believe has the potential to seriously impact on Australia as a whole.

Monday, August 29, 2005

ADSL - the saga continues

Well after my previous hassles (here and here), I was at my wits end. I had pretty much eliminated most variables before I’d even rang my ISP, but after they insisted I had my modem double checked by plugging it into a friends ADSL line and watching it work, the only variable was the alarm system. When we moved in, there were no instructions on the alarm system, and to be honest, it wasn’t high on my priority list, but the tech support person at my ISP insisted that I get it checked out because it may still be plugged in to the phone line and causing interference. Well, I checked the alarm myself and couldn’t find any connection to the phone line, but then again, I’m not a trained alarm system technician so what would I know, and as the tech support person at my ISP kindly informed me, "If Telstra send a technician out and they find out that it’s your fault, they’ll charge you $99". So I had an alarm technician come around and verify ($75 later) what I already knew, the alarm was not plugged in to the phone line. So finally the coast was clear and I could insist on them sending a Telstra technician out… still with the warning of being charged if Telstra concluded that the issue was anything to do with my setup. Like all service companies these days Telstra would only give a 4 hour window, during which they would be performing the work, this meant that I was required to stay home from work during this time. Fortunately the technician called me fairly early in that period to tell me “yeah mate, it should be right now, there was a problem at the exchange”. And sure enough I now have ADSL internet access again.

Having ascertained that it was Telstra’s fault, and having been threatened with being charged if it was my fault, I am just wondering if I should send Telstra a bill for my time and the expenses I’ve had to incur to determine that Telstra didn’t do a proper job in the first place. Another thing that has crossed my mind is would I have got the same run around had I been a bigpond customer, ie is this Telstra’s way of using their monopoly on the network to make it difficult for other ISP’s to compete on an even footing. Maybe that’s a bit too much of a conspiracy theory, and Occam’s razor dictates that possibly a mixture of incompetence and/or apathy may be a better explanation, which essentially reduces to Hanlon’s Razor "Never attribute to malice that which is adequately explained by stupidity".

Friday, August 26, 2005

Quality on the web

I recently was asked to review some changes to a corporate website, and it got me thinking about what I expect for web sites from a quality perspective.

One thing that I think should go without saying, (but obviously doesn’t) is validation. I would say at least the 2 biggies xhtml and css validation are a must. These validators check through either your xhtml or css code and verify it against the generally accepted standard. Now if your designing a site that you know is ONLY going to be run with Internet Explorer, or whatever browser happens to be the flavour of the month for you target audience then fine, code to that browser if you really must, however, if your website is public facing you have no such control, and with mobile devices becoming more and more popular, you can never guarantee what your web site will be viewed under. I challenge anyone reading this blog to validate their corporate website, you’ll probably be very surprised what you’ll find, I know I was surprised just doing a minimal amount of research for this article.

I actually made the suggestion in the review that anyone doing web development should have every browser known to mankind and a few others installed on their machine, NOT JUST INTERNET EXPLORER. I am always frustrated when I’m using firefox, and I come across something that doesn’t look quite right, and have to exit and view it in ie.

Another big thing for me is that tables should NEVER be used for formatting. Tables are great... For tabular data. Nothing else in xhtml renders tabular data more elegantly and describes it more precisely than tables. But when it comes to formatting they suck. I know in the dark ages of web development there was little other choice and I myself used them prolifically before I stumbled upon the css zengarden. This is one of my favourite sites ever, and gave me the impetuous I required to sit down and learn css properly. I can also recommend a book "HTML Utopia : Design Without Tables Using Css". The other advantage as can be seen by css zengarden is that if you write your page properly, when marketing come down and say "we want to change our corporate look" as marketing are want to do (they have to justify their existence during the quiet periods somehow), it is a matter of replacing a few css files and putting up the new corporate logo, and suddenly the entire website looks completely different. You can then spend the rest of the month it would take for someone who formatted their website with tables doing something far more productive like getting your site up to accessibility standards like 508 or WCAG 1.0.

Sunday, August 21, 2005

More hassles

I can't believe what has happened over the past few days.
After my previous hassles, I patiently waited til Friday. According to my ISP's web site they would notify me on a designated phone number I provided when I filled out the online form requesting my change of phone line. I guess I was expecting an actual human (of some description) to call me and pleasantly inform me that I was once again connected to the information super highway, but why pay someone to talk when a simple automated SMS will do. OK I can handle the SMS, but what I find completely unacceptable is after my previous argument with them over them not divulging information to me because I wasn't the person who set up the phone line with Telstra, they have the ordacity to send an SMS with my user name and...... PASSWORD in plain text. I am seriously concerned now that they have no real idea about security.
To add further to my problems, I hadn't actually unpacked my ADSL modem from the move, and of course we've got boxes every where, so I spent most of Saturday trying to find my modem, and when I finally got it unpacked..... I couldn't get things working. I've been pretty busy this weekend looking at furniture for the new place so I haven't had a great deal of time, so I decided to wait til I came home tonight to go through all the different possibilities and test all my cabling etc.... before I call my ISP and spend 30 mins waiting in the phone queue to maybe find an answer. Well the good news is I didn't spend 30 mins in the queue, the bad news is that the reason for this was the call centre closed at 6pm. So til tomorrow after work, I'm still on dial up.

This is getting beyond a joke.

Thursday, August 18, 2005

Winge about ADSL hassles

I haven’t blogged in a while, and there is a damn good reason why. I have been in the middle of moving house. My partner and I have recently purchased a fantastic place in Fitzroy (inner city Melbourne).
The moving process is quite stressful, but I must confess I wasn’t expecting so much hassle with my ADSL line. We needed to get a new phone line at our new place, and so of course we had to switch our ADSL plan to that new line. We made this request on Monday the 8th of august, and waited…. Now I was under the impression that this would take up to a week. I have to confess that I think this is a particularly ridiculous amount of time considering that there is not really all that much work involved. They have to test the line, and then re-route my connection to my ISP. Sounds like all of about half an hour to me, and the fact that I had paid $99 for the work to be done, I would think that Telstra would be able to afford to resource this role fairly well….. We are still waiting for this to happen. On calling my ISP, he gave me the standard response of “Telstra say that it will take between 5 and 10 working days”. This is completely ridiculous, I’m an IT professional and because I move I can’t have an ADSL connection for 2 weeks. I do have dial up access, but that’s not a real internet connection…. Ever tried downloading webcasts and podcasts over dial up, it’s plain infuriating. To make matters worse, they actually wouldn’t give me any specific details of the status of my request because the my previous phone line was registered under my partners name. This I was told was for security reasons…. Lets see now, the guy at the help desk of my ISP had already asked me my address, the account name and my phone number, he then proceeded to ask me if I was Androniki Papapetrou, my partner (obviously not realizing that Androniki is a greek girls name (the male equivalent being Andronicus)). If at this point Id’ve said “Yes that’s me” he would have proceeded to divulge the information I required, but stupid honest me said “No that’s my partner”. So after he insisted that he wouldn’t tell me for security reasons, I got my partner to ring. I had to tell her our account name as she didn’t know that, and when she rang the questions they asked to verify that she was who she said she was….. account name, address and telephone number. Hmmmm top notch security there guys, if this information was genuinely sensitive, then we’re in a lot of trouble here. I think this incident raises a lot of questions about security. I am a firm believer in privacy, but if you really need to identify which pieces of information should be secure and then secure them appropriately, the rest can just be broadcast on your website…. It’ll save people so much frustration.
The latest on our ADSL connection is that it should be ready by Friday….. thanks Telstra.

Sunday, July 17, 2005

Evaluating VSTS

Well, today I finally start evaluating Visual Studio Team System. Yesterday I upgraded my PC to 2 Gig of RAM as the Virtual PC image with VSTS beta 2 requires 1.5 Gig on it's own.
I am excited about the new version control system (SCC) mainly because having worked with Visual Source Safe in previous projects, I am all too aware of the need for a decent offering from Microsoft in the Source Control department, although I am going to be quite hard to please given that I have been using Subversion for my own projects for some time now, and have found it to be very good.
I am also interested in the unit testing and code coverage modules.

I have to confess though, I don't think the productivity gains are going to be quite as dramatic as the Microsoft hype is making out. The best that we can hope for is that with the tighter integration of all these aspects of the SDLC, there will be a small time saving in people not having to switch between applications to perform development related tasks, and that reporting on project status will become easier.

There are a few reasons I believe this.
- A good, productive software development team will already have processes in place that suit there projects, their tool set and their team structure, they will already have worked out procedures around the fact that their tools aren't completely integrated, so the integration of the tools can save a small amount of time here.
- A good team will also be disciplined in following procedure, If a code review or static code analysis is required before checkin, a disciplined team will adhere to this, and do not really need software to tell them that they've forgotten to write unit tests. In this case the only benefit I can see is when new staff are introduced to the development cycle, the procedures will be more evident and they may learn them quicker.
- A good development team will have good leadership that will keep an eye on the processes tweaking them if there are issues with the code produced, or if the procedures are becoming too burdensome.
- A bad development team would have discipline problems that require more than just some software rules to solve. In my experience, where there is a lack of discipline, it is either out of laziness, or a lack of understanding of the reasons behind the procedures and policies. Laziness is a serious problem, however a lack of understanding can be solved only through education and experience.
- A good team will have communications in place. One presentation I've seen suggests that with VSTS there will be no more need for weekly status meetings because the work item tracking and the automatic reporting will be enough to display status. Maybe the actual status reporting in such meetings could be simplified, but I have always found these kinds of meetings vital as they provide a forum for everybody, (not just the project manager) to get a feel for what is going on across the entire project, so developer X might be complaining about a problem he's having and developer Y says that he has just finished some code that solves a similar problem, and would just require some re-factoring to solve his particular issue, while tester A is struggling with a particular concept in the use cases, so one of the BA's offers to explain it a bit more thoroughly for the entire team who then suggest she re-word the use case slightly. These kinds of informal meetings are invaluable to a dev team, and until we start writing software with advanced AI, they cannot be replaced by software.

Anyway, I still think VSTS will be a worthwhile tool, but I just think we need to be realistic about how far software tools can take us, and we need to not under estimate the human side of software development.

Sunday, July 10, 2005

The code wars have begun

Fellow collegues Mitch Denny and Joseph Cooney have started the "Iron Coder" challenge over the question is it better to sub-class or use extender providers. It will be a very interesting battle, with dark lord Darth Denny defending extender providers, and the young Jedi Joseph upholding the cause for sub-classing.
Use the source young Jedi.

Friday, July 08, 2005

Great use for nested classes

When I first read about nested classes I thought it was just one of those obscure parts of c# that I was never likely to find a decent use for, but today I found quite a good use for it, and it was sitting right there in my previous post.

Usually we use a custom control to contain an UltraGrid like so


public class MyControl : UserControl
{
...

private UltraGrid myGrid;
}


In my last post I offered a solution to adding record headers to an UltraGrid, but I passed the RowHeaders in as a List parameter to the constructor, now in the problem I'm trying to solve, this list is already maintained by the user control, so it means I have to maintain in 2 separate places..... Well not any more


public class MyControl : UserControl
{
...
private list myRowNames;
private UltraGrid myGrid;

private class RowSelectorDrawFilter : IUIElementDrawFilter
{
private RowSelectorDrawFilter(MyControl control)
{
myControl = control;
}
...
private MyControl myControl;
}
}


Then at the business end of things in DrawElement I use the following

...
drawParams.DrawString(drawParams.Element.Rect, myControl.myRowNames[row.ListIndex], false, false);
...


This means that I can let the user control maintain the row names and no-one ever needs to know about our RowSelectorDrawFilter class as it's happily nested in MyControlClass.

Saturday, July 02, 2005

Row Headers in infragistics UltraGrid control

A problem was puzzling me with the infragistics UltraGrid control the other day, how to get row headers in the grid?



My first thought was "well the UltraGrid is such a huge control, there must be some property somewhere I can set to do this", something like.... myGrid.DisplayLayout.Rows[i].Header = "Row Name" or myGrid.DisplayLayout.Override.RowSelectors[i].Text = "Row Name" etc.... I spent ages looking all to no avail.

After all else failed, I resorted (as a last ditch attempt) to the infragistics knowledge base where I found this article.

Now this just talks about getting rid of the pencil, but slightly adapt it and you get the following


class RowSelectorDrawFilter : IUIElementDrawFilter
{
public RowSelectorDrawFilter(List<string> rowNames)
{
myRowNames = rowNames;
}

public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
{
// Drawing RowSelector Call DrawElement Before the Image is Drawn
if (drawParams.Element is Infragistics.Win.UltraWinGrid.RowSelectorUIElement)
return DrawPhase.BeforeDrawImage;
else
return DrawPhase.None;
}

public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
{
// If the image isn't drawn yet, and the UIElement is a RowSelector
if (drawPhase == DrawPhase.BeforeDrawImage && drawParams.Element is Infragistics.Win.UltraWinGrid.RowSelectorUIElement)
{
// Get a handle of the row that is being drawn
UltraGridRow row = (UltraGridRow)drawParams.Element.GetContext(typeof(UltraGridRow));

drawParams.DrawString(drawParams.Element.Rect, myRowNames[row.ListIndex], false, false);
return true;
}

// Else return false, to draw as normal
return false;
}



private List<string> myRowNames = null;
}


then add the following line to the OnLoad method


myTableGrid.DrawFilter = new RowSelectorDrawFilter(myRowNames);


and providing the row names list is in the same order as the underlying table, it all just works. It is important that row.ListIndex is used to index into the rowNames array instead of row.Index, as row.Index is the display index, and if the grid is sorted, the row names will not be sorted.



Hope this helps someone else out there.

Monday, June 27, 2005

Simple fix for nunit

The simple fix for the nunit problem was to find someone with nunit already installed, and copy the binaries across onto my machine, everything works fine.

PS oh and load nunit.core.dll and nunit.framework.dll into the GAC using gacutil.exe

Saturday, June 25, 2005

Beta 2 woes

Well, it's been another interesting week at the bleeding edge of technology.

I discovered a problem with one of the third party controls we were using that caused events to fire in a different order to what we were expecting. This issue only occurred on my laptop, and just to prove it wasn't hardware, I ran it on a VPC on my laptop, and it worked as expected. After much searching and gnashing of teeth, I decided that a reformat was in order. As discussed earlier, I have had some issues with the upgrade from beta 1 to beta 2 of visual studio 2005, and figured that it could well be some framework issue, especially since the third party component used .net 1.0, and we were developing for .net 2.0 beta 2. I figured it would also give me the advantage of being the only one in the office with a completely clean install of visual studio 2005 beta 2.
So after half a day of re-installing my system, I finally am back to a place where I can develop. The biggest issue however is that I can't install nunit because the installer won't run unless it sees the .Net 2.0 framework beta 1. As I have mentioned earlier, I'm a bit of a unit test fanatic, and without it I feel crippled. My first thought was, grab the source and compile it under vs 2005 beta 2. No such luck, bits of it compile such as the core nunit framework, but not the actual nunit GUI.
Oh well, I guess I'll just keep limping along until the guys at nunit release a new version.

Saturday, June 11, 2005

The beauty of unit tests

Small confession, I only started writing unit tests a couple of years ago, but since then I find myself becoming more and more obsessed with unit tests. The development manager at the company I am currently contracted to has called me a “unit test evangelist”. Why have I become so fanatical in such a short period of time? I guess being interested in the whole development cycle I can see the huge benefits of code that has been properly unit tested. I’d like to list what I see as some of the advantages, in no particular order, and certainly not exhaustive.

- coverage: it is important that whenever a piece of code is written that the underlying logic is tested as soon as possible, and in isolation from the rest of the system.
- Confidence: If a class has been adequately unit tested, then anyone using that class can have a certain level of confidence in using that class.
- Demonstration: When the writer of a class writes unit tests against that class, the unit tests can be used by another developer to understand how the class is supposed (and not supposed in the case of negative unit tests) to be used.
- Shorter System Test: As I’ve mentioned before, the system test phase of the development cycle is the most unpredictable phase of the entire development cycle. If bugs are found by the developer in unit tests, they will never make it to system test.
- Refactoring: in todays “agile” world, refactoring is how a lot of companies enhance their software, but it can lead to bugs if the existing system is not understood properly. If a project has adequate unit test coverage, then any false assumptions made by the developer refactoring will be picked up immediately by the unit tests and will force the developer to understand that bit of the system before continuing.
- Performance analysis: A good set of unit tests can be used as a starting point for performance profiling. I have actually heard of one company that had the tradition that every Friday, all developers would stop what they were doing and concentrate all their efforts on improving the performance of their five slowest unit tests. Even if you don’t do this, you can at least see where your performance problems may lie.

I hear a lot of developers complaining that it’s too much effort to set everything up to a point where their classes can be unit tested. It can be a bit of an effort in some cases if say you’re working with data layer classes that talk to a database, however, it just requires a bit of thought when you start the project, and a lot of the setup work can potentially be re-used in the main application. I have yet to see any case where putting in the extra effort has not paid off. The only exception I can really think of is that retro-fitting unit tests to a piece of existing software can be more pain than it’s worth, however, this shouldn’t be an excuse not to start. My recommendation would be to make the decision that any new piece of functionality should be fully unit tested.

What I would like to do is over the course of the next few weeks I’ll write up a few articles about getting started with unit tests, and focus on a few different options available. If you have already been convinced by more most eloquent argument and want to get started right away, then here are some links to see you on your way.

For .Net developers, there is nunit.
For Java developers there is JUnit, and
For C++ developers, there is C++ Unit
There is even a TSQLUnit for unit testing your Transact SQL.

Beta tools

Sometimes I wonder exactly what I have to offer to the development community, I am just a developer the same as thousands of other developers out there, and rather than just add to the blog noise out there, if I don’t feel I have anything new to offer I’d rather not say anything. However, the one thing I am doing that not a lot of developers are doing at the moment, is writing a commercial application using Whidbey (visual studio 2005) and Yukon (sql server 2005). Most developers I know can’t really find the time to do much more than download the beta’s and have a short play before they go back to visual studio 2003 and sql server 2000. So I’ll share some of my experiences using the beta tools. I’ll start the ball rolling by talking about my recent experience upgrading from Visual studio beta1 to beta 2.
The team lead had done the hard yards initially, and was raving how smoothly the upgrade went, as far as code goes, there were a few minor things that needed around dictionaries etc…, but nothing significant. So when it was my turn to upgrade, I thought the process would be relatively smooth. So I started uninstalling stuff… first uninstall our software, then infragistics, then uninstall all the individual components of visual studio, run the cleanup tool (see here for details on what's involved), then uninstall all the components of sql server, as well as the sql server express instance for our software etc…. so by early afternoon, I was ready to start installing things.
Installing vs2005 beta2 was a very long process, so don’t expect to do this in 10 minutes. It’s good to see they have now included sql Mobile in the default install. There was an error at the end installing sql express, but I knew I would have to install our own instance later anyway, so I pushed on regardless. Installed infragistics, then went on to install our product which should have installed the sql instance. It didn’t, so after looking around in the registry we found that the uninstall of the sql instance hadn’t cleaned up the registry. Deleted manually, and attempted again, this time the sql instance install ran, but came up with a fatal error "Service 'SQL Server (instancename)' (MSSQL$instancename) could not be
installed. Verify that you have sufficient privileges to install
system services". I knew I was an administrator on my own machine (what developer isn't), so hit mailing lists and news groups. There were people quite willing to offer advice, but, especially on the sql down under news group, but when fellow Readify employee Greg Low suggested that re-formatting looked like the only option, I started to get a bit worried. However with a bit of patience and some help from one of my work collegues (actually the guy who writes the installer) we managed to figure out that the uninstaller for the sql instance had not removed the service for the named instance of sql server we were using. So hack around in the registry a bit more, and finally the we are up and running. In total 2 days to upgrade from beta 1 to beta 2. everything else seems to be going relatively well, it is a true testament to microsofts commitment that we are able to develop commercial software on there beta tools, but I will make just 1 criticism..... please make error messages more informative, if the error had've said "Cannot install service, an existing service with the same name already exists", I could have saved a day of pain.

Monday, April 25, 2005

Code Camp Oz

Just got back from Code Camp Oz. I fear my journey to the "geek" side is now fully complete.
Had a great time, met some more of my fellow Readify colleagues. It's always good to be able to put a face to the emails and blogs.
I attended most of the seminars.... (couldn't quite bring myself to get to the VB.net talks...... I feel I've done enough VB6 and VBA in the past that if anybody really wanted me to do some VB.Net I could quite easily wing it). There were 2 talks that had me very interested, both on one of my pet topics...... performance. It's good to see that the developer community is taking performance seriously.
Other talks were also very good, and I think given the circumstances, all the speakers did a really good job. Murphy's law always holds true for demonstrations, worship of the demo Gods sometimes helps, but when you're using beta software, sometimes even the demo Gods give up and go home.

Thanks to all those who organised it, it was well worth giving up a weekend for.

Friday, March 11, 2005

My new laptop

Please forgive the self indulgence, but I thought I'd just post a picture of my new laptop. It's not every day you get a new baby.



For those interested it's an ASUS M6N PM1.8/1Gb/15.4"/80Gb

Sunday, March 06, 2005

The performance question

Recently there has been a lively discussion amongst my work collegues at Readify about performance, sparked by a blog article by Rico Mariani. There have been some very interesting points made, but it has prompted me to think about performance. The random thoughts I want to share here, (I am a little too insecure to post my extremely humble (and slightly off topic) opinion to my collegues at Readify), is that dispite all the promises of the computer industry backed up by Moore's Law, in every "serious" project I have been involved in, performance has been a big issue. At first I put it down to the fact that I was working with Palm OS, and Pocket PC devices and obviuously on memory constrained devices you have to be very careful, but in my current gig, we're writing a PC applicatoin and there are serious concerns about the performance of the system under regular use. I think that the converse to Moore's Law is that the more powerful we build computers the more ways we find of using that extra power to the point that we are not really much further ahead than we were when computers were slower. Example, in my previous job, we developed a Pocket PC application which essentially was just a re-write of a Palm OS application we wrote 3 years prior. The PPC app requires a Pocket PC 2002 with 32 Meg of RAM and a 200 MHz processor, and still runs quite slow, where as the Palm Os application was targeted at a Palm OS 3.1 device with 2 Meg of memory and an 8 Mhz processor... and it ran quite fast.

Saturday, February 26, 2005

Unit testing private methods using reflection

Don't know how many other people have come across this problem, but a couple of days ago I was writing a class in C# and I decided I wanted a private method to perform some functionality. I knew the private method would contain some non-trivial logic, but didn't want to expose it to other classes that other developers were working on. I decided that the logic within the method was serious enough to warrant some unit tests, but how could I unit test considering the method was private. Normally I would make the argument that as long as I tested the public interface correctly, then I should be fine, however, I had a suspicion that this time was different, so I sought the advice of my fellow Readify colleagues, and the ever brilliant Mitch Denny came to the rescue with some sample code that used .net reflection to call into the private method.


TestVictim victim = new TestVictim();
Type victimType = typeof(TestVictim);
MethodInfo method =
victimType.GetMethod("PrivateMethodName",
BindingFlags.NonPublic BindingFlags.Instance);

//pass parameters in an object array
method.Invoke(victim, . . . .);


or in my case more along the lines of


Type victimType = typeof(VictimClass);
MethodInfo =
victimType.GetMethod("PrivateMethodName",
BindingFlags.NonPublic BindingFlags.Static);

//pass parameters in an object array
method.Invoke(null, . . . .);

as this was a static private method.

This worked a treat and I very quickly discovered the reason that I'd suspected I should go the extra mile and create this unit test. The very first time I ran my unit tests with just the most basic tests in place, I discovered one of those "doh" type bugs. Had I been attempting to just test the public interface, because there was considerable complexity in the public method that was using this private method I would have been looking in the wrong place for ages trying to debug the public interface, stepping into each line etc..., but because I'd spent 15 minutes setting up the unit test, when I did finally write the unit test for the public method, it worked first time.

Question: So when should you go to the extra effort of using reflection to unit test a private method?
Answer: When the private method contains non-trivial logic, and writing tests for the public interface won't make it obvious what's really happening or you won't be able to get decent code coverage from the public interface tests. There may be other times as well, but this is the rule I'm going to stick to for now.

Wednesday, February 09, 2005

Peer Code Reviews - 2

In my previous article on Peer code reviews I mentioned I didn't like the idea of insisting on a code review before checking into source safe. Well, I still don't like it, but I have discovered one reason which supports the idea.

If developers are left to code and check in/check out as much as they like, and are only required to have a code review before a periodic label, then it becomes tempting to write large chunks of code before getting a code review. now if a reviewer, by definition another developer, is asked to review pages and pages of code, then as the reviewer is also undoubtedly a busy person, they will simlpy use the page down key to scan over vast amounts of code and not really look for anything in particular as to look intently at each peice of code requires significant effort. I guess the conclusion is review early, review often. However, I still believe that there should be very few barriers to checking in building code.

Wednesday, February 02, 2005

Peer Code Reviews

Even though I have had 8 years experience in the IT industry, it may or may not surprise you to know that until my current job I have never had a formal peer code review. In the past the only times that a peer has looked at my code has been in a very informal way, and not really looking for the kind of things that should be looked for in a proper peer code review. So as you might guess, I was a little nervous when faced with the prospect of a peer code review, however, I am now completely sold on the idea.

I believe there are 2 elements that make code reviews invaluable to good code production. Firstly, the reviewer has a different perspective on the code. The reviewer is someone with different experiences, and as they are not in the thick of the coding, have time to relax and view the code in a more objective way than the creator of the code. They are not subject to the same line of logic that the coder has gone through to produce the code, so if the coder has written something a certain way after a string of incorrect or sub-optimal logic, the reviewer is free to question the logic, or propose a better way of implementing an algorithm, and the coder then is forced to either justify his logic by tracing through his steps, validating his decisions at each point, or accept the better way and re-code accordingly. The reviewer can also check for consistency with the accepted coding standards, and if the coding standards are good, better adherence will result in more readable, more maintainable code.

The second element is the psychological factor. As a developer, if I know my code is going to be reviewed, I will be very careful to adhere to the accepted coding standards and I will make sure that my code is set out in such a way that it is easy for another person to read. I will also validate my logic, imagining how I will explain complex bits of code to my potential reviewer. And finally I will do a once over of my code before I ask someone to review it, tidying everything up, making sure the review process will go smoothly and there will be no serious issues that the reviewer could potentially pull me up on.

All this doesn’t guarantee bug free code, in fact, the purpose of a code review is not to replace a proper QA process, but it creates an opportunity to catch obvious coding errors that would have otherwise come up in the QA process, and would have extended the whole phase unnecessarily. As the QA cycle is always the largest unknown of any software project, anything that can potentially decrease this phase has to be a good thing.

The only thing I don’t quite agree with is the way in which they use their source control in conjunction with the peer code reviews. Their idea is that there should not be a single line of code under source control that has not been reviewed. This creates an obstacle to checking in regularly. My personal opinion is that there should be very few obstacles to checking in modified source code. At my last work the rules I instated were just the obvious two; only check-in if the project is building (ie don’t break the build), and check-in regularly (usually before you go home at night). I always get nervous if source files are checked out for too long, there are obvious problems that can occur. The issue is that to avoid large amounts of small code reviews developers will wait for multiple days until they have some serious code to review. I think that all though the concept is noble, maybe a similar concept could be achieved by having some simple processes around labeling (or tagging depending on the notation of your source control), that can be administered by the release manager. I'll have to see how the process goes over the next few months, and see if my opinion changes with respects to their source control methodology. One things for sure I'm a convert to peer code reviews.

Thursday, January 27, 2005

Back to work

If anyone is wondering why I haven't updated updated in ages, it's because I've been on holidays for a couple of months. My adventures can be read on my other blog.

I have now started a completely new job. I am contracting to a company called Readify who are on-selling my skills to a company called QSR. So far the job seems really exciting, QSR are very highly organised, and everyone seems quite friendly. I feel I am going to learn a lot of invaluable lessons about software management.

Monday, November 22, 2004

Mobility: Optimize Your Pocket PC Development with the .NET Compact Framework -- MSDN Magazine, December 2004

I wish this article had been written before we plunged headlong into a Pocket PC project, and found out most of this stuff the hard way. It would have saved a lot of time.

Mobility: Optimize Your Pocket PC Development with the .NET Compact Framework -- MSDN Magazine, December 2004

Friday, November 05, 2004

subversion.tigris.org

I have just recently downloaded and installed Subversion (version control sfotware) for my own personal use at home, and I must say, I'm a convert. These guys have done a fantastic job.
Couple this with TortiseSVN and you have a winning combination.