Sunday 21 December 2008

Terminology: Ensure

What's in a name? Well, quite a lot actually. At best, a poorly chosen name gives little or no insight into the nature of thing it is naming, and at worst the name can be misleading and actually send you down the wrong path entirely. Conversely, well chosen names can convey the meaning, and intent for a variable, method or project.

There's plenty of literature available on the topic, so I'm not going to belabour the point any more, other than to give a couple of examples of names that I try to use consistently in my projects. I'll add other examples as and when I remember them!

The first, I've already mentioned in a previous post, and that name is "Scaffold". To me, it means "something I've put up as a temporary structure, that isn't intended to be there when the final product is released".

The second name is used when I want to get a reference to something that may not have been created yet.

If I was going to create a foo object, I'd probably use "CreateFoo". But I can't use "Create" because the object might already exist.

If I was going to retrieve a foo object, I might use "GetFoo". But again, I can't use "Get" because the object might not have been created yet.

So the term I use in this situation is "Ensure". I think "EnsureFoo" conveys the meaning and is distinct from "Create" and "Get", and doesn't mislead.

Saturday 20 December 2008

Delete the font

Originally, I could read every website that was thrown at me.

Then, ClearType arrived, and I had the option of "improving" the readability on my LCD screen. I tried ClearType and decided I prefered my text without ClearType, so turned it off. Things were still fine.

But then, sites started using fonts that seemed to rely on ClearType to be clear enough to read. The fonts I struggled with were mainly Calibri, Segoe and Vera.

(I won't bother posting screenshots, because you won't be able to see them as they appear on my monitor.)

I tried to find ways to disable certain fonts on websites, replace font X for Y, make a global stylesheet change, but in the end, I found the way to make readable the sites that use those fonts, was simply to delete the fonts that I struggled to read. :)

Thursday 18 December 2008

Ideas

I wonder if there's a website where you can post your ideas for coding projects. I had a (very) brief search, but didn't find anything so far.

Various software ideas pop into my head from time to time.

Here's one of them:

Connecting people via a database correlating hobbies with people.

By chance I found out that a colleague read some of the same books as me - we had a bit of a chat about the books and it made a nice change to talking about work. I wondered how many other colleagues read the same books as me. So originally the database idea was just for work. Then I thought it could easily be expanded to allow people in local neighourhoods to find people with similar interests. Then I thought it could easily be expanded to be a global database.

The trouble would be getting people interested enough to fill in their details. Writing the database and the interface would be easy by comparison!

Wednesday 17 December 2008

More Customizations

Two more customizations - this time relating to the system notification area.

When working on a new PC, sooner or later I end up installing 4t Tray Minimizer. I like to keep a clear taskbar, so if I have several programs open at once, and I'm not actively working on something, but don't want to close it, I can right-click the minimize button and it turns into an icon in the system notification area.

Secondly, when I have too many icons in the notification area, I like to decide which icons don't need to be there at all. For the trial period, I had PS Tray Factory installed, which mostly did what I expected of it, though it did seem to forget my settings from time to time (although that could have been one of the trial limitations).

I'd quite like to have a go at writing my own program that manipulates the icons in the notification area. When I have time. One day. :)

Tuesday 16 December 2008

Conversation Context

Why are mobile phones so distracting to the point where over 30 countries have made it illegal to drive while operating a mobile phone. If having a conversation with someone over the phone is so distracting, why isn't it illegal to chat to a passenger in your car?

In England, at least, it's legal to use a mobile phone while driving, as long as you are operating the phone "hands-free". Personally, however, I wouldn't feel safe operating a mobile phone while driving, regardless of whether or not I could use the phone and keep both hands on the wheel.

The reason is to do with context, and it doesn't just apply to using a mobile phone in a car - I have the same issue with landlines and three-way-conversations involving somebody in the room with me.

The trouble is, in both examples, I'm the piggy-in-the-middle, but neither of the other "players" communicates with each other directly.

In the landline example, the other players are obviously the person on the other end of the line and the person in the same room as me. In the mobile example, one player is the person on the mobile, while the other player is the environment in which I'm driving my car.

If somebody was sat in the car with me, and the lights turned green, they could see that I was concentrating and hang fire with the conversation until they could see that there was less demand for my attention. But the person on the other end of the mobile can't see the road, and know when to pause, so will carry on talking and distracting me, without realising.

I'm sure there's an analogy to programming here, but for the life of me I can't see it... :-S

Monday 15 December 2008

Scaffold

Ever find yourself commenting out lines of code, or adding dummy values, or setting up variables just to test something, then once the test has finished, going back through your code removing the comments, commenting out the dummy values and changing the variables back? And then repeating that sequence when you find that you hadn't actually finished testing?

I do.

Steve McConnell calls this code "scaffolding code".

I also have a tendency to forget to remove this code once I've fixed my bug or finished my test. So I've gotten into the habit of marking the change with a comment similar to

// Scaffold: added dummy value
int dummy = 3;


Sometimes my scaffold comments get lost among a sea of other code, and I forget to remove it. So to group it together, I've started using a single scaffold file / class. That way there's only one place to look for the scaffold code.

That's still susceptible to me forgetting about the scaffold before publishing my program, so I think the next step might be to create a user defined scaffold file that can be edited and stored locally, so even if I turn on all my scaffold constructs, nobody else sees them.