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 . . .
Today I read Roy Osherove’s blog post “Two Different ways to create bad logic in unit tests“. It’s an interesting article that covers logic included in many unit tests, is it acceptable to compare a returned string value using a comparison value built via string concatenation? It is perfectly possible that an issue introduced by the concatenation process is duplicated in both the code and the unit test – more often than not the logic . . .
The challenge set by problem 18 was By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. A 15-row triangle was then supplied for which the program must determine the corresponding maximum value taking a similar path . . .
The challenge set by Problem 54 was to determine the number poker games payer 1 won given a text file detailing 1,000 hands dealt to 2 players. Given the logical nature of the rules, the solution was just a case of finding the best way to 1) implement the rules and 2) duplicate the rule hierarchy. I quickly re-factored my first attempt that attempted to place the ruled based logic inside of the PokerHand class . . .
I’ve just spent a very painful hour or so debugging a jQuery issue that turned out to be a self inflicted problem! The site I was working on had been working perfectly all morning, then a particular page began to fail on a refresh (browser F5). It was possible to browse to the page and it displayed correctly, but press F5 to refresh the page and it failed on the statement below. Checking the contents . . .