Intelligent Design
Today’s readings largely focused on good code design, with a few tips on Hash/Array instantiation (setting default values). The exercises were two games: Mastermind and Hangman. We accomplished the first game before lunch, and NEARLY debugged our Hangman before end of class at 6.
In both coding projects we strove to stay within more advanced coding guidelines:
Break out complex code in to small methods ( < 10 lines)
DRY: do not repeat yourself
Minimizing parameters
Avoid long method chains
In the end I was really happy with our code: its day 3 and I already see great progress in the way I approach problems and organize more complex programs.
Favorite Ruby tricks learned today:
Parallel assignent of n variables with array of length n ( x, y = [1, 2] ). Awesome for cleanly passing data between methods
Deep copying a multidimensional array. I had a problem with this yesterday in tictactoe trying to use the “dup” method. Just needed to use map. Its ALWAYS map…











