Monday, September 15, 2008

Design Concepts - training - Traffic junction


Assignment which I did for the Design Concept training, Which was given by my Company VP.

Assignment was to identify the objects in Traffic junction and establish the relation ship between them.

Object Representation in traffic junction

Traffic junction
Traffic Inspector
Traffic Signals
Red light
Green light
Yellow light
Road
Coffee day Shop
Tree
Park
Cow
Dog
Road divider
Electric poles
Traffic Camera
Electric lights
Footpath
Bus Stop
Traffic signal Board
Traffic police bike
Bus
Car
Car driver
Bike
GK Stationary shop
Transformer
Advertisement Board
Bus Stop
Cycle
Electric line
Bus driver
Beggar
Passengers
Roadside Seller
Traffic police hat
Bus commuter
KFC Shop
Pan Shop


1) Association

Definition: An association is a simple relationship between two objects without any additional implications. All object have their own lifecycle and there is no owner

Example:

Multiple students can associate with single teacher
And single student can associate with multiple teachers
But there is no ownership between the objects and both have their own lifecycle.
Both can create and delete independently.

Association relationship in traffic junction

Traffic police - -- ------ interact with -------- Traffic Signals
Beggar - -- ------ interact with -------- Footpath
Traffic police - -- ------ interact with -------- Traffic Camera
Beggar - -- ------ interact with -------- Bus Stop
Beggar - -- ------ interact with -------- Bus
Shop Keeper - -- ------ interact with -------- Pan Shop
Bus - -- ------ interact with -------- Road
Bus - -- ------ interact with -------- Bus Stop
Bus driver - -- ------ interact with -------- Bus
Beggar - -- ------ interact with -------- Bus driver
Beggar - -- ------ interact with -------- Traffic police
Beggar - -- ------ interact with -------- Traffic Inspector
Car - -- ------ interact with -------- Road
Bike - -- ------ interact with -------- Road
Stationary shop - -- ------ interact with -------- Shop Keeper
Transformer - -- ------ interact with -------- Electric line
Traffic Inspector - -- ------ interact with -------- Traffic police
Traffic Inspector - -- ------ interact with -------- Beggar
Beggar - -- ------ interact with -------- Bus stop
Shop keeper - -- ------ interact with -------- Advertisement board
Traffic Inspector - -- ------ interact with -------- Advertisement board
Beggar - -- ------ interact with -------- Advertisement board
Car driver - -- ------ interact with -------- Road
Car driver - -- ------ interact with -------- Pan shop
Car driver - -- ------ interact with -------- Coffee day shop


2) Composition (HAS – A)
Definition: Child object does not have their lifecycle and if parent object deletes, all child object will also be deleted

Relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete

House ---- has a Room ------------- Room
(If House object is deleted, Room object is also deleted)

Composition (HAS – A) relationship in traffic junction

Park ------------ has a ----------------------- Tree
Road ------------ has a ----------------------- Road divider
Shopping complex ------------ has a ----------------------- Stationary shop
Traffic police ------------ has a ----------------------- hat
Bus ------------ has a ----------------------- Bus driver
Bus ------------ has a ----------------------- Bus commuter
Bus stop ------------ has a ----------------------- Bus commuter
Park ------------ has a ----------------------- Beggar
Bus commuter ------------ has a ----------------------- ticket
Traffic Inspector ------------ has a ----------------------- bike
Car driver ------------ has a ----------------------- Car
Coffee day shop ------------ has a ----------------------- Coffee making machine



3) Inheritance (IS – A)

Inheritance is uni-directional; Child object will be inherited by parent object

House ------------ is a --------------- Building.
(But Building is not a House)

Inheritance (IS – A) Relationship in traffic junction

Traffic police ------------ is a ----------------------- Driver
Bus Driver ------------ is a ----------------------- Driver
Beggar ------------ is a ----------------------- Bus commuter
Shop keeper ------------ is a ----------------------- Bus commuter

Red light ------------ is a ----------------------- Traffic Signal
Yellow light ------------ is a ----------------------- Traffic Signal
Green light ------------ is a ----------------------- Traffic Signal
Traffic police ------------ is a ----------------------- Bus commuter
Traffic Inspector ------------ is a ----------------------- Driver
Coffee day shop ------------ is a ----------------------- Shop



4) Polymorphism

Traffic Signal status ------ > for the same message --- Bus or Ambulance behave differently ( loosely coupled polymorphism)