Thursday 22 September 2011

Spotting a True Developer

I was thumbing through some old Maths homework set for me in my university days and I came across a practical joke that a lecturer set us that I think would be a marvellous addition to any technical interview when assessing would be developers.

The principle stems from a Mathematical fallacy which can be proven to the naked eye but, when you start to dig into it a developer should easily spot the anomoly as it can only be disproved by 'dry running' the concept in your head. Remember dry running you old school guys? A skill that has sadly seemed to have diminished as debuggers have gotten better and better. The good news is with SalesForce.com and it's Apex programming language the debugger is pretty basic and I personally am starting to see a slow resurgence of this lost, essential art!

On to the meat of this:

If we start with a basic principle X = Y it is safe to assume we can expand this as long as whatever we do to one side of the equation we do to the other side to keep it balanced so here we go.

1. Multiply both sides by X

    X^2 =X^2

2. Subtract Y^2

X^2- Y^2 = XY - Y^2

3. Now let's factor both sides and break it down into an easier to read format

(X - Y) (X + Y) = Y (X - Y)

4. Now we can divide both sides by X - Y to clean it up a bit

X + Y = Y

5. Now if we revisit our original principle that X = Y we can now express this as

Y + Y = Y or 2Y = Y

6. Now we simply divide by Y

2 = 1

And there you have it, we have now proven that 2 = 1 but can you spot the problem with this. I maintain my assertion that a true developer capable of dry running this will spot it in a few moments.


This is a common Maths 'joke' so have a go at it first before googling for the answer and I'll release the answer in my next blog but you shouldn't really need it as long as you maintain the basic principle X = Y

Until next time,

Chris

No comments:

Post a Comment