Monday, December 10, 2007

I'm afraid I'm a car snob

My car needed its second service today, which coincided with a planned shopping trip which i didn't really want to move. So I've got a courtesy car, and although it's almost brand new, clean, quiet and quite nice looking, there's no power there at all. I'm used to 200 horsepower and a turbo, now I've got an entry level 1.4 litre which is too heavy to ever be called nippy.

But at least it's only temporary, hopefully I'll get mine back tonight or tomorrow.

Thursday, December 06, 2007

UltraMon

If you're lucky enough to be using multiple monitors on one PC then check out UltraMon.

I've been using it for a couple of weeks now, and only just realised I can make Visual Studio span both screens, which means I can dock all the toolbars to one screen, leaving me with a full screen of code :).

Neat Pattern for Cloning with Inheritance

For once I've come across an MSDN forum post which exactly solves a problem I had. I'm not having the same problem as the person who asked the question, but the solution given was spot on for me.

Suppose you have two classes, SuperClass and SubClass, where SubClass inherits from SuperClass. If I want to create a deep copy of SubClass I should really implement a Copy method in SuperClass, and override that in SubClass.

But if I do that I can't really use the Copy method in SuperClass, because I can't cast a SuperClass to a SubClass.

The solution (as described in the above post: I can claim zero credit for this neat pattern), is to instead create a CopyFrom method, in which a SuperClass can be populated from another SuperClass. Then in the SuperClass's Copy method I create a new SuperClass, and call the CopyFrom method on it, passing in "this" (or "Me", if in VB.Net).

Then SubClass can override CopyFrom and call into the base method, adding any further properties that SubClass has. SubClass then overrides the Copy method, creates a new SubClass, and calls CopyFrom before returning it.

This is the code from the post above (credit to "nobugz"):


Class A
Private DataA As String = "Data-A"
Public Sub New()
End Sub
Public Overridable Sub CopyFrom(ByVal obj As A)
Me.DataA = obj.DataA
End Sub
Public Overridable Function Clone() As A
Dim NewA As New A
NewA.CopyFrom(Me)
Return NewA
End Function
End Class

Class B
Inherits A
Private DataB As String = "Data-B"
Public Sub New()
End Sub
Public Overrides Sub CopyFrom(ByVal obj As A)
obj.CopyFrom(Me)
Me.DataB = CType(obj, B).DataB
End Sub
Public Overrides Function Clone() As A
Dim obj As B = New B
obj.CopyFrom(Me)
Return obj
End Function
End Class

Wednesday, December 05, 2007

Divx XBox 360 Dashboard Update December 2007

If you've signed into XBox Live over the past couple of days you'll probably have been prompted to download a console update. I haven't yet found a complete list of everything that's changed, but I can confirm that the rumoured Divx support has been included. Yes, you can now stream Divx videos from a PC (running Windows Media Player 11) through your XBox so you can watch them on TV.

The quality is surprising good from the what I've watched.

Tuesday, December 04, 2007

Bad Smells in Code

If you've read anything by Kent Beck or Martin Fowler you'll probably have come across the concept of Bad Smells in developing computer systems. Not every developer I know has heard of these though, or if they have they're not entirely sure what it means.

In general terms it basically means that something just doesn't feel right in the code. But it can take a few years experience in writing code before you get to the point where you start getting this feeling, so I'm glad that a list of the common bad smells are listed for all to see.

The list is by no means complete, but please check out the most common bad smells.

Wednesday, November 28, 2007

DLL Dependencies

Found this blog entry on geekswithblogs.net linking to Dependency Walker. This is an application that shows you the dependancies that a DLL has.

I couldn't get to the site though, so I downloaded the app from majorgeeks.com.

There's a comment on that blog saying it doesn't work with .Net assemblies though, but you can just use ildasm for that, and look in the manifest.

Monday, November 26, 2007

Blackwater (Jeremy Scahill)

I'm currently reading Blackwater: The Rise of the World's Most Powerful Mercenary Army by Jeremy Scahill. It recounts the history of Blackwater USA (Wiki entry here), the company employing a large proportion of the "security contractors" hired to protect assets in hostile places around the globe, such as in Iraq.

The book begins by documenting the bloody ambush of Blackwater contractors in Fallujah in March 2006, and moves on to tell how the U.S. Government is increasingly using companies such as Blackwater to influence foreign policy where it would be politically unwise to use the U.S. Military. Scahill tells how Blackwater has set up bases in Tbilisi, Georgia and Azerbaijan which are now tantamount to having unofficial U.S. bases in the area, but without the political uproar.

The book certainly makes interesting reading. In fact, what I find most enlightening is not how powerful and influential companies like Blackwater are, but rather the clear political wrangling that goes off behind closed doors, that common folk like me only get a hint about in the press.

Scahill is obviously very passionate about this cause, and he has produced a seemingly well researched piece of writing that forces us to ask questions not just about our role in Iraq, but also asks us to cast an eye over other conflicts and places of political unrest. It is clear from the stories told in this book that our governments aren't giving us a true picture of what is happening in these places. But this is something a cynical, skeptical person such as myself already suspected anyway.

However, the book could hardly be called impartial, and as such it loses much of the credibility it should be earning. Scahill's choice of language is constantly laced with emotive terms that will make it easy for any party opposed to his views to dismiss the entire book as left-wing propaganda.

In choosing to write in this style Scahill has made a rod for his own back. What should be a chilling, hard hitting exposé on the U.S. Government's recent political choices is in danger of being wholly dismissed when the questions it raises deserve to be answered.

If you can look past the occasional emotional phrase, and concentrate on the fully referenced source material, you can see a book which raises as many questions as it answers. Although I doubt answering these questions was ever Scahill's intention, in writing this book he has at least made public what is happening that other media sources aren't giving us a true picture of.

What does that error code mean?

If you've ever come across an error number in managed code it can be infuriatingly difficult to find out the true root cause of your problem: normally there's a helpful wrapper around the numbers, giving (semi) meaningful names to the errors encountered.

But, work with stuff long enough and you'll soon find a huge, dirty-looking (mostly negative) integer staring back at you in your log files or debugger window and you'll wonder "What the **** does that mean?"

If you can't find anything on Google for the exact number you've got, paste the number into calc and convert it to hex. You'll usually get a number preceded by a bunch of Fs, which you can ignore. Do another search for this hex number (minus the Fs), and you'll sometimes get something which will point you in the right direction.

It was on such a search where I stumbled across this helpful document. This text file contains a heap of hex error codes and their meanings. judging by the ntstatus.txt file name they look to date back to Windows NT days, but they're still helpful now in some cases.

I can't say that everything in there is accurate, or that every error code you'll get is listed there.

Creating an Interop Assembly for RTC Client API 1.3

