jens bennedsen 2002objektorienteret systemudvikling using grasp to create a ayatem

20
Jens Bennedsen 2002 Objektorienteret systemudvikling Using GRASP to create a ayatem

Post on 22-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Jens Bennedsen 2002 Objektorienteret systemudvikling

Using GRASP to create a ayatem

Jens Bennedsen 2002 Objektorienteret systemudvikling

Von Petersen Charter• Von Petersen’s Charter is a small

regional carrier with small-aircraft service to nearby destinations.

• Von Petersen’s Charter needs an application for scheduling flights and making reservations.

VPC

Jens Bennedsen 2002 Objektorienteret systemudvikling

The System• We will make a simple reservation

system– Implement a prototype on the computer– No GUI but TUI– Waterfall development

Jens Bennedsen 2002 Objektorienteret systemudvikling

“So what is the system going to do?”

• Look at the basic features– Functionality of the system

• Look at the concepts of the problem domain– Concepts of the flight domain

• Look at other reservation systems (for inspiration)– library– movie theatre

• Which of these views on the problem to start with?– BOTH - hand in hand

Jens Bennedsen 2002 Objektorienteret systemudvikling

Features/requirements• You must be able to reserve a flight

– The “Fisher Price” system

User Reserve flight

Jens Bennedsen 2002 Objektorienteret systemudvikling

Reserve use caseName: Reserve a flightPurpose: Have a flight reservedActor(s): UserStart conditions:Description:Actor (Customer) System1. Request flight

reservation

3. Select route

5. Select flight and entercustomer information orenter departure date

2. List all the routes

4. List all the flights with room leftfor this route for the next month

6. If flight selected make a reservationotherwise list the flights for the givendeparture date and continue at 5

Exceptions:

End state: The flight is reserved Version1.0

InitialsJBB

Jens Bennedsen 2002 Objektorienteret systemudvikling

System events (reserve use case)

user system

requestRoutes

getScheduledFlights(flightDescription)

makeReservation(passenger, sheduledFlight)

Jens Bennedsen 2002 Objektorienteret systemudvikling

Other features• Enter (add, change, delete) airports• Enter flight descriptions• Enter scheduled flights• …• You can really get carried away here -

remember– ”Your customer will vote with his wallet”– The best features will satisfy ”a want” for the

customer who will be served by the system or whomever is paying for the system

Jens Bennedsen 2002 Objektorienteret systemudvikling

The system viewed as use cases

VonPetersenCharterReservationSystem

Reserve a flight

(from VonPetersenCharterReservationSystem)

Customer Manage Flight descriptions

(from VonPetersenCharterReservationSystem)

Manage Scheduled flights

(from VonPetersenCharterReservationSystem)

Manage airport

(from VonPetersenCharterReservationSystem)

Administrator

Jens Bennedsen 2002 Objektorienteret systemudvikling

What are the problem domain concepts?• Airport

– An airport that Von Petersen Charter operates on

• Route (FlightDescription)– A route that Von Petersen Charters flies

• Scheduled Flight– A concrete flight of a route at a given day having a

given capacity.

• Reservation– A reservation of one or more seats in a scheduled

flight

• Passenger– A person of a given type flying with Von Petersen

Charter

Jens Bennedsen 2002 Objektorienteret systemudvikling

Problem domain class model

Airport

getCode()getName()

<<Interface>> FlightDescription

getNumber()getDepartureTime()getArivavalTime()getCapacaty()

<<Interface>>

0..*1

+theFlightDescriptions

0..*

+departure

1

1

0..*+arival

1 +theFlightDescriptions

0..*

ScheduledFlight

getDate()

<<Interface>>

0..*

1

+theScheduledFlights0..*

+theFlightDescription1

Reservation

getTimeMade()getTimeExpires()setTimeExpires()

<<Interface>>

1

0..*

+theScheduledFlight 1

+theReservations 0..*

Passenger

getNumber()setType()getType()

<<Interface>>

0..*1

+theReservations

0..*

+thePassenger

1

Person

getName()getAdress()setAdress()

<<Interface>>

0..*1

+thePassengers 0..*+thePerson 1

Jens Bennedsen 2002 Objektorienteret systemudvikling

Patterns• Here we have a common case: Something

(FlightDescription) there can be many instances of (ScheduledFlight)– item/instance of item pattern:

InstanceOfItemItem

1 0..*1 0..*

General informationcommon to all instances.

For exmaple: departure airport

Instance specificinformation.

For example: departure time

Jens Bennedsen 2002 Objektorienteret systemudvikling

Architectural decisions• A closed three tier architecture

– minimise the places to change– a good default choice

Model

Function

GUI

Jens Bennedsen 2002 Objektorienteret systemudvikling

Elaborate on the use case• Place responsibilities/properties on the

classes• How is the interaction of the objects

– Where should one place the operations/responsibilities/properties?

– Expert pattern

• Who is responsible for the overall execution of the use case?– Possible: Add new classes responsible for controlling

the use cases (use case controller)

• The scenario for now: No problems– customer exists, scheduled flight exists, ...

Jens Bennedsen 2002 Objektorienteret systemudvikling

Create airport “use case”

TUI m : ManageAirports

: AirportImpl

createAirport("Århus", "aar")

AirportImpl("Århus", "aar")

creator patterncontrollerpattern

Jens Bennedsen 2002 Objektorienteret systemudvikling

Where does all the airports go?

• We need somewhere in our system where the airports are stored/saved

• Container class

Containers

getAirports()Returns the

container holding the airports

Jens Bennedsen 2002 Objektorienteret systemudvikling

Just one Containers

• There is just one instance of the Containers class– singleton

• How do we implement the singleton?– Singleton pattern aAirportManager

: Containers aContainers : Containersr

instance( )

Containers( )

if the instance attribute points to a Conatiners object, return that one

otherwise create a new, update the instance attribute and return

getAirports( )

Jens Bennedsen 2002 Objektorienteret systemudvikling

aReservationController :ReservationController

GUI

requestRoutes( )

: Containers aFlightDecription :

: ScheduledFlight

getFlightDescriptions( )

getScheduledFlights(flightDescription)

getScheduledFlights()

hasRoom()

Reserve flight interaction

Usecasecontroller

Expert pattern

Jens Bennedsen 2002 Objektorienteret systemudvikling

Now we just need the code :-)• Use the class diagram to find out which

classes there is :-)• Use the interaction diagram to implement

the different operations - eg:

what

how

m : ManageAirports

: AirportImpl : Containers

createAirport("Århus", "aar")

AirportImpl("Århus", "aar")

instance( )

Jens Bennedsen 2002 Objektorienteret systemudvikling

ManageAirports

class ManageAirports { //creates an airport public abstract void createAirport(String name, String code); //returns the airport with the code <code> public abstract Airport findAirport(string code); //adds a departure to the ariport public abstract void changeAirport(string code, string newName); //erases the airportwith code <code> public abstract void eraseAirport(string code); // return the airports public abstract Iterator airports(); //add an arrival };