Object Oriented Modeling and Design Agenda Object Oriented
Object Oriented Modeling and Design Agenda Ø Object Oriented Philosophy • Developing an Object-Oriented application • How do you organize a business & OOAD? Ø Example • Flight booking system ØAn Object-Oriented Approach • A Payroll Program ØStructured Approach ØAn Object-Oriented Approach
Object basics: Object Oriented Philosophy : Ø When developing an Object-Oriented application, two basic questions always arise: ØWhat objects does the application need? Ø What functionality should those objects have? Ø OOAD can be illustrated by analogy to how to organize a business
Object basics: Object Oriented Philosophy : How do you organize a business & OOAD? Business Analogy OOAD What are the business processes? Requirements analysis What are the employee roles? Domain analysis Who is responsible for Responsibility what? How do they assignment, interaction interact? design
Object basics: Object Oriented Philosophy : What objects does the application need? Identifying Objects: Example Ø Flight booking system Ø Assume that the following sentences are summarized by domain experts – Airline companies offer various flights – A flight is open to booking and close again by order of the company – A customer can book one or more flights and for different passengers
Object basics: Object Oriented Philosophy : What objects does the application need? – A booking concerns with a single passenger and a single flight. – A booking can be cancelled or confirmed. – A flight has a departure airport and an arrival airport. – A flight has a departure day and time and an arrival day and time. – A flight may involve stopovers in airports. – A stopover has an arrival time and a departure time. – Each airport serves one or more cities.
Object basics: Object Oriented Philosophy : What objects does the application need? Ø Objects : Sentence 1 – Airline companies offer various flights Airline company, Flight (real world entities) Ø Objects : Sentence 2 – A flight is open to booking and close again by order of the company Airline company, Flight (real world entities), Booking Ø Objects : Sentence 3 – A customer can book one or more flights and for different passengers Booking, Flight , Customer Distinction between customer and passenger?
Object basics: Object Oriented Philosophy : What objects does the application need? Ø Objects : Sentence 4 – A booking concerns with a single passenger and a single flight Booking, Flight , Passenger Ø Objects : Sentence 5 – A booking can be cancelled or confirmed Booking Ø Objects : Sentence 6 – A flight has a departure airport and an arrival airport Airport, Flight
Object basics: Object Oriented Philosophy : What objects does the application need? Ø Objects : Sentence 7 – A flight has a departure day and time and an arrival day and time Flight Ø Objects : Sentence 8 – A flight may involve stopovers in airports Flight , Airport, Stopover Ø Objects : Sentence 9 – A stopover has an arrival time and a departure time Stopover Ø Objects : Sentence 10 – Each airport serves one or more cities Airport, City
Object basics: Object Oriented Philosophy : What functionality should those objects have? • OPERATIONS : Sentence 2 – A flight is open to booking and close again by order of the company Flight: – open. Booking – closed. Booking • OPERATIONS : Sentence 5 – A booking can be cancelled or confirmed Booking: – cancel – confirm • Similarly we find all operations
Object basics: A Case Study - A Payroll Program: Program Ø Consider a payroll program that processes employee records at a small manufacturing firm. This company has three types of employees: – Managers: Receive a regular salary. – Office Workers: Receive an hourly wage and are eligible for overtime after 40 hours. – Production Workers: Are paid according to a piece rate.
Object basics: A Case Study - A Payroll Program : Structured Approach: FOR EVERY EMPLOYEE DO BEGIN IF employee = manager THEN CALL compute. Manager. Salary IF employee = office worker THEN CALL compute. Office. Worker. Salary IF employee = production worker THEN CALL compute. Production. Worker. Salary END
Object basics: A Case Study - A Payroll Program : Structured Approach: Ø What if we add two new types of employees? – Temporary office workers ineligible for overtime – Junior production workers who receive an hourly wage plus a lower piece rate.
Object basics: A Case Study - A Payroll Program : Structured Approach: FOR EVERY EMPLOYEE DO BEGIN IF employee = manager THEN CALL compute. Manager. Salary IF employee = office worker THEN CALL compute. Office. Worker_salary IF employee = production worker THEN CALL compute. Production. Worker_salary IF employee = temporary office worker THEN CALL compute. Temporary. Office. Worker. Salary IF employee = junior production worker THEN CALL compute. Junior. Production. Worker. Salary END
Object basics: A Case Study - A Payroll Program : An Object-Oriented Approach : Ø What objects does the application need? – The goal of OO analysis is to identify objects and classes that support the problem domain and system's requirements. – Some general candidate classes are: • Persons • Places • Things
Object basics: A Case Study - A Payroll Program : An Object-Oriented Approach : • What are some of the application’s classes? • • Employee Manager Office Workers Production Workers • Identify class hierarchy – Identify commonality among the classes – Draw the general-specific class hierarchy
Object basics: A Case Study - A Payroll Program : An Object-Oriented Approach : FOR EVERY EMPLOYEE DO BEGIN employee compute. Payroll() END
Object basics: A Case Study - A Payroll Program : An Object-Oriented Approach : If a new class of employee were added FOR EVERY EMPLOYEE DO BEGIN employee compute. Payroll() END
- Slides: 17