We worked through the challenges throughout the week in rotating pairs. Below is the introduction that sets out the overarching goal:
Let's go back several years, to the days when there were no Boris Bikes. Imagine that you're a junior developer (that was easy). Transport for London, the body responsible for delivery of a new bike system, come to you with a plan: a network of docking stations and bikes that anyone can use. They want you to build a program that will emulate all the docking stations, bikes, and infrastructure (repair staff, and so on) required to make their dream a reality.
- Are you having fun?
- Are you a better developer than you were yesterday?
- Can you use a test-driven approach to write object-oriented code?
- Download the source code using
$ git clone
- Within the command line, type the command
$ irb
to enter the Ruby REPL - Then, use the following commands to interact with the programme:
2.3.3 :001 > require './lib/bike.rb'
=> true
2.3.3 :002 > require './lib/docking-station.rb'
=> true
2.3.3 :003 > my_bike = Bike.new
=> #<Bike:0x007fc80a02d738>
2.3.3 :004 > canary_wharf = DockingStation.new
=> #<DockingStation:0x007fc809b2a8f8 @bikes=[], @capacity=20>
2.3.3 :005 > canary_wharf.dock_bike(my_bike)
=> [#<Bike:0x007fc80a02d738>]
2.3.3 :006 > canary_wharf.show_bikes
=> [#<Bike:0x007fc80a02d738>]
- Within the root of the directory, run
$ rspec
to run the tests and see the results in the command line
- Application written in Ruby 2.3.3
- Tests written in RSpec
- Tried to use a object-oriented approach with each object in a separate file
- Uses dependency injection to store instances of Bike in an instance of DockingStation
- We struggled a bit with understanding how best to map out the domain model
- One of the questions was whether you could have two
messages
on the same line (i.e. for the sameobject
)
- One of the questions was whether you could have two
- Another conceptual hurdle was the distinction between feature testing and unit testing
- We came to realise that feature testing is interacting with the programme from the point of view of the user and unit testing is testing a specific bit of behaviour within the programme
- It would be nice to fully extend the concept of bikes working or not working
- Currently it is only half implemented
Samir Gossain, Konrad Schlatte, Frankie Shaw