Tuesday, 17 August 2010

Total WTF moment whilst reading Clean Code

I've just spent a useful and enjoyable day finally getting around to reading Clean Code, definitely a book to come back to time and again for reference, etc.  However given the subject matter the book contains I was amazed to find in the section about "magic numbers" a statement that "some constants are so easy to recognise that they don't always need a named constant".  Two of the examples given are the number of feet per mile and the number of work hours per day.   I'm not sure how many people that work with imperial units could easily state how many feet are in a mile.  If you are more used to using metric units then that figure has next to no meaning what so ever.  And at least in the UK working hours vary depending upon the industry, company and even department that you work in.  Whilst it doesn't detract from the content of the book I'm not sure those statements should have got past the proof reading / draft review stage.

No comments:

Post a Comment