Sunday, March 25, 2007

repeating myself

I want to repeat the contents of this post, but that would be breaking rule #1.

Seriously, I am amazed that there isn't a ruler poised above the knuckles of every developer that raps down whenever they duplicate code. Naughty, naughty, naughty.

Code Camp!

It's less than a week to Code Camp 2007. I'm really looking forward to this years event.

I have been to the last two and really enjoyed myself. If you thinking of going, then I recommend that you do.

Hope to see you there.

Wednesday, March 21, 2007

why pipelining? (response to Andreas)

Andreas added a comment to about this post.

The question was why would you pipeline?

Perhaps a definition is in order - I define this as encapsulating the conditional call check inside the function to:
- reduce duplication of code
- to remove the possibility that the check is not made before the function is called and
- ensure that the function is only executed when appropriate

I noted that this was different to Design by Contract (DbC), as in DbC if you fail the preconditions, then the application will throw an exception.

Consider this code, without Pipelining:

public partial class Form1 : Form
public Form1()

private void OKButton_Click(object sender, EventArgs e)
string cleanText = string.Empty;
if (removeCheckbox.Checked)
cleanText = ReplaceUnderscoresWithSpaces(sampleTextBox.Text);

System.Windows.Forms.MessageBox.Show(string.Format("Cleaned text: {0}", cleanText));

private string ReplaceUnderscoresWithSpaces(string p)
return (p.Replace("_", " "));

This, rewritten with pipelining would be as follows:

public partial class Form1 : Form
public Form1()

private void OKButton_Click(object sender, EventArgs e)
string cleanText = ReplaceUnderscoresWithSpaces(sampleTextBox.Text, removeCheckbox.checked);

System.Windows.Forms.MessageBox.Show(string.Format("Cleaned text: {0}", cleanText));

private string ReplaceUnderscoresWithSpaces(string p, bool execute)
string temp = p;
if (execute)
temp = p.Replace("_", " ");

return (temp);

(Changes in bold)

Now, forgetting the simplicity of this example (and some of the other minor issues), it shows that:
- the function identifies what it needs to execute,
- the conditional is inside the function, not dispersed throughout the code
- there is less complexity in the calling code
- the conditions of execution are in the function

But this technique is only useful for functions that do not have a side effect if they are not executed. I only do this when it's necessary to do so. But it's still a nice technique to remove duplication and clean up the calling code.

Monday, March 19, 2007

Code Complete, Second Edition

I've posted about this book before.

I bring it up because a colleague asked me about it, or I mentioned it, I can't remember - it doesn't really matter.

He said that he'd been told it was a good read.

I absolutely recommend this book to everyone in the software development industry.

It's a fantastic grounding on lots of topics that developers and others may not have considered.

There's two things I must say about this book:
1. It will take a while - stick with it.
2. Read it and then move on. As I said - it's a great grounding, but you need to keep reading other books after this one. It's just a good one to have read, or be going to read.

Patterns of Enterprise Architecture

I finished "Patterns of Enterprise Architecture" yesterday. It's very good and definitely worth a read.

I know, most don't read these kind of books cover to cover, but I like to amass all of the knowledge I can, in the hope that a little sticks so the next time I see an issue or an opportunity, I have more options...

Which book next, I hear you ask? Well, I'm 24.4% through "Agile Software Development - Principles, Patterns and Practices". This is a great book, bringing together lots of Agile and programming concepts into one place. I'm really enjoying this one.

Saturday, March 17, 2007

reply to start choppin

My last post got two comments! So far, that's the best ever. (Pity one was deleted.)

But I'm not sure that I didn't cause confusion. Sorry.

To clarify, I was talking about programming languages. Not written languages.

If you read Start Choppin's comment you'll see what can happen without capitalisation in English. (Superb example, by the way.)

Careful, I've entered rant mode now...

I cannot think of a good reason to have case sensitivity in any programming language. If you have a good reason, then please let me know.

Rant mode off.

One reason I was given today was that the developer wanted to name the variable the same as the class, but only differ in case. For example (in C# syntax):

Link link;

Where Link was the class name and link is the name of the variable.

OK, seems a sensible reason. Except that it's bad form to name your variable the same as the class. Why, let's just say one word. Confusion. Much Better to name it something appropriate:

Link nextPageLink;

We can't have descriptive programming! No, that's toooo sensible.

But if this is your only argument for case sensitivity and you must call your variables the same as the class, then why can't the compiler know what you're referring to based upon it's context. Even VB6 could handle this.

And, the real point of my post was that we do things in software development that make it harder than it needs to be. Case sensitivity is just one example.

Another would be choosing to use an Object Orientated database instead of a relational database. (Can't wait to see the comments about that statement!)

Thursday, March 15, 2007

stupid, stupid, stiupid!

I will never understand the need of case sensitivity in a language.

I'm sure that because C had it, everyone else who thinks that their "serious" language must have it as well.

I refuse to like having something in a language/application that enables me to make mistakes and have it next to impossible to notice.

Stupid, stupid, stupid!

Sunday, March 11, 2007

back of my t-shirt

I've ordered a t-shirt for Code Camp Oz, 2007.

On the back I've put something that's a bit obscure. Those that know me will know that that's exactly me favourite kind of joke.

So, if you see me and don't understand it, then check out this link.

Sunday, March 04, 2007


I posted here about the lack of a particular feature in VS 2005. Turns out that it's already there, but turned off by default. (Thanks Rory for pointing it out!)

I'm not sure why - everyone I've talked to about this thought it should be turned on by default.

I was going to crack open the IDE extensibility area to add it myself, but it's already done.

I wonder how many other useful features are "hidden" in VS 2005/TFS?