A simple programming exercise for use with pair programming. The objective is to create a LIFO (last in first out) stack with push and pop methods. Ruby arrays already provide these methods, so doing the exercise in Ruby is pretty straightforward. The exercise can be made tougher by not using the existing Array#push and Array#pop methods, but the key is to be following the TDD (Test Driven Development) methodology; i.e. only writing code in the main application after an appropriate test has been written, and only writing the bare minimum of code necessary to make that test pass.
In particular we recommend trying this exercise in a pair with one of the following pair programming protocols:
- Ping Pong
- Change the Error
- One Undermanship
Or some combination of the three. Here is a live example focused mainly on the "Change the Error" protocol using "Github Pong":
See the full sequence of code commits for this session and each stage in the process can be accessed via git tags step00 to step14.
- rspec version?
- Gemfile?