If you want to use the RTC Client API 1.3 in managed code (like C# or VB.Net), you need to create an Interop assembly from the rtccore.idl file that is found in the C:\Program Files\RTC Client API v1.3 SDK\SDK\IDL directory (if you used the default installation path).

There are some steps detailing how to create the assembly here: Creating a Interop Assembly for RTC Client API 1.3. However, I found that they were a little out of date and I had to do some reading around before I understood them.

To create the assembly:

1. Download and install the Microsoft ® Windows Server® 2003 R2 Platform SDK. This SDK works for "the x86, x64 and Itanium-based versions of Windows Server 2003, Windows Server 2003 R2, Windows XP SP2, Windows XP x64 Pro Edition, and Windows 2000".

2. Go to the Visual Studio 2005 Command Prompt from Start Menu -> All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools

3. In the Command Prompt window, change directory to where the rtccore.idl file is (C:\Program Files\RTC Client API v1.3 SDK by default).

4. In the Command Prompt type: midl /I "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" rtccore.idl. This will create 5 new files in the directory. One of which is rtccore.tlb.

5. In the Command Prompt type: tlbimp rtccore.tlb /out:Interop.RTCCore.dll /namespace:RTCCore /sysarray. This will create an Interop.RTCCore.dll file in the directory, which you can then reference in your .Net applications.

Using Microsoft's Speech API (SAPI) in managed code

Neat little article here for How to use Microsoft's Speech API (SAPI) in a managed application.

Doesn't go into much detail on how to use it afterwards, but there's enough there to show how simple it is.

Tuesday, November 20, 2007

First mobile blog post!

I'm just testing right now, I'm not mobile myself but this post is being written on my mobile phone. It's a new free service we're offering, so if you want to use your mobile to add blog entries give it a go!

Mobile post from the Esendex BlogIt service

Esendex BlogIt

I've just signed up for this great new service from Esendex where I can blog all day long from my mobile phone for free!

Mobile post from the Esendex BlogIt service

Wednesday, November 14, 2007

YO! Sushi

I've been to the Nottingham YO! Sushi a few times now and I have to say I've never had a better fast dining experience. It's a very short walk from the office and thanks to the conveyer belt of dishes, you can start eating straight away--perfect for a quick bite to eat at lunch.

Only trouble is I always find myself getting carried away and eating too much :)

How fast is your turnaround time?

There's currently a question been posted on AskSlashdot which asks How fast is your turnaround time?:

...Overall, we manage to get a 'bullet-proof' patch in about 4-5 weeks (from coding->QA->Build/Packaging->shipment), which I consider not so bad. But the other day, we got an urgent request from our support team to come up with a decent fix in 48 hours. I think they're a tiny bit unrealistic. So I wanted to get feedback from my peers: are we doing that bad?...


Esendex's core product is an online service, which means our customers don't need to install anything. So realistically I'm not in a position to comment on this particular matter. We don't need to go through a packaging stage, and we can be pretty confident that we won't have installation issues as we own all the server hardware the system runs on.

But looking at the timescales involved here puts a few things into perspective. If one of our releases introduces a critical error (by which I mean that people can't use our service anymore), then the entire business rests on getting that error fixed. In these cases (thankfully they are few and far between) 48 hours is just too long. In fact much too long.

If we're in a position where we have customers not able to send messages then our SLAs make us contractually obliged to fix the problem within 4 hours. I remember being alerted to one such error a few years ago at 2am on a Sunday morning. By 5am that day the system was patched and fully operational again.

A quick turnaround stems from the design methodology you are using. With XP we learn to expect change, so we make sure that we don't code ourselves into a corner. This makes new requirements easy to add, but it has the side effect of making most bugs easier to fix as well.

Of course, there's always going to be the possibility that your design is so flawed that it's impossible to fix a certain bug. In these cases backing out of an update is sometimes the only feasible option.

All non-trivial software contains errors. If there's one truism about software development, that's it. The important differentiating factor is the severity of those errors. A truly business critical severe error needs to be fixed as fast as possible, and if it means late nights then so be it.

As professional developers we're paid to release working software, and if that software doesn't do its job then we haven't done our job.

Tuesday, November 06, 2007

And so I bought an Ipod Touch...

Just happened to pass Curry's at lunch, so I wandered in from the cold and had a look around. Among the Ipods was the new Touch, with the tempting notice of "Back in stock" next to it. I've been wondering about getting one since seeing it reviewed on Something for the Weekend, and as I asked the shop assistant if they did indeed have some in stock (as I no longer believe everything I read) a strange feeling swept over me.

And so I bought an Ipod Touch, and I must say I am very impressed. I haven't put any music on it yet as my music collection is at home, and I am at work, but the internet connectivity is very useful. The Safari browser is cool, and it has the "pinching" zooming that the IPhone has.

And the Esendex website works through it too. I think I must be one of the few people that have sent a text message from an Ipod Touch :).

Monday, November 05, 2007

Zero Punctuation

I got emailed a link the other week to Zero Punctuation's MOH: Airborne review, and this evening I've just watched a load more.

Very, very funny. I can't recommend them enough.

Check here for a list of reviews

Remember, remember

As I write this the sound of gunfire clatters in the street outside. Huge explosions rock the glass in my window. Orange haze stains the night sky as distant fires rage.

A smoky mist lingers in the crisp November air.

No, England hasn't been invaded. Marauding rioters aren't destroying the town. And I haven't taken a day trip to Iraq.

It's just that time of year again where we decide to celebrate the fact that 402 years ago a Catholic tried (and failed) to blow up the Houses of Parliament. So now, to show our solidarity in this traditional religious intolerance, we feel the need to purchase illegal industrial fireworks and set them off in our own back yards.

Now, don't get me wrong, I enjoy Bonfire Night. In fact on Saturday I wended my merry way down to Tesco and took advantage of their "buy 1 get 1 free" offer on fireworks, and later that evening we set them off (and we were only slightly drunk).

But these were "garden fireworks". Actually sold for use in people's gardens. And, if I have to be honest, some of them weren't that good (in fact, some of them were really quite crap). But we all had a good time nevertheless.

These aren't garden fireworks going off outside.

I'll try and describe what I can see from my window now. If you've ever been to an organised fireworks display you'll know that those fireworks are considerably louder, faster and bigger than what you can buy over the counter at your local supermarket. Imagine those types of fireworks being set off from at least one house per street as far as I can see. I can see maybe twenty streets from here.

All around rockets are screaming into the sky, erupting into a shower of sparks. It is really impressive looking actually, and I admit there is a tinge of jealousy that their fireworks are better than the ones I bought on Saturday.

But imagine this. You jab a rocket a little too far into the ground and light it. What happens? It goes nowhere and makes a big bang. Imagine doing that with one of the industrial fireworks I'm looking at right now. The outcome of that would spoil any body's night.

I can't remember a Bonfire Night being this noisy. How come people are spending this much money on their own personal fireworks displays? Is it just petty competitiveness that makes people do it?

I'll be sticking with my legal garden fireworks, thank you.

Thursday, November 01, 2007

Manually Remove a Windows Service

Just a quick note linking to this article explaining how to Manually Remove a Windows Service.

Basically, open the Registry and go to this key: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services

If you expand this key you'll see sub-keys for each installed service. Delete the key for the service you want to remove.

Wednesday, October 31, 2007

Been a little quiet here lately

I've just become very aware that I haven't posted here since Friday's cynical link about BP being fined, but things have been busy here finalising and deploying the update hinted at in my Monitoring Custom Windows Services post.

It's not been an easy couple of weeks, but I think we're finally seeing the performance improvements that we were hoping for.

I know I mentioned posting some code samples about how to create your own performance counters, but I really haven't had time.

If you want to investigate using performance counters then probably the best thing to do is check out these MSDN articles:

Friday, October 26, 2007

BP fined for environmental crimes and fraud

BP has been fined $373m by the US government for "environmental crimes and committing fraud".

"BP has committed serious environmental crimes in our two largest states, with terrible consequences for people and the environment," the Environment Protection Agency said.

Anyone else remember their advertising campaign that encouraged people to calculate their "carbon footprint"?

Seems BP should get their own house in order before telling the rest of us to.

Thursday, October 25, 2007

Monitoring Custom Windows Services

