object oriented analysis and object oriented programming
DESCRIPTION
Object Oriented Analysis and Object Oriented Programming. Session 4 LBSC 790 / INFM 718B Building the Human-Computer Interface. Agenda. Class diagrams Object diagrams Object design Object oriented programming in Java. Object Modeling. Models are abstractions of reality - PowerPoint PPT PresentationTRANSCRIPT
Object Oriented Analysisand
Object Oriented Programming
Session 4
LBSC 790 / INFM 718B
Building the Human-Computer Interface
Agenda
• Class diagrams
• Object diagrams
• Object design
• Object oriented programming in Java
Object Modeling
• Models are abstractions of reality– That are created for a specific purpose
• Classes represent types of entities– That are important for the chosen purpose– Specify subordinate objects and methods
• Objects are specific instances of classes– Encapsulate specific objects and methods
Flight Finder Exercise
http://www.glue.umd.edu/~oard/spacea/ff/
Flight Finder Background• The traveler (or a system administrator) will first obtain schedule data
from JOSAC using their Web browser and store it on their hard drive in the received format. Upon program initiation, the Parse Sched use case will run automatically. Once that completes, the traveler may specify the origin, destination, radius around each, and a connection radius (or leave any of the default values set), earliest and latest times, and then initiate the search. Once the search completes, the traveler may step through the interesting routes one at a time, viewing information on which their decision might be based. Once one or more acceptable routes have been identified, the traveler can then contact the appropriate facilities directly to make travel arrangements.
FlightFinder Use Case Diagram
JOSAC
Traveler
Select
Search
ParseSched
<<include>>
<<include>>
Search Use Case Narrative• Assumptions
– Current JOSAC schedule parsed
• Pre-conditions– None
• Initiation– Search function selected
• Dialog– Search parameters selected, search initiated, unknown locations resolved, route list
displayed
• Termination – Route search complete (normal), unknown location (error)
• Post-conditions– Route list displayed (if available) or blank
Select Use Case Narrative• Assumptions
– Route list displayed
• Pre-conditions– At least one available route
• Initiation– Route selected from list
• Dialog– Select route, display details in map+timeline+text
• Termination – Display completed
• Post-conditions– Details displayed
Flight Finder Background• The traveler (or a system administrator) will first obtain schedule data
from JOSAC using their Web browser and store it on their hard drive in the received format. Upon program initiation, the Parse Sched use case will run automatically. Once that completes, the traveler may specify the origin, destination, radius around each, and a connection radius (or leave any of the default values set), earliest and latest times, and then initiate the search. Once the search completes, the traveler may step through the interesting routes one at a time, viewing information on which their decision might be based. Once one or more acceptable routes have been identified, the traveler can then contact the appropriate facilities directly to make travel arrangements.
Flies between Contains
FlightFinder Class DiagramRoute
GUI
Map
Timeline
Location
Airfield
Leg
AircraftType
Schedule
Flight*
1
1
*
2
1..9 11..**
*
0..1
1
1
1
1
*Sequence ofSequence of
Displayed in
Displayed in
Displayed in
2
1
Travelbetween Uses
Fli
es b
etw
een
*
0..11
1
Full FlightFinder Class DiagramRoute
GUI
Map
Timeline
Location
Airfield
Leg
AircraftType
Schedule
Flight
1
*
1..9 11..**
Sequence ofSequence of
2
1
Travelbetween
+addLeg(l:Leg)+summary():String
+search(p:Param)+display(r:Route)
+draw(r:Route)
+draw(r:Route)
-seats: integer-departureTime: Time-arrivalTime:Time+parse(s:String)+summary():String
-name:String-icaoIdentifier:String{4}
-latitude:double-longitude:double-timeZone:TimeZone+distanceTo(l:Location)
-flightNumber:String
+parse(s:String)
-updated:Time-source:URL
+parse(f:File)
-name:String-speed:int
+flightTime(o:Location, d:Location)
Con
tain
s
Use
s
Dis
play
ed in
Dis
play
ed in
1
1
Displayedin
1
*
2
*
D
FlightFinder Object Diagram1:Route
:GUI
:Map
:Timeline
DC:Location
Andrews:Airfield
:Leg
C-9B:AircraftType
Sep26:Schedule
AF302:Flight
-seats=3-departureTime=1200Z-arrivalTime:1400Z
-name=Andrews AFB-icaoIdentifier=KADW
-latitude:38-48N-longitude:076-51W-timeZone=EASTERN
-flightNumber:AF302
-updated:Sep 26/1200Z-source:http://www…
-name=C-9B-speed=450 knots
LA:Location
-latitude=33-57N-longitude=118-24W-timeZone=PACIFIC
Scott:Airfield
-name=Scott AFB-icaoIdentifier=KBLV
Lambert:Airfield
:Leg
-seats=34-departureTime=1600Z-arrivalTime=1900Z
-name=Lambert Field-icaoIdentifier=KSTL
LAX:Airfield
-name=LA Intl Airport-icaoIdentifier=KBLV
NV514:Flight
-flightNumber:NV514
O
D
O
O
D
1st
2nd
Key: O = Origin D = Destination
Class Critique
• Multiple instances must be possible– Each uniquely identifiable
• Can’t be subdivided into distinct classes
• Multiple attributes needed to describe
• No empty attribute values
• Methods needed– At least for creation and modification
Attribute Critique
• Naturally describes the object– Does not describe some other object
• Value will be known for some instances
• Value will never be empty
• Cannot be subdivided into smaller attributes
• One value, not a list of values
• Cannot be computed from other attributes
Relationships
• Object relationships– Has-a– Aggregation– Composition
• Class relationships– Generalization (“extends”)– “Implements”
Practice Exercise
• Create a Class Diagram for an academic transcript– Include a method to compute grade point average– Include a method to print the transcript
• Code (only) the transcript class in java– Include a main method that tests the class– Create stubs for any other needed classes
• Run your main method
Classes to Explore in the API
• String– Manipulate strings (e.g., to extract substrings)
• StringTokenizer– Pick apart strings (e.g., into words)
• GregorianCalendar– Dates and times
• Hashtable– Like arrays, but with any object as the index
Muddiest Point
On a blank sheet of paper, write a
single sentence that will convey
to me what you found to be the
most confusing thing that was
discussed during today’s class.
FlightFinder Class Diagram
Aircraft
type
display()
Airfield
nameicaoIdentifier
location
display()
Flight
flightNumberaircraft
legs
display()
Schedule
webpage
readFlight()readDate()display()
Location
latitudelongitude
distanceTo()timeZone()
Leg
flightdepartureFielddepartureTime
arrivalFieldarrivalTime
availableSeats
display()
Options
keyboardroutes
compute()display()
Route
legs
display()