Exercise Notes

Learning goals

  • Software design approaches and patterns, to identify reusable solutions to commonly occurring problems
  • Apply an appropriate software development approach according to the relevant paradigm (for example object-oriented, event-driven or procedural)

Programs used

Zoo

You should already have a copy of the Zoo Management System repo cloned locally from following along during the reading for this module.

  1. Hopefully you’ve already experimented with adding a Guinea Fowl to the zoo. Try adding a few more types of animals. Can you implement the muck-sweeping interface suggested in the reading? What do you think about using inheritance for AnimalThatCanBeGroomed compared with interfaces for ICanBeGroomed? Can you find a good way to avoid code duplication?

  2. Complete the thought experiment from the reading about the schedulers – what’s the best way to allow Program.Main to work with any scheduler, rather than hard-coding each type? There’s no one right answer to this, so consider all the options.

Parking Garage Application

Design a class structure for the following application about a parking garage.

Your class structure should support the following objects being created:

  • An object that represents the garage itself.
  • The garage may have multiple floors, so we want an object per floor. The floors all look broadly similar, although they have different numbers of spaces.
  • We need an object to represent each space, containing fixed information on the size of the space (some are small/low height), and transient information on current occupancy.
  • Cars, motorbikes, and vans may park in the garage. We want an object instance representing each vehicle that enters the garage, with a registration number attached. We’ll also need to be able to work out whether the vehicle is of a suitable size to fit the various available spaces.

You can do this as a diagram (have a look at this tutorial and try to produce something aligned with the UML standard described there), or sketch out some code.

There are lots of different architectures that could work. Make notes on what assumptions you’re making as you go, e.g. why did you pick a particular approach? What challenges will it likely help you solve?