A lot of my work at Esendex involves creating and maintaining Windows Services that form the guts of a much larger product that we collectively call the Esendex Messaging System. The work that these services do can differ wildly: everything from the relatively mundane to complex critical services that the business depends on.

Because of this, each service needs to be monitored in different ways. Sometimes its OK to trawl through log files to discover what the service is doing, but with other more widely used services this quickly becomes tedious.

We're currently in the process of rolling out an update to one of our critical Windows Services, and this update involves an architecture change that makes examining logs beyond tedious, it's actually unworkable for anything other than tracking historical events.

This is where we use custom performance counters. If you're a developer and don't know what these are, then read up on it, and quickly. Performance counters can be used to give you visibility on the near-realtime progress of your systems.

Here are some examples of what we monitor with performance counters:

  • Execution time of certain key interface methods,
  • Total counts of current throughput at various stages of a message's journey through the system,
  • Rates of current throughput (how many messages per second, etc),
  • Statuses of key services.
From these we can use the standard Windows Performance Monitor to watch what a service is doing. For a more bespoke monitoring solution you can also write your own applications that read your performance counters and display the results in a more friendly way.

If I get time I'll knock up some sample code demonstrating how to do this.

Friday, October 19, 2007

The Vulcan Flies Again

Something I've been waiting to see for a few years after hearing that the Vulcan to the Sky Trust were restoring one: yesterday it completed its first test flight.

Check out some of these photos of the flight.

Thursday, October 18, 2007

Couple of things I miss from Visual C# Express

I know this great little application is free and so can't really complain, when you work with Visual Studio 2005 Professional five days a week the bits that are missing start to get to you:

  1. No "delete all breakpoints" option.
  2. Can't attach the debugger to another process, or set the project to load a different application
Doesn't sound like much, and I didn't think that was much, until you step through an XNA project, and then have to manually remove all your breakpoints. Or if you want to unit test something and you can't attach to the NUnit process, which means you can't step through your tests.

Glad it's got Intellisense though :)

The Stupidity of the Collective

I left work a little later than usual today, and so when I finally got onto the motorway the traffic was lighter than I normally have to drive through. Although I say "lighter" it was still busy, and I had to wait a few minutes before I could get into the outside lane to overtake a pair of lorries seemingly dancing together in the first two lanes.

The middle lane was clear after I passed, so I moved into that, and a little while later the first lane was clear, so I moved into that.

It was then that I realised the outside lane was pretty much bumper to bumper. The middle lane was clear, and the first lane that I was in was flowing smoothly at just under 70mph. The outside lane on the other hand was stumbling along at probably around 60mph, and the cars were so close that people had to keep braking, which was causing a traffic shockwave as far back as I could see in my mirror.

Why were these people in that lane? I have no idea really, but it must be for a similar reason to why cars try to overtake people when the next lane is going no faster than the one they're leaving.

Don't these people know that life in the fast lane doesn't always get them to their final destination any quicker? I mean, just look at Keith Richards..... ;)

Wednesday, October 17, 2007

What if Google Had to Design For Google?

To web developers the term SEO (search engine optimisation) can send chills down their backs. Usually it means adding things to the design of a web site in order to get it noticed by search engines--particularly Google.

Saw this linked from Slashdot: What if Google Had to Design For Google in which it shows what Google would look like if their own developers had to get their site noticed by themselves.

The outcome looks eerily like a Facebook or MySpace clone. Now you know why those sites can look so cluttered ;)

Monday, October 15, 2007

Log Visualiser using a particle system

I carried on my attempts to make logging output look a bit interesting, and what I think I wanted was a stream of pixels flowing down from a server name to give a waterfall effect. Each pixel streaming down would represent one log event, and the colour of the pixel would be determined by the log level of that event.

I set out to implement this, but then thought that someone else must have come up with a particle system for XNA already. And they have, check out this particle sample on the XNA Creators Club.

This sample shows how you can make explosions and smoke effects in XNA, and the end result is surprisingly realistic. I took this example and derived my own class from the abstract ParticleSystem class. It took some experimentation with the parameters I used, but now I've got a stream of pixels flowing in the way that I planned.

I've also got a mock application that just generates log entries for the XNA application, and I've generated 10,000 logging events in a very quick sequence. As the XNA application doesn't store the events for very long there doesn't appear to be much slow down, but it would be interesting to load test it against a number of servers generating a high volume of logs. At the moment I think there would be a slow down but I'm pretty sure I can refactor the event handling so that it will be more scalable.

There's some cleaning up to do, mainly with the positioning of new server entries and externalising a number of parameters to a config file, but I think I'm mostly there.

Thursday, October 11, 2007

Visualising Logs - Progress Report

Just a short one as it's getting late now. I've continued a little with my XNA log viewer mentioned previously.

I've set up a mock application that generates logs on command, and I've set up log4net in the same way you would if you wanted to look at the logs in Chainsaw. So this fires off UDP packets containing the entry in XML. I've then got a class that listens asynchronously to a socket. When it receives data it deserialises it to an object, and then raises an event.

My XNA "game" has one of these socket listening classes, and provides an event handler to receive the logs.

On screen right now I'm just scrolling the messages. To do this I have a GameComponent that contains a rough implementation of a generic circular queue. The contents of this queue are drawn to the screen, and as it's always wrapping around, it gives the effect of scrolling without having to move the position of the string.

Next I need to figure out how I want the logs to be visualised.

How to prosecute a lying politician.

Did anyone else watch The Ministry of Truth on BBC2 just now? I saw a summary of it on last night's Newsnight, and was compelled to watch the full version today.

If you didn't get to see it, the crux of the documentary was to find out what you can do if an MP (including the Prime Minister) openly lies to the electorate.

The shocking answer, according to the makers of this new documentary, is: you can't.

If a politician lies to the electorate, there is no formal course of legal redress outside a general election. In a bid to close this gap in the constitution, an MP has drafted The Misrepresentation of the People Act: a bill that would force politicians to tell the truth - or face criminal prosecution.

Plaid Cymru MP Adam Price is now spearheading a national campaign to change British law so that any politician who deliberately misleads the electorate can be prosecuted.

Now, I don't normally get involved in politics, but watching the MPs in this documentary all agree that honesty was important, and then call the interviewer naive for wanting to put something into an actual law has put my back up quite a bit.

However, it was refreshing to see that no one backed down, and there were responses for every one of the MPs' objections. For instance:

The bill is not needed as Parliament regulates itself:
All of the regulatory bodies within Parliament report to the Prime Minister, who then decides if he wants to act on it. The programme likened this to being judge and jury at your own trial.

If an MP openly misleads Parliament their career is over:
Admittedly most MPs found to have lied do resign, but it doesn't prevent them from holding office again. Look at Peter Mandelson and David Blunkett. These MPs resigned only to find themselves elected officials once more.

Any MP in the House can ask "question after question after question" at Prime Minister's Question Time (Lord Falconer gave this little gem):
An MP can only ask a maximum of two questions per sitting, and the PM doesn't have to actually answer it.

To say this bill is needed is to suggest that all politicians are dishonest:
Not at all, claims the documentary. Just because we have laws against murder, robbery, rape, and theft doesn't mean that we would all do it if it was legal. (Although, an admittedly unscientific poll on the Ministry of Truth website asking "Do you think politicians lie to us" is currently sat at 96% for "Yes, on a regular basis")

You can't have a law against lying (particularly liked this one, that seemed to be spouted by most of the MPs):
Well, we do already. Trades descriptions laws, advertising laws, company laws... they all prevent individuals from deceiving their customers, or board members. Why should the government who, as one person on the documentary said, "are the board of directors for Great Britain PLC" be any different?

