Object-Oriented Design

An overview of object-oriented design and the four pillars
The Solid principles for clean code
How to approach OOD

Often we start modeling software requirements by doing Use Cases.

More specific diagrams are done using UML

  1. OOD questions are often intentionally vague so the interviewer can test whether you will make assumptions or ask clarifying questions.  Some questions to ask include who is going to use the system and how they are going to use it.
  2. Now that you know the users it is time to evaluate what the core objects in the system are.
  3. Define relationships between objects.  The includes defining what objects are members of other objects, inheritance between objects, and cardinality.
  4. Last define what actions your various objects will take.  You may find you have forgotten things from previous steps.  It is ok to go back and add them in as you discover them.
Question 1

Design a parking lot system with object-oriented design (in terms of classes, objects, users, and interfaces) for a very large (30k) parking lot.  Assume the parking lot has four entrances and exits, one for each side of the parking lot.  Assign a parking space nearest to the entrance that the car came in from.  The system should not allow more cars than it has spaces.  There are four kinds of parking spaces: handicap, compact, large, motorcycle.  The system should be based on an hourly rate that is paid when the car exits the parking lot.  The system should take cash and credit cards.  It also has a system for monitoring how many cars are entering and exiting as well as video surveillance.  You need to design the system so that it can be used for new parking lots with minimal work needed.

Here is a video walkthrough of these requirements when you think you have a design.