Not all developers like fixed width fonts

In particular, I don’t. Lots of times other developers come over to me and look confused as they see Tahoma, 8pt. They have all sorts of comments about it not being right, in fact my absolute favourite was that it a waste of memory. Sorry last time I looked, Tahoma 8pt is the font used everywhere else on my desktop. Windows is probably saving memory by sharing it around.

However the problem is that some applications don’t let you make your own decisions. VS2003 only ever allowed you to get a bold variant of some Fonts e.g. Tahoma, but some other applications go one step further. They only let you access a fixed width font.

Sorry, but these applications are making a decision that should be theirs and they are choosing to affect my productivity. There is considerable research into what makes text faster and easier to read (i.e. you make less errors when you read it).

http://blogs.msdn.com/fontblog/archive/2005/12/13/503236.aspx
http://blogs.msdn.com/fontblog/archive/2005/10/28/486511.aspx
http://blogs.msdn.com/fontblog/archive/2005/11/16/493452.aspx – Quite fun

So given all this research (apologies that its all from one source) why do so many applications force you  into fixed width fonts!

Generating namespaces

One common problem I find is that developers do not understand the difference between deployment units and namespaces. The most common confusion is that these can often be the same, so they keep creating new assemblies.

However just fire up the object browser and take a look at the system assemblies. In particular look at system.dll and mscorlib.dll. Notice how the System.Web namespace is spread over mscorlib.dll, system.dll and system.web.dll.  Notice how System.Diagnostics is not a separate dll just part of system.dll.

So instead of creating a new project, create a new folder. Projects create deployment complexity, whereas folders simplify projects by grouping things together. While you are still working inside a single project you can still move things around, and you haven’t needed to change all sorts of deployment scripts. Consider this diagram

If you think that the blue shapes relate to assemblies, consider instead that they might simply be namespaces.

Only create projects and separate assemblies once you have multiple applications and there is reuse. Having something reused in multiple applications is where multiple assemblies starts, not before. This diagram shows again namespaces, where the reusable parts are shipped in a single assembly.

Singleton is Evil

Well I’ve read a bit of Steve Yegge before but I hadn’t come across http://steve.yegge.googlepages.com/singleton-considered-stupid before. He might have a point too.

I am currently re-writing an application I’ve written before, using lots of lessons I’ve recently learned.

Before I had quite a few singletons. Now so far I have a factory class.

Before I had a heirarchy of classes, each having a clever constructor that could process data and return a very specific instance of a base class. Now I have a simple class, and that perviously mentioned factory handles the different data types.

Who knows, maybe I’m getting to be a better developer

Works on my machine

Works on My Machine http://jcooney.net/archive/2007/02/01/42999.aspx (via http://www.codinghorror.com/blog/archives/000818.html). There are of course several responses to this

Pointy Haired Boss
Great, a new formal acceptance program for protyping code testing. I just hope its compatible with ISO 9001 and Six Sigma.

Manager
Oh no. Another piece of certification that my staff must comply with. We will never hit the next release delivery date with this extra overhead.

QA
Wow. Dev are doing some testing… Hmm, what’s this bit? Optional? Testing isn’t optional.

Developer
Professional reputation 🙂 snigger.

Has Microsoft released Vista, I didn’t notice

Alas poor marketing team, I knew them well

Until now I’ve been wondering what happened to Microsoft’s marketing team. Admittedly I don’t believe that I belong to their target audience.

I don’t read newspapers so I’ve probably missed those full page spreads showing the new glass interface in full colour. I tend to go and get my news either from news.bbc.co.uk which I hope has less of the usual this or that political bias than most. Or if I really want to know by watching the Press Associations RSS feeds. These feeds have the advantage of having NO editorial or comment or anything really. They consist of really short facts (usually). I particularly don’t like the free rags foisted onto you every night, as these seem to consist solely of advertising, celebrity photos/exclusives and a small portion of content recycled from the mainstream newspaper which is coincidentally owned by the media moguls who pay for these advert/celeb rags. (Although I must admit they do provide a source of revenue for London taxi drivers. For without all those distributors standing on every inch of the pavement, we might actually make our trains and tubes on time.)

