When you see the following numeric characters written down what do you think?

1234

One thousand two hundred and thirty-four. Right?

Probably, yes, the context is likely to be base-10, but what if it was hex?

0×1234

What is that value? In decimal it’s 4660.

The first four years of my career involved a lot of interaction with individual bits and bytes, which were being transmitted over serial port protocols. (one such example was. Modbus).

It was fun. It felt like proper programming.

Over the next decade, hardly anything at all like this came my way. And in those years, without realising, I’d lost a skill – The feeling for binary and hexadecimal numbers and how they translated to the comfortable decimal numbers with which we are all so familiar.

So, recently I was thrown into a project which involved translating the bytes coming from a serial port to a series of fields in a class. It wasn’t too taxing, but it was hindered by the fact that I had think about the conversions. It made me realise that this stuff can actually be quite useful.

Like a linguistic skill, it’s often better to learn to think in terms of the domain in which you are conversing. The best linguists, when communicating in German will think in German, rather than translating from their native language.

But my experience is that we often need to translate between these domains. Simply thinking in of that domain isn’t enough.

I’m not saying that you should be able to look at a hex value 2f5a109888aedfbc1, or a binary value of 00101010110100101010101010 and know instantly what decimal value it is. I’m suggesting that up to a sensible exponent of 2, you should have a feeling for the equivalent decimal and hex representation (the binary one follows directly from the exponent).

2^ Binary Hex Decimal
1 10 2 2
5 10000 10 16
8 100000000 100 256
10 10000000000 400 1024

I’m suggesting that a feel for this up to an exponent of 32 is desirable. This, of course, takes us to the limit of a 32-bit value – 4 bytes – or an int (probably) to you and I. An exponent of 31 (with one subtracted from the final number) gives us the boundary of an unsigned int, 16 gives us an unsigned short int, 15 a signed short int, etc.

An old professor of mine at university used to boast that he knew, by heart, the decimal representation  of each power of 2 up to an exponent of 64. This was met with moderate derision from some of his students, but maybe he had a point…

 

, , , ,

Have you ever wondered where C#, BASIC (yes, it’s an acronym), or C++ came from? What about Ruby, Python or PHP? And whatever happened to Algol, Ada or Pascal. And where exactly is Delphi at these days?

Well, you can see a timeline of these and forty or so other languages here at levenez.com.

Fascinating!

, ,

I have long been of the opinion that developers and programmers (is there any difference?) should be left alone to do what they do best, i.e. develop/write software. Moreover, they outght to be able to do so with a clear scedule and without fear of interruption.empty calendar

Switching between tasks takes time. There is only a finite amount of room in your head for various programming-related paraphenalia, so the moment you switch tasks, inevitably, some of what you currently hold will have to give way

I’ve recently stumbled across two articles that bear this out for me:

http://37signals.com/svn/posts/2391-the-pleasure-of-an-open-schedule

http://www.joelonsoftware.com/articles/fog0000000068.html

So who is responsible for this? Well, a number of people, and it starts at the top. The prime goal of a project manager, for me, is to remove any obstacles from the path of development.

Enhanced by Zemanta
,

I once answered a Question on StackOverflow regarding surnames and regular expressions. I thought this might be worthy of a note here as well.

The questioner wanted to how to write a regular to transform surnames with irregular capitalisations. I.e. names like

  • MckIntosh
  • MacDonald
  • O’Reily

Quite simply this is not possible as there is no reliable rule that holds 100% of the time.

Consider the following names:

  • Mrs Macey
  • Mr Opal
  • Mr Macdonald

They are all correct. Even Mr Macdonald who doesn’t capitalise his ‘D’s. Our regex would churn out:

  • Mrs MacEy
  • Mr O’pal
  • Mr MacDonald

Bad regex!

We have to be careful when dealing with surnames – these could be our customers after all. And there is little that is more insulting than having your own name being churned up and spat out by some half-baked regex. Especially as this may be done by several such half-based regexes at different companies. You may feel like you want to change your name just so they get it right!

It’s as bad a name mispronunciation. I feel for all the people named Cockburn – (pronounced ‘Coeburn’), or McLeod – (‘McCloud’).

Unfortunately, this is all too common. Some systems are programmed only to store uppercase characters, in which case you are scuppered, and you do have to rely on some magical but flawed algorithm.

Others seek to perform some sort of user-input validation or correction. In any such case, the validation system should allow the user to input what they intended and not tell them how to think.

And always make it really really easy in your systems and processes to make minor corrections to a surname. This is a human being after all!

I still get letters from Scottish Gas addressed to Mr G Wiseman. And yet, they know my first name is James. I’ve tried to change it but just go through numerous levels of call-centre, and then get told that I need to provide it in writing. and email is not good enough. Sigh!

,

Font Smoothing In Windows

Some time ago I Investigated a problem with that a tester was encountering with forced font smoothing on Windows.

We were migrating a system that utilised Monospaced/Fixed Width font. When retaining this font on the new Web Form (changing font was not an option) the default smoothing looked really bad.

So how do you turn off font smoothing in Windows XP?

These instructions are courtesy of Arizona State University: http://www.west.asu.edu/it/start/faqs/fontsmoothxp.htm

  1. Minimize all applications so that you can see the desktop.
  2. Right-click anywhere on the desktop background (not on an icon).
  3. In the resulting pop-up menu, choose Properties. This will open the Display Properties dialog box.
  4. In the Display Properties dialog box, select the Appearance tab.
  5. In the Appearance tab, click the Effects button (lower right).
  6. In the Effects dialog box, check the “Use the following method to smooth edges of screen fonts” check box to enable font smoothing and uncheck it to disable font smoothing.
  7. If font smoothing is enabled, you can choose between Standard and Clear Type smoothing. In our experience, only Clear Type will eliminate the “jaggies” in italicized type, so we recommend Clear Type smoothing for those who want smooth type.
  8. When you have finished setting these properties, click the OK buttons in both the Effects and Display Properties dialog boxes.

 

Font Smoothing In CSS3

You can also turn off font smoothing in CSS3 (so only IE8+, sorry!): http://www.w3.org/TR/css3-fonts/#font-smooth-prop

 

What Is the Font?

I also found another useful tool when trying to determine the exact font used in the legacy system (this was not apparent from the code). Find out your font from a bitmap.

 

Fonts,Smoothing and Subpixel Rendering

Finally, if you want to dig further into fonts, smoothing and subpixel rendering check out This Aritcle From Joel Spolsky