An Early Day Motion about the bill is set to be put in front of ministers next week. The cynical side of me thinks that a lot of smarmy spin doctors will shoot it down before anyone has had the chance to discuss it properly, but I truly hope that doesn't happen.

I wish Adam Price the best of luck next week, and sincerely hope he takes it all the way to an actual law.

Wednesday, October 10, 2007

Do you use goto in C#?

Looking through the code for the SmtpClient.Send method in Reflector and found this snippet:

switch (this.DeliveryMethod)
{
case SmtpDeliveryMethod.SpecifiedPickupDirectory:
if (this.EnableSsl)
{
throw new SmtpException(SR.GetString(
"SmtpPickupDirectoryDoesnotSupportSsl"));
}
break
;
case SmtpDeliveryMethod.PickupDirectoryFromIis:
if (this.EnableSsl)
{
throw new SmtpException(SR.GetString(
"SmtpPickupDirectoryDoesnotSupportSsl"
));
}
goto
Label_021C;
default:
goto Label_022B;
}
MailWriter fileMailWriter =
this.GetFileMailWriter(
this.PickupDirectoryLocation);
goto
Label_025D;
Label_021C:
fileMailWriter = this.GetFileMailWriter(
IisPickupDirectory.GetPickupDirectory());

goto
Label_025D;
Label_022B:
this.GetConnection();
fileMailWriter =
this.transport.SendMail((message.Sender != null) ?
message.Sender : message.From, recipients,
message.BuildDeliveryStatusNotificationString(),
out exception);
Label_025D:
this.message = message;
message.Send(fileMailWriter,
this.DeliveryMethod != SmtpDeliveryMethod.Network);
fileMailWriter.Close();

this
.transport.ReleaseConnection();
if
((this.DeliveryMethod == SmtpDeliveryMethod.Network) && (exception != null))
{
throw exception;
}

I've always been taught to avoid goto like the plague, and it's something I've followed for years. I've never even considered it to be an option when writing code.

Thinking about it though, I did read an article a few years ago (which I can't find now) which said you could credibly use gotos only if you used it to jump down code, and not up: a rule that is stuck to here.

The thing is, I know this code can be written without using goto. But also, it might not be as readable as it is now.

I'm conflicted. But I'm sticking to the "no goto" rule until someone can come up with an example that really can't be coded without using a goto.

Sending SMS to a specific port using the Esendex API

I've written an Esendex Developers Blog entry describing how to send SMS to a specific port. It's quite technical, but we've had a few support cases raised about it in the last couple of weeks, so thought I'd write about it.

It's quite long as well, but I don't think I could make it be any shorter and still be meaningful.

Tuesday, October 09, 2007

Making logging output "interesting"

This slashdot article caught my interest last night: Logfiles Made Interesting with glTail. Basically a guy has written a Ruby on Rails program that parses Apache access logs and gives you a visual representation of them using OpenGL graphics.

The outcome of it looks pretty interesting, and it got me thinking about what else you can do. I'm wondering how we could visualise some log4net logging, maybe using the XNA framework to output the graphics.

So last night I coded up a simple UDP Socket listener, and made a mock application that logs out an XML event to a UDPAppender. I found it should be pretty simple to get the log events to an XNA application, and now I'm thinking how the logs that the Esendex system generates can be displayed in an interesting yet useful way.

I'll keep you posted if I do anything else.

Friday, October 05, 2007

Walkers Keywords from Google Analytics

Waiting through my lunch for an Orange conference call to continue I opened Google Analytics and checked up on who was getting to this blog. There's an unusually high proportion of people seemingly searching for Walkers crisps.

Some of the search keywords are:

  • the purpose of walkers crisps
  • internal customers at walkers crisps
  • what are walkers crisps called in walmart orlando
  • how do you make a packet of walkers crisps
  • how much fat is there in a pack of walkers
  • walkers crisp purpose of the business
  • walkers crisps labels
  • what is the main purpose of the packaging of walkers crisps

Also a couple of visits from what looks like an internal Walkers host name.

Seems to be a bit of a Walkers hub at the moment ;)

Batching Bulk SMS Submissions using the Esendex API

I've written a summary of how to submit batched messages using the Esendex APIs, which will help anyone having problems submitting large amounts of messages at once.

It's not code specific, but should point you in the right direction if you find that making many single submissions is giving you network errors.

Read this Esendex Developers Blog entry: Batching Bulk Submissions using the API for more information.

Thursday, October 04, 2007

Documenting assumptions with Debug.Assert

Another one from Greg Beech today: Document your assumptions with Debug.Assert instead of comments.

I've never used Debug.Assert, but after reading this post I'm trying it out today. The post makes some excellent points:

When writing methods people frequently make assumptions, such as that the internal state of the class is correct, or that the arguments passed into a private method are valid (because they should have been checked by the non-private method calling it)

[...]

[If these assumptions are wrong] the program will carry on regardless until it fails at some point in the future. And because you didn't trap the problem at the point where it became clear that something was already wrong (i.e. at the comment documenting the assumption) then it's much harder to work out where the problem really occurred because the failure itself could occur further down the line in a largely unrelated method.

[...]

So every time you find yourself making an assumption "I know this will be there", "this should be in that state", "the argument should not be null as the public method will have validated it", document it by using Debug.Assert rather than a comment. Then, if your assumption is incorrect, your application will come to a grinding halt at the point where the problem became apparent.

So I'm giving it a go. It can only help during development, and won't affect anything in production code as the Debug class will only compile in debug builds.

There are a few warnings in Greg's post about when not to use it, so make sure you read those before giving it a go.

Esendex Website Updated

The new style web site went live yesterday afternoon, with surprisingly (but reassuringly) few problems. It's early days yet, and I'm sure we'll get a few calls from people who can't find things in the new format, but it looks like the deployment has been successful.

I was in two minds about posting about this actually, because I've not done that much work on it. I've paired with Neil and Kevin on the odd task, but I think of the developers here I've probably done the least on it.

The new website contains various blogs (like for support, development, and the company as a whole), so please check those out. I've already posted to the development blog, summarising the inbound multipart message update I blogged about here recently.

Right, onto the next story.

Tuesday, October 02, 2007

Product Knowledge Vs Coding Ability

I stumbled across Greg Beech's blog a few days ago while browsing the MSDN Forums and my attention was drawn to this post: Is product knowledge more important than coding ability?

The post didn't turn out to be what I thought it was, but it was interesting reading none the less. I thought it would be a discussion about whether a developer's knowledge of their product was more important than their individual coding ability, but the "product knowledge" that the title refers to is knowledge of third party software your company uses.

Greg gives a good example where his team solves a difficult problem quickly through their knowledge of the products they are using, rather than with any dramatic improvement in coding skill.

But isn't knowledge of these products just one measure of your ability as a developer? Without knowing how to use a framework (and I mean "framework" in the broadest possible terms) a developer isn't going to be able to do much quickly.

For example, if I wish to send an email from a program I don't open a socket to a mail server and throw SMTP commands across the wire. I use something like the System.Net.Mail classes which contains everything I need.

I know I could implement my own SmtpClient. I have the coding ability to write the code that will do it, but it would be a waste of my time to do so.

Coding ability and product knowledge are just two of the many weapons in a developer's arsenal that need to be used at different times to solve different problems.

I'd say the ability to judge when to use each is the more important skill though.

Monday, October 01, 2007

Sumo TV Trailerdrome