I do get a very small window of opportunity to watch tv, certainly no more than 1 hour a night, and averaging far less than that, but I have caught the “Wow” advert once. I must admit I liked it. I’m not going to rush out and buy Vista just because of it, but it was a nice piece of advertising. It certainly fell into the classic English advertising of not being brash and upfront, but instead trying to get a brand formed in your mind. All those technical and social revolution milestones, wow this Vista must be a huge positive change. Ahem.

What I have seen is all the bill board advertising. This I have no choice but to read. The tube station halls either have these 6’x4′ images jump out on you as stride down the corridor, or hold your eye while you wait for the “tube muggle” to move over to the right with their suitcase. I particularly like the two english comedians

  • I was built for spreadsheets and text editors – I was built for music and video
  • I was built for the office – I was built for the home
  • I suffered from 14,000 (2) viruses last year – I suffered from none

Hold on a moment, those adverts are on a white background with black text, and they have a fruit like logo in the bottom. Oh no I’ve been reading Mac propoganda (1). So where is Microsoft? Did they miss me?

Well actually no

Now if you found this post, you’ve found this site. If you should decide to read around, you will probably come to one of two conclusions.

  1. Wow this guys sure does know a lot about C#, DotNet and programming on Windows.
  2. This bloke is a sad geek who spends all his time on computers and has no other life.

Either way the problem is simple. Anything I can see in an advert I have already been reading on the old Windows Vista site. I deliberately did not download the Vista Beta purely because I knew I would be hooked, and so instead I have spent a fair portion of time keeping up with Longhorn. One reason I am already fully conversant with what is coming in Vista, because I don’t spend my days reading the adverts and celebrity photos in those free papers. Thing is though you could be too, except it appears to have gone. The marketing guys have been and taken away all the detailed information and replaced it with the celebrity photos edition. Like a size zero model it looks good, but there’s less under the surface than you want.The more you look the less you find.

Today Vista marketing hit me square in the face

Lunch time today I needed a break. I had no urgent issues to address, no clients concerns and no meetings from 11am to 2pm. I had some time spare, a commodity rarer than gold dust, that occurs less frequently than both of my children being angels at exactly the same time. I took a wander over to PC world.

To me PC world is a near utopia. It has all those glittering pieces of hardware in the flesh, just calling out to you to buy them, but you must not. You can buy them cheaper elsewhere. The virtual land of Amazon is a short URL away and provides you with all the pictures, lots of information, no salespeople,better prices and the spec you actually want. Alas, Amazon is virtual and PC world is real.

Today it was a Vista heaven, and after having a play on actual Vista laptop I know know what Microsoft marketing have been up to. Almost every single laptop and desktop was running Vista. Theoretically I can see what all the hype is about and go Wow. Well actually more like wow, erm . It was pretty, it had glass, but it is just an OS. Sorry but it is. Now my OS does three things for me, that I can appreciate.

  1. It hibernates my session when I close my laptop (although not all the time if I am debugging in VS2005).
  2. It takes up a small line at the bottom of the screen with the Start Bar.
  3. It lets me change programs with Alt-Tab.

Everything else it does is invisible, I just take it for granted. So I really need to spend more than 10 minutes playing with a laptop in a store. So my first impression is this

  1. I didn’t get chance to hibermate
  2. The line at the bottom is black not blue, and you can run the sidebar on the right.
  3. Alt-tab now works an in a funky way, but the really pretty window switcher is via the mouse.

So will I be upgrading to Vista

Well… yes. I mean there is absolutely no chance that I won’t at some point. At the very least my employer will upgrade and I will use it then.

Am I going to rush out and buy a copy… No. There’s no reason to spend money updgrading my current laptop which is five years old, has one shift key and one USB port that don’t work. I’m not afraid of going through the upgrade. I bought my Tecra 9000 as the 2nd one (supposedly) into the UK. It came with Win2K and I went through driver hell getting it working with XP. This time I’m not in such a rush.

However what does excite me is the opportunity to run Vista on a tablet. New OS on new Hardware with new hardware and funky new features. Maybe I’ll stop that lump of bone growing anny bigger before it becomes RSI. Lots of talk about how much better Vista is for handwriting recognition which it needs to be as my handwriting is appalling. I’ve run Pocket PC’s for years until I bought my laptop and that was always hit and miss.

