Today, my pair partner and I got to the harder parts of the Oystercard challenge. It took pretty much all day, a ping pong session, a hula hoop session and many biscuits but we got there in the end and it felt really good!
Part of the challenge was extracting a new class out of an existing one. So far we only had a class for our oystercard and for the station, and our oystercard was storing all of our journeys, doing the fares-pretty much everything. So to follow the single responsibility principle, we extracted the journeys to have its own class. Previously we had stored the start and the journey in a hash and pushed the hash in an array. Now we had our new shiney journey class and could store the info for each journey in an object.
It’s funny how, once you’ve done it, you think “oh yeah that makes sense, why did I even bother with an hash at all?”. Hindsight, huh?