Flicking around Sky Digital channels a few weeks ago I stumbled across Sumo TV's Trailerdrome on channel 144. There's no website for the programme itself, the only thing I've found is the Sky.com TV listings page that tells you when it's on:

Featuring the best of obscure film trailers, public information films and newsreels from the last 70 years, when life was more innocent. Or was it?

And it is obscure, but I found it disturbingly compulsive viewing. The only problem is that they seem to show the same trailers on different days.

Among the trailers and public service films I've seen:
  • a warning to young girls about "getting yourself in trouble", which contained absolutely no mention of pregnancy or sex, but ended with the girl being put into care for no other reason than being a single teenage mother
  • an animated educational film about how capitalism works, and why it makes America great
  • coverage of an "Economy Drive" from the 50s/60s, in which teenage drivers aim to follow a long street course using the least amount of fuel. I think the winner managed around 50 miles per gallon per ton.
  • a documentary on how to have dinner with your family. Apparently no one person should dominate the conversation, and the girls of the family must help their mother prepare the meal.
  • a short film about divorce, that only mentioned the word once, covered none of the legal side of actual proceedings, and which only really showed the beginning of a couple's relationship in which the woman said she could change the man to suit her own needs.
  • far too many more to list here.
One of the great things though is that there seems to be no real adverts for the duration of the programme, which runs for about two hours. There are actually adverts, but they are old ones from the 50s and 60s that clearly aren't on sale now. There's a crazy one for Heinz Pickles that features an old lady beating up the waiting staff in a restaurant because the pickle she was served wasn't good enough.

So if you find yourself channel surfing and you happen across something in black and white that usually has a very condescending voice over on top then you've probably stumbled across Trailerdrome. Give it a go, it's a laugh.

Thursday, September 27, 2007

Is ploughing like software development?

Jonathan's blogged about a quote from Joe Berkovitz seemingly comparing software development to agriculture: Is ploughing like software development?

While I too wonder at this strange analogy, development is sometimes like running on a ploughed field: requiring lots of energy, getting nowhere fast, and when you look back you've just made one hell of a mess. ;)

Wednesday, September 26, 2007

Visual Studio 2005 Automation Samples

Guess I should have looked at creating a Visual Studio plugin first rather than figuring out how to convert RTF to HTML. I might not need to do that judging by the description of one of the Visual Studio 2005 Automation Samples:

Generate HTML
This sample demonstrates how to take text from the editor window and build a HTML file using this text, including font and color syntax highlighting information.

Haven't downloaded this yet, but I will do. Sounds like the Blogger code upload plugin could be quite easy to implement.

I found this page linked from the Customize and Extend Visual Studio page on MSDN.

UPDATE: Ahh, the Generate HTML sample is actually in C++, not C#. Should still be able to use it as a guide though, just need to figure out what objects to use.

Nottingham isn't that far from New York then

Driving home yesterday was an experience to say the least. Where the ring road around Nottingham meets the A610 was the scene of chaos. So much chaos that I found myself laughing at it so I didn't get annoyed with the stupidity of the people involved.

The A610 heading out of Nottingham was grid-locked completely. So much so that when the traffic lights changed to red there was still traffic on the junction, and that traffic had nowhere to go. It effectively cut off the ring road.

Normally this isn't a problem, but I think there must have been something in the water yesterday. Horns were sounded, tyres screeched, cars swerved into oncoming traffic--I particularly liked the van driver who did a racing start when the ring road's lights went green, even though 10 feet in front of him was a line of traffic that could not go anywhere.

He slammed on the brakes and swerved into another lane, cutting up a car and resulting in more horns being sounded.

I didn't want to add to all of this mayhem, so I turned around and went home another way.

I always find it curious when people get angry over things that no one has any real control over, and which aren't particularly important anyway.

Tuesday, September 25, 2007

RTF to HTML and the GData API

Finally got around to properly extracting the RTF conversion code from AutoFormatter last night. It turned out to be as easy as I thought, after last time's wasted efforts. I've had a look on Robert Verpalen's blog for some contact details, but I can't find any and the AutoFormatter post doesn't seem to allow comments.

I might have to leave a comment on another one of his other posts, but the date on the AutoFormatter post is December 2005, so I don't know if he's maintaining it now. Doesn't seem to be any posts since then about the application anyway.

I think I'll wait until I have something usable first though.

Anyway, with that extracted I downloaded the GData API SDK and tried to connect to my blog. The sample code included is very helpful, but it still took a little time to get my head around. I eventually knocked up some code that would add a new draft to my blog, so I think I have everything I need to make the plugin now.

Now I just need to learn about how to make a decent plugin.

Comics Britannia on BBC4

I watched Comics Britannia on BBC4 last night, an episode that focused on more modern comics, ones which a parent probably wouldn't want a young child to read.

I'm not what you call a comic geek, but I've read a couple of the more "adult" orientated comics (and graphic novels), so I found last night's programme very interesting.

