Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Thursday, November 16, 2006

Nots and Ands

Don’t you just love programming!

If Not (AppSettings("ProxyServer").Equals("")) And (AppSettings("ProxyPort").Equals("")) Then
req.Proxy = GetProxy()
End If


The not doesn't make any difference if both values are empty strings! It should be:


If Not (AppSettings("ProxyServer").Equals("") And AppSettings("ProxyPort").Equals("")) Then
req.Proxy = GetProxy()
End If


Spot the difference!


I reckon there ought to be an easier way to express this concept and I'm sure that 'not/and' 'not/or' structures like this cause lots of bugs. Perhaps new operators, something like this would help:

all({list of values}) {single value to compare against}
any({list of values}) {single value to compare against}


(both returning a boolean)

So to back to the example, to only set proxy settings if both port and server settings exist, we'd have

If all(AppSettings("ProxyServer").length, AppSettings("ProxyPort").length) > 0 Then
req.Proxy = GetProxy()
End If


I'll see if can code, all and any in c#...

Wednesday, July 12, 2006

Bad Software.

Why it is so hard to make great software. I've been talking with a colleague at work over numerous lunchtimes about this...

What I've come to the conclusion of is:
BAD + GOOD = BAD + 1 with a lot of time, effort and frustration getting there
BAD + BAD = BAD

So I've come to realise that unless you (and those that you work with) refuse to take the tempting shortcuts and turn your back on the desire to implement a quick hack just to get it done, then it is questionable whether it is worth trying to make something that is already a mess just slightly less of a mess?

Unless it is your explicit aim to make the jump from BAD to GOOD then you are probably better off just getting the job done (quickly) and not worrying too much about how bad everything is. Otherwise what will happen:
Will you will have spent more time than expected, and therefore look less productive?
Will the changes that you've made be noticed or even appreciated by anyone?
How long before someone else makes another change and undoes all your 'GOOD' work, especially if not everyone in the team aspires to make things GOOD.

This is a slighly self-defeatist argument and I would appreciate the views and opinions of others on this.