Monday, February 8, 2010

Agile Besançon -- beautiful code

Last night at Agile Besançon we talked about beautiful code (based on the book Beau Code). We started with about a 25-minute implementation of a binary search algorithm, followed by compare/contrast of code, and an analysis from the book of common mistakes. Apparently this is much harder to implement than one would first expect, and only 10% of programmers can get it right in 2 hours. We all found vulnerabilities in our code (overflows, invalid assumptions about boundary or repeating cases), and it was a great opportunity to reflect on the assumptions we make as we code.


regis_desgroppes said...

Salut André,
I would be super nice to share the subject, ideally with a few approaches.

D. André Dhondt said...

It actually was a binary search--that is, given a sorted input array like {1,4,7,15,33,68,245,934,1043,3201}, write an algorithm that identifies whether any given test number is in the list. It doesn't count to iterate the list--you have to split it in half, then determine which half to search for your next try, and split again until you find a match or determine it's not there.