So thanks Microsoft. When the hardware manufacturers get me the tablet spec I’m after I’ll be buying nto your new OS. Until then, well I would say don’t waste your money on the advertising, but it looks like you aren’t.


(1) Not that I am adverse to Macs, there just isn’t much call for them in the average real time processing system that handles large sums of money a day.

(2) This figure is probably wrong. Sorry wasn’t paying that much attention as the 8:40 was late again and another hoard of fake business types (3) were wheeling their briefcases into everybodies way on the tube.

(3) You can tell fake business types from the real ones in one simple step. Ignore the BlackBerry, mobile, laptop, corporate suit or even the miniature filing cabinet/massive briefcase on wheels. When they step off the train/tube are they already travelling at top speed? Those are the ones who are driven and have to get things done.

(4) Yes I have read Pratchett. How did you guess?

CLR integration – SQL

Just written my first C# SQL function, here it is in all its glory.

[Microsoft.SqlServer.Server.SqlFunction]
public static DateTime GetSunday(DateTime original)
{
    DateTime result
= new DateTime(original.Year, original.Month,
        original.Day
((int) original.DayOfWeek),
       
0, 0, 0);
   
return result;
}

Then I went and found out how to really go to town. http://msdn.microsoft.com/…/sqlclrguidance.asp, so here is my 2nd function (and helper)

 

[Microsoft.SqlServer.Server.SqlFunction
    (FillRowMethodName
=FillGetAllDates,
    TableDefinition
=Date datetime)]
public static IEnumerable GetAllDates(DateTime start, DateTime end)
{
    DateTime date = start.Date;
    List
<DateTime> result = new List<DateTime>();
   
while (date <= end)
    {
        result.Add(date);
        date
= date.AddDays(1);
    };
   
return result;
}

public static void FillGetAllDates(object row, out DateTime date)
{
    date
= (DateTime) row;
}

IEnumerator and Foreach

I wanted to write a simple post about List enumeration and suddenly realise that here we as developers, are about to enter a pradigm shift. No longer is the default to develop for a single processor, threading will not be something that clever programs use. Almost everything is going to require scaling and queuing.  Why? Well here comes Core Duo. Two processors on a single piece of silicon. In fact I even read that servers are going to be offered with four Core Quad Chips. Welcome to the “many core” era.

I almost always use foreach for all list processing. Of course as we move into a many core world the standard concept of foreach just wont cut it anymore. Consider the following.

foreach (Data x in List<Data> list)
{
    Action.Do(x);
}

That just doesn’t take advantage of this extra power. It keeps all the processing on a single thread on a single Core of a single CPU. Looking for bottlenecks, start right there. Of course the reason we use this is because of its simplicity. Everyone can read this. It makes sense.

However there is an answer, and as usual it isn’t anything new. In fact it is the GoF Visitor pattern, and it’s already it the code above (sorry must stop cheating).

By defining the operation that we want to perform outside of the loop, in this case Action.Do(x); then we allow ourselves the opportunity to change the loop.

foreach (Data x in List<Data> list)
{
    Action.BeginDo(x);
}

Which only leaves us with one problem? How do we know when they are all finished?

Update:
I think just missed my own point here. Why? Well this is exactly the same thing that Eric Sink wrote about http://software.ericsink.com/entries/multicore_map.html in response to Joels post http://www.joelonsoftware.com/items/2006/08/01.html.

InternalsVisibleTo

nUnit integration is made so much better with the InternalsVisibleTo attribute. Declare this in the assemblyInfo of the class you want to write tests for and specify the nunit dll that you want to be able to acccess the internals. [assembly:InternalsVisibleTo(“nunit.xml.whatever”)]

Why does this help?

Probably the best way to illustrate this is with an example. I have a class in an assembly which takes an object model, converts it to XML and then passes it into a webservice. My unit tests want to confirm that the serialization always work, not the webservice. My interface does not expose the XML at any point.

However with this attribute I can now expose the XML via an internal property, and pick it up as a test.