A pleasingly large section of the programme was devoted to Alan Moore. His V For Vendetta, Watchmen and Lost Girls (which is not one I'd recommend for the easily offended) are among my favourite books of all time, so it was interesting listening to the man himself talk about his creations.

I think I got into this series a bit too late, so I'm looking forward for a repeat showing sometime soon.

Friday, September 21, 2007

Trying to Extract Features from AutoFormatter

I took a look at the AutoFormatter code last night, and tried to make a start on extracting the code that does the conversion into a class library.

I can't say it was an easy task though, and at the end of it all I found I'd done it wrong anyway. What I really need is a class that just converts RTF to HTML, but I had extracted the method that creates the div blocks around the code as well. Surrounding the code in this way does make the end result nice and pretty, but for the purposes of a generic conversion library it's not needed.

It was about 11 o'clock last night when I figured this out. It's always a little disheartening when you find you've just spent the last 3 hours doing something that you now need to discard.

Guess that's what happens when you try to modify code without truely understanding it. I can't see any unit tests in the code to give an indication of the intention of some of the code, or to provide a safety net to the quite severe refactoring that I am attempting.

But I think extracting the RTF to HTML code should be easier than what I did last night. There were a number of options I needed to extract into a class and pass into the method last night, but I'm sure I don't need all of this for the straight conversion.

I'll see how it goes.

Thursday, September 20, 2007

Formatting Currency to Pence and Cents

Almost anyone will know how to format a decimal to a currency string. It's nice and easy to make a number like 1.25 format like £1.25, (or $1.25 if you're using a CultureInfo that has a dollar CurrencySymbol in its NumberFormatInfo.

But, say I have the decimal 0.06, and I want this to format to 6p. Or I might have 0.065 which I want to show as 6.5p.

How do I do that?

I understand I may need to multiply this decimal by 100 to get the whole number of pence, but how do I know which symbol to append? Plus, how do I know which end of the string the symbol needs to go?

There is nothing in a NumberFormatInfo that describes these things. The CurrencySymbol gives us our $, £, €, etc, but where's the pence and cents symbols?

Any ideas?

Right now we've got a workaround in place that works, but shouldn't this be a part of the NumberFormatInfo?

I've posted a question on the MSDN Forums about this.

UPDATE: Kevin posted a question on the MSDN Forums for this as well, and got a more satisfactory answer than I did.

Read that post here.

Wednesday, September 19, 2007

RTF to HTML: AutoFormatter 2.0

Visual Studio copies code from the editor in RTF format, so technically all you need to do is convert RTF to HTML in order to upload it to a blog post, which will form part of the plugin, if I ever get around to making it.

Looking around last night I found AutoFormatter 2.0. This is a .Net 2.0 application written in C# that does a neat job of doing exactly what I need. The HTML it produces is in a scrolling DIV, formatted in Visual Studio colours, and looks quite nice.

In fact, as a standalone application this is just what I need to post code samples, but I started down this path to try the GData API with a Visual Studio plugin. I'm hoping to use part of AutoFormatter to do it though.

If I can extract the conversion code from the AutoFormatter app into a standalone assembly, then theoretically I should be able to use it from the plugin. The code is available for download, and I made a start at extracting the required elements last night. If I can get this working then that's a big chunk of the work done I think.

I'll get in touch with AutoFormatter's author if I manage to get the core functionality extracted to a separate assembly. Hope he doesn't mind.

Creating Visual Studio Plugins

This is more of a reminder to myself than anything else: Exploring Extensibility: Your First Visual Studio Add-in.

I found it at about the same time I was looking into the GData API, and I had an idea about creating a plugin to Visual Studio which would allow you to upload a code snippet to a blog post, and have it fully formatted so it was readable.

Still might do it, but I'm not sure how indepth the wizard approach will be. I'll probably end up with a standalone application that you paste code into and then upload it.

What's the carbon footprint of a potato?

BBC News is running an article about the carbon footprint of Walkers Crisps: What's the carbon footprint of a potato?

Seemed like a rather spurious thing to blog about at the time.

Configure an Assembly in .Net 2.0

Found this article for an example on redirecting an assembly's version via the App.config file. In .Net 1.1 it was easy to do this as there was a GUI to let you redirect all version bindings to a different version. You still get this GUI if you have the .Net 2.0 SDK installed, but you don't get it with the .Net 2.0 Redistributable.

This way you only redirect specific applications rather than your entire system.

Monday, September 17, 2007

Using UDP in XNA

I've had an anonymous comment left on a UdpClient post asking if I have used the UdpClient in an XNA game. Well, no I haven't--and to be honest I've not used the class much in anything else either. In fact that previous blog entry was posted after pairing with Nick on a bespoke application for a customer of ours.

But, the question got me thinking about it anyway. The comment says that they have a piece of code using the UdpClient that works in a normal .Net application, but when included in an XNA game, it no longer receives anything.

Now, I can't see why this would be the case if you are compiling to a Windows game. A Windows game is just running on the standard .Net framework, so everything should be OK. However, XBOX 360 games will run on a variation of the .Net Compact Framework, so there is a difference there to be aware of.

So assuming you're making a Windows game, why should the UdpClient now not work? Well to start I made a normal console application with the code snippet posted in the comment, and tried to get that to work. I made a separate console application to use as the sender.

And that's when the problem struck--one which I should have seen at first glance anyway. If you try to have multiple applications on the same computer accessing the same port using UdpClient you will get an exception that says "Only one usage of each socket address (protocol/network address/port) is normally permitted". (Read this article for a bit more information).

The only way we've found to stop this happening is to not use UdpClient at all, but to create Sockets yourself and use those instead.

However, I thought there must be an easier way--someone must have solved this problem before. And it looks like someone has.

I've not had a look at it in much depth, but if you want to send and receive UDP packets in XNA then take a look at the lidgren-library-network, which is on Google Code.

I don't know whether this uses UdpClient under the hood or not, but it has an XNA extension for sending Vectors and Matrices so it must have been used in some XNA games somewhere along the line.

Check it out and see if it helps.

Ajax onreadystatechange Arguments

Having not used Ajax that much I was surprised to see that the function you declare for the onreadystatechange event could not take any arguments. I thought that this was a bit of a limitation as it meant that if you wanted that function to use any external data you had to declare that data globally, which has always been a big no-no in my book.

Global data when it's not needed always leads to a lot of pain in my experience.

But despair not, there is a way to pass arguments in. As Javascript supports anonymous methods you can create a new method inline, and then call another function from there--one that does have the arguments.

Take a look at this article if you're still stuck.

A Day For Winning

I got back from a week's holiday this morning to find that I had not only won Esendex's new strapline competition, but I've also taken the spot prize in the Esendex fantasy football mini league.

Maybe I should go and buy a lottery ticket ;)

Friday, September 07, 2007

How C# 3.0 and LINQ Evolved

Starting Visual Studio today the Start Page's MSDN feed pointed to this article: C# 3.0: The Evolution Of LINQ And Its Impact On The Design Of C#.

It describes the separate language additions that were required to make LINQ work, and is well worth a read in my opinion.

Having been introduced to C# and LINQ at Tech Ed earlier this year I'm itching to try some of it out when I get the chance.

My Internet is back

I've now got a new cable modem, and things are eventually beginning to look up on the internet connectivity front. I'd had that modem since about 2004, and the engineer thought it was time to get a new one.

It's much smaller than the old one. We'll see how it goes on the reliability front.

Tuesday, September 04, 2007

Internet Problems Update

Apparently my internet provider think the connection problems are because my modem is broken, and they are sending an engineer around with a replacement on Thursday afternoon.

We'll see if this fixes the problem.

Essential SQL Server Date, Time and DateTime Functions

Just found this article on Essential SQL Server Date, Time and DateTime Functions. Has some handy functions you can add to get the following:

  • Get just the date part of a DateTime value
  • Get the time part of a DateTime value
  • Create a DateTime value with explicit Day, Month, Year, Hour Minute and Second parts
  • Create just a time value (with the date section set to a 'base' date)

Angry with No Internet

I had a plan to play with the Google Blogger API last night in order to write an application that would allow me to upload code samples to this blog more easily than at present, but as I got home my internet connection was down yet again.

I won't name the company in question, but I connect to the internet at home through a well known supplier here in the UK, but just recently the levels of service I've been receiving have been shocking. I'm having to reboot the cable modem on a daily basis whereas before a few weeks ago I rarely, if ever, had to do this.

And it appeared that last night was going to be the same. Switched on the laptop, watched AVG try (and fail) to update itself, followed by the GMail Notifier's exclamation mark proclaiming it couldn't establish a connection. So off I trudged, yet again, to unplug the cable modem. Wait two minutes. Switch cable modem back on. Off I trudged back to my laptop.

Still no connection.

Sigh. Unplug cable modem again. Wait 10 minutes this time. Switch back on. And nothing.

So I phone their customer services number, only to be told I must pay a 10p connection fee, and then it would be a 25p a minute phone call... How can any company think it's a good idea to charge premium rates for requesting help? This is worse than the company who demand payment to fix bugs in their software! It wouldn't be so bad except this company is notorious for leaving you on hold for at least 20-30 minutes.

Gritting my teeth I resorted to emailing them... but can I find an email address to send to? No. I looked back through the recent bills for one, but there's nothing there.

I pulled out the emergency DKU-2 cable I have and connected my Nokia 6230i to my laptop. Nokia PC Suite allows you to connect to the internet over your mobile phone, so I connected and went to the offending company's website. The only thing I could find was a General Enquiries email form--and I'm pretty sure that won't be monitored out of office hours.

So, no service, no free help on the phone, and seemingly no way of requesting help through email.

I think it's about time I switched suppliers.

Monday, September 03, 2007

Calling all drivers (in the UK at least)

Try out the BBC's Highway Code Quiz.

I'm not going to gloat over my 10 out of 10 score though, the questions didn't seem too difficult.

Friday, August 31, 2007

Component Services Hanging When Connecting to Other Computers

The Component Services application under Administrative Tools allows you manage the COM+ applications on different computers on your network. This is done by adding the computer to a list--a list which is then saved for the next time you open the application.

