Friday, April 17, 2015

Solve (Design OO model) a Parking Garage problem

Series:
·        Solve (Design OO model) a Parking Garage problem
·        Solve (UML representation OO model) a Parking Garage problem
·        Solve (app pattern) a Parking Garage problem
·        Solve (cloud & network deployment pattern) a Parking Garage problem

Problem statement:

We are going to design the object model, a webapp, and a cloud deployment diagram to determine availability of parking space in a Parking garage using the design and architecture patterns.

A parking garage is a multi-level structure. It consists of parking levels which further comprises of parking space. A vehicle can be parked in one parking space. Each level and the garage have a Display Box. The Display Box shows if there available space or full.

This is a going to be a multi-part series. The current one will focus on Object Model. (It is a simplistic model for demonstration purpose only and the model.)

Let us design the OO model. We will use GoF design patterns.

 

Structural patterns:

·        Garage Object composes ParkingLevel Objects which further composes ParkingSpace Objects (composite.)

·        DisplayBox Object can have independent life thus DisplayBox Object has association relationship.

·        There are many ParkingSpace Objects which differs by insignificantly from one another (Flyweight)

Creational patterns:

·        There can be only one Garage Object (Singleton)

·        There can be only predefined level of ParkingLevel and ParkingSpace (Factory)

·        (Advance) We can have proxy Garage Objects if we want to centrally manage multiple Garages (proxy) – we are going to exclude this one for simplicity.        

Behavioral patterns:

·        We are going to instantiate objects out from classes (template)

·        We need to maintain state of the ParkingSpace Objects (state)

·        We need to iterate over ParkingSpaces for reasons such as finding out availability (iterator)

o   Alternatively we could have used Observer pattern to find out availability of parking spaces in a ParkingLevel and ultimately in a Gargage.

·        We need to aggregate ParkingSpace Objects(visitor)

·        We need to find out available space, reserve, etc. Garage Object it to rely on ParkingLevel which in turn relies on ParkingSpace (chain of responsibilities)

o   Alternatively we could have use Command pattern for delegation

No comments:

Post a Comment