While this means you don't need to keep adding a computer, it also causes the application to hang if a computer in the list no longer exists.

If you have a computer in Component Services that no longer exists, you can make the application usable again by following these steps:

  1. Open Component Services on the affected computer
  2. Drop down into the Computers directory from the Component Services node
  3. Make a note of the computer names in this list (apart from My Computer)
  4. Close Component Services (you may need to kill the application from Task Manager)
  5. Get the local IP address of another computer on your network that the affected computer can access
  6. Open the hosts file in a text editor (the file can be found in \System32\drivers\etc\
  7. Add entries for each computer name you noted, assigning the IP address from Step 5
  8. Save the file
  9. Reopen Component Service and drop down to the computers list
  10. You may have to give it a few minutes, but now you should be able to select the other computers in the list and remove them
  11. Edit the hosts file again to remove the entries you've added
Follow these steps and you should be able to get Component Services back in working order again.

Thursday, August 30, 2007

How to Complain

Partially inspired by Adam's Premium Rate SMS Abuse post, I thought I'd republish a post I made a few months back on a different blog about how to complain. It doesn't fit in completely with the exact situation Adam discusses, but I feel there's a couple of things that are still relevant:

We all have to complain at some point. Some people feel the need to complain more than most, but sometimes something will happen that we have every right to complain about. When that time comes it can often be frustrating even finding the person to complain to, so when you actually get to talk to someone tempers can already be frayed.

I've been working with software for a number of years now, so I've been on the receiving end of a fair few complaints. These have ranged from the perfectly calm, reasonable complaint over something that genuinely is a problem, to an angry, swearing marathon yelled down the phone at you as if you were some troublesome infant. So I thought I would be in a position to share what makes a good complaint that can be resolved quickly.

1. Make sure you actually have a problem

Just because what you have isn't doing what you want it to do, doesn't mean it is not capable of doing it. OK, you might have a problem with the usability of the product, but make sure you make that clear when you complain.

2. Make sure you can reproduce the problem

Inconsistent error reports make it very difficult to track down problems. If you can consistently cause an error by performing a set number of steps, then chances are the people trying to fix your problem will be able to as well. Reproducing the problem in a controlled environment is the first step towards resolving a problem.

3. Be clear about what is wrong

The chances are that the people looking at your problem will have a dozen or so other things to do at the same time. Their time is better served fixing problems than deciphering what problem you are having.

What were you doing before the problem? What version of the software are you using? What data had you entered in? Have you been able to perform these steps before? If yes: has anything changed with your own system since that time? Do you have a customer reference that you can give so I can look at your call history?

If you don't include answers to at least some of these questions in your initial report the people looking at your problem will just have to ask. This takes time, especially if you are difficult to get in touch with. This time could have been spent looking into why your problem was happening, if you had just provided a little more information into what problem you actually have.

4 For God's sake, just be polite!

Chances are that if you have a problem, you're not going to be too happy about it. It's stopping you working in some way, otherwise it wouldn't be a problem.

However angry or upset you are, take a few deep breaths and count to 10 before lifting up the phone and yelling at someone. You'll be more concise when you're calm--people are more likely to help you when you are calm.

Yes the person you speak to is probably being paid to help you, but that doesn't mean they have to like doing it. If you are rude and aggressive the only thing they will want to do is get you off the phone. They will tell you how you can fix the problem quickly, but this might not always solve the root cause of the problem. Yes, they are being paid to help you, but they are not your slaves/pets/children. They are still human beings with feelings that deserve to be respected.

If you're calm and polite and raise an issue, you may get that same quick fix to get you on your way, but you're also more likely to remain in memory. And who knows, maybe they'll pro actively let you know of better ways of solving the problem later. Maybe they'll even thank you for highlighting an error they'd missed.

You don't have to believe in karma to see that what goes around comes around. If you're polite to them, then they will repay that by being polite to you.

5. ...and shut up and listen to them!

This might seem obvious, but too many times people just don't listen to the help they are given. Make sure you don't fall into this category.

You might think you know what is causing the problem, and by all means offer this to them, as long as you are polite about it. But if this doesn't turn out to be the issue, then don't cling to what you think is right! Customer support does actually look into problems! They wouldn't tell you something different if it wasn't true!

Listen to them, and understand what you are told. Don't be too proud to say if you haven't understood. They should be able to tell you again using concepts you're familiar with. If you still can't understand then get them to write it down so you can forward it to someone who might.

You don't want to have to call them again with the same problem do you?

6 Understand that calls are prioritised

Your problem may be bugging you a lot, but if you are able to work around it, then your problem will be put lower in the pile of outstanding calls. No company has the man-power to answer every support call it receives immediately, and critical problems will always be investigated first.

If your problem is that you don't like that you can't change the order of some data in the application you are using, then this will fall behind a call from another company for which the application doesn't work at all.

All customers are important, and all customer support calls deserve to be answered promptly. But understand that not all calls can be solved immediately, so don't get angry and think you've been forgotten. The company that you are dealing with does value your custom and your call, but you have to understand that you are not their only customer, and occasionally other customers' calls need to be dealt with before yours.

Surefire Money Maker

Anyone who has written a non-trivial piece of software will be aware that the occasional bug is inevitable. Unit and acceptance testing, and a QA process can limit the number of bugs that can creep out into the wild, but there will always be the odd bug out there.

If a company releases a piece of software that stops customers working, it is up to that company to put it right as soon as possible.

I was talking to a friend this week who tells me that not all software companies follow this rule. He's a software developer too, and (as I understand it) most of his work is dependant on a piece of software provided by another company.

He found a bug with this piece of software that caused it to be pretty unusable, so filed a bug report, only to be told he must pay to have this bug fixed.

How about that? A company has released a defective piece of software to a paying customer, and then told that customer they must pay an additional charge to get it working properly.

Talk about a guaranteed money maker.

I suppose this is where the software's licence agreement comes in, which usually has a clause saying something like "we make no guarantee that this software will do anything you need it to, including the purpose we sold it to you for".

Wednesday, August 29, 2007

Potential Breaking Change For API Customers

We are currently working on reassembling multipart inbound messages before they are placed into inboxes, which has the effect of increasing the maximum length of an inbound message from 160 to a purely theoretical 38,862 characters.

Esendex customers who use the API to receive inbound messages and have restricted their systems to the current 160 maximum will need to increase their current restrictions.

Read more here.

Esendex Inbound Multipart Messaging Update

Most people who use SMS will know that a standard SMS message is limited to 160 characters (using a standard 7-bit character set). But most people will also know that mobile phones are capable of sending a message of more than this.

The phone does it by splitting the message into parts, and placing a header on each part that describes:


  • how many total parts there are in the message

  • which part this current segment is

  • a reference so parts from different messages don't get mixed up


Esendex's outbound service has supported sending these long messages for more than a year, but at the moment we treat inbound message parts as separate messages.

We're currently working on an update that will cause these message parts to be reassembled into one message, so all parts (or however many parts we actually receive) will be displayed as 1 message in the Inbox.

So what is this going to affect? Well, if you use the website to view your inbox, or have your messages emailed to you, then this won't affect you at all--all you will see is a longer than usual message if a multipart message is sent to your account.

However, if you have written an application that retrieves your messages from your Inbox, or which receives direct messages through the Application Notification service, then this could potentially be a breaking change.

If you are expecting a message to be a maximum of 160 characters, you will need to modify your code and/or database tables to accept messages longer than this. If you need to apply a maximum length, then the limit of 1 Esendex inbound message will now be based on the total characters in the maximum number of parts allowed by the specification.

The maximum number of parts is stored in an unsigned byte starting at 1, which gives a potential for 254 parts(!). Each part can have 153 characters, which gives a technical maximum of 38,862 characters in an inbound message.

However, I seriously doubt any provider or phone manufacturer will allow anyone to send a 254 part message. I certainly know that phones have their own limits on the number of parts a handset can send.

As an example Esendex's outbound service limits you to sending 4 message parts, or a total of 612 characters.

A maximum of something like 1000 characters should probably handle most cases, but the potential is there for 10s of thousands of characters under the right circumstances.

This update is currently in development and will hopefully be going live in September sometime. I've been told an email will be sent around to API customers giving an official announcement, but you can get a head start on any changes you need to make right now.

Wednesday, August 22, 2007

Enable Internal System.Net Logging

Having trouble with certificates while requesting information using HttpWebRequest, manifesting itself with the error "Could not create SSL/TLS secure channel". As far as we could tell the certificate should have been ok.

To diagnose the problem I found this great blog post to enable the internal logging from the System.Net classes by Durgaprasad Gorti over at the MSDN Blogs.

Just needs a new section in the app.Config file to log out what the System.Net classes are doing. One of the samples in the blog post worked straight off for me:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
    <system.diagnostics>
        <trace autoflush="true" />
            <sources>
                <source name="System.Net" maxdatasize="1024">
                    <listeners>
                        <add name="MyTraceFile"/>
                    </listeners>
                </source>
              <source name="System.Net.Sockets" maxdatasize="1024">
                    <listeners>
                        <add name="MyTraceFile"/>
                    </listeners>
                </source>  
           </sources>



            <sharedListeners>
                <add
                  name="MyTraceFile"
                  type="System.Diagnostics.TextWriterTraceListener"
                  initializeData="System.Net.trace.log"
                />
            </sharedListeners>
            <switches>
                <add name="System.Net" value="Verbose" />
              <add name="System.Net.Sockets" value="Verbose" />
            </switches>
    </system.diagnostics>
</configuration>


It creates a file called System.Net.trace.log in the directory where the EXE is running. The logging is very comprehensive and will point you in the right direction for fixing your problems.

Monday, August 20, 2007

Ohh.. Polls

Maybe I'm behind the times a bit with this, but I've found you can add polls to your BlogSpot blogs. They're a page element you can add from the Template tab. I'm sure it wasn't there the last time I looked.

Blog Rethink

I grow tired of maintaining two blogs so I've decided to scrap my personal blog.

I'm keeping the blog you're reading now since it gets more traffic and has external links to it. But I've renamed it as my personal blog instead of Development Blog.

There'll be no changes in the address though, so the only thing you may notice is the odd post that isn't about software development--something that's been happening lately anyway.

Jeremy Vine Steps Up

The BBC News article Unmitigated ferocity, here I come caught my eye during my lunchtime news fix. In it Jeremy Vine talks about an incident he witnessed on the tube in which a man harassed a female passenger while the rest of the carriage looked on. As the man left, and the doors closed, another passenger flicked two fingers at him, only for the man to return and beat up the passenger when the doors happened to reopen.

This type of violence is now getting more common in most of the large towns and cities in Britain, and people lucky enough to have not experienced it first hand will probably think that they would not sit idly by and be a silent witness to it.

The reality, as Vine states, is quite different. As a nation we are relatively introverted and most people just want to get on with their day and not get involved. Plus there's the additional risks of getting the beating yourself, or being charged with assault if you happen to succeed in placating the thug.

As someone who has been on the receiving end of such violence the article struck a particular chord with me.

After a night out with friends I sat on the last bus home opposite two men (one older than the other) flanking a young woman looking very worse for wear and with no shoes on. I remember asking the older man (who was already glaring at me) if she was ok with no shoes on. For my trouble I got a stream of obscenities, but worse was to come when the bus approached my stop.

All three followed me from the bus and started kicking and punching until I managed to push past the shoeless girl and get away. Luckily they didn't pursue, as I was bleeding from my head and spent the rest of the night in Kings Mill Hospital.

Calling an ambulance for an assault led to a police report being filed for an ABH, and although I went through a number of mugshots and indicated a couple of potentials, nothing else has happened. Apparently the CCTV on the bus was not working on that night.

In hindsight I would have loved to have turned the violence back on them, but at the time all I could think was "This hurts, I need to get away", rather than "This hurts, I need to hurt them too". I suspect that this is the thought most people would have given a similar situation.

I would have liked for someone to help as Vine says he will do from now on, but I understood then as I do now the risks that someone else would be taking on my behalf. It's OK standing up to verbal abuse as he did on the bus, but wading into a fistfight is something else entirely.

I know I won't be physically fighting for a stranger any time soon, I prefer to keep my head down to avoid such confrontations in the first place. But I do admit that it is this mindset that is partially responsible for the violence we see now on almost a daily basis in the news.

Vine is right, by doing nothing we give the thugs permission to carry on as they are. But members of the public aren't the right people to be stopping such violence. Police do wade in and break up these fights when they happen late at night in the city centres, but who will stop the violence elsewhere?

TransactionScope Stumbling Block

I returned to work this morning after a week's holiday to discover that all was not well in the TransactionScope camp. A certain four letter word that I won't repeat here sprang immediately to mind.

Luckily, tests had highlighted the problem before this went live, but the setback is disappointing at best and for me it's personally infuriating as I was the person who suggested it and took the lead in its development.

I've not had chance to look in a great depth at what the team investigated during my absence, but there might be a light at the end of the tunnel. The articles Nicholas has linked to (articles 1, 2 and 3 for your convenience) certainly suggests a reason to the problems we are seeing, but they might not be the root cause of the particular problems that the tests highlighted.

I mocked up an application involving instantiating two SqlConnection objects enlisting in the same TransactionScope weeks ago, prior to even suggesting we implement the pattern fully, and saw no problems with it.

Could this problem be purely down to a long running transaction timing out?

In Nick's words: To be continued...

Thursday, August 09, 2007

Problems Rotating Models in XNA

After finding Blender I've created some simple cubes and exported them into an XNA project. I want to rotate these after receiving input from the GamePad (although currently I'm testing with the Keyboard).

The idea that I have calls for the cubes to be rotated 90 degrees after a button press. The camera isn't moving, so having a cube rotate in this way means that the cube will always be displaying a full face.

I've figured out how to rotate, but as soon as I rotate around more than 1 axis I have to consider which direction the cube is facing to determine which direction I should rotate based on the next button press.

The cube needs to rotate up and down, and left and right, and the buttons to do this should be the same regardless of the cube's current orientation. My initial simple hamfisted attempt at rotating didn't take this into account. So if I rotated left and then pressed the button to rotate up, the model twists clockwise.

I rather stupidly failed to realise that the rotations are being done in relation to the model. Hindsight tells me how stupid I am for not realising this--how difficult would model movement and rotation be if everything was done in relation to the camera or an absolute point?

But now I know this it's got me wondering how I can achieve what I need. I suspect I need to store the current orientation of the cube, and then based on this determine which way is up so I can rotate accordingly.

Anyone have any experience of rotating models in this way?

XNA Arcade

Over at Ziggyware XNA News there's a post about XNA Arcade.

Kyle Schouviller's created the application to allow people to easily distribute their XNA games.

Haven't checked it out yet, and it is still in it's alpha stage, but the concept certainly sounds interesting.

Check out the application here.