Modular Programming and UML Class and Object Diagrams - PowerPoint PPT Presentation

About This Presentation
Title:

Modular Programming and UML Class and Object Diagrams

Description:

Flight Finder Background ... latitude:double -longitude:double -timeZone:TimeZone distanceTo(l:Location) ... latitude=33-57N -longitude=118-24W -timeZone ... – PowerPoint PPT presentation

Number of Views:93
Avg rating:3.0/5.0
Slides: 35
Provided by: doug5
Category:

less

Transcript and Presenter's Notes

Title: Modular Programming and UML Class and Object Diagrams


1
Modular Programming andUML Class and Object
Diagrams
  • Session 4
  • LBSC 790 / INFM 718B
  • Building the Human-Computer Interface

2
Agenda
  • Modular Programming
  • Homework Java
  • UML Class and Object Diagrams
  • Homework Use Cases
  • Idea Rally

3
Sources of Complexity
  • Java syntax
  • Learn to read past syntax to see ideas
  • Copy working examples
  • Interaction of data and control structures
  • Structured programming
  • Object structure
  • Practice modeling using UML
  • Modularity
  • Our focus this week

4
Modularity? Who cares?
  • Limit complexity
  • Extent
  • Interaction
  • Abstraction
  • Minimize duplication

5
What can go wrong here?
Input
Output
6
Defensive Programming
  • Goal of software create desired output
  • Programs transform input into output
  • Some inputs may yield undesired output
  • Methods should enforce input assumptions
  • Guards against the user and the programmer!
  • Everything should be done inside methods

7
Passing Arguments in Java
  • Call by value
  • Primitive data types
  • Object references
  • The two meanings of equal
  • Overloaded method names
  • Depends on parameter type, number, and order

8
Returning Values in Java
  • Return type declaration
  • No return statement for void
  • Return statement causes termination
  • Multiple return statements can be present
  • First one executed causes termination
  • Type must match declaration
  • Objects encapsulate complex return types

9
Uses of Methods in Java
  • Constructor
  • Set and get
  • Helper
  • Event handler
  • Stay tuned until we get to GUIs

10
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

11
Exercise
  • Read the Book class
  • Create the Library class
  • Test the two together

12
Things To Pay Attention To
  • Syntax
  • How layout helps reading
  • How variables are named
  • How strings are used
  • How output is created
  • How applications are invoked
  • Structured Programming
  • How arrays are used
  • How boolean flags are used
  • Modular Programming
  • Modularity of methods
  • How methods are invoked
  • How arguments work
  • How scope is managed
  • How errors are handled
  • How results are passed
  • Object Structure
  • How classes are defined

13
(No Transcript)
14
Getting to the Object Structure
  • Capturing the big picture
  • Designing the object structure
  • Class diagram (entity-relationship diagram)
  • Object diagram (used to show examples)
  • Represent a candidate workflow
  • Represent object interactions for a scenario
  • Represent event-object interactions

15
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

16
Bills Budget Flight Finder
17
Flight Finder Background
  • The traveler may specify the origin, destination,
    type of flight (e.g. one-way, round-trip) exact
    or approximate dates, 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 select and book the flight, by providing
    personal and payment information.

18
FlightFinder Use Case Diagram
Search
ltltincludegtgt
AA/ Sabre
Process Sched
Select
ltltincludegtgt
Traveler
ltltincludegtgt
Book
19
Search Use Case Narrative
  • Assumptions
  • Current AA/Sabre schedule available
  • 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

20
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
    maptimelinetext
  • Termination
  • Display completed
  • Post-conditions
  • Details displayed

21
Flight Finder Background
  • The traveler may specify the origin, destination,
    type of flight (e.g. one-way, round-trip) exact
    or approximate dates, 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 select and book the flight, by providing
    personal and payment information.

22
Bills Budget Flight Finder
23
FlightFinder Class Diagram (1)
1..9
1
1..

Route
Leg
Flight
Sequence of

Sequence of



Flies between
Contains
Displayed in
1
2
0..1
1
GUI
Airfield
Schedule
1
1
Travel between
Uses
Displayed in
1
1
2
Map
Location
AircraftType
Displayed in
1
Timeline
24
Relationships
  • Object relationships
  • Has-a
  • Aggregation
  • Composition
  • Class relationships
  • Generalization (extends)
  • Implements

25
FlightFinder Class Diagram (2)
1..9
1
1..

Route
Leg
Flight
Sequence of

Sequence of
addLeg(lLeg) summary()String
-seats integer -departureTime
Time -arrivalTimeTime parse(sString) summary()
String
-flightNumberString parse(sString)


Displayed in

Flies between
Contains
0..1
Uses
GUI
Airfield
Schedule
1
1
search(pParam) display(rRoute)
-nameString -icaoIdentifierString4
-updatedTime -sourceURL parse(fFile)
2
1
1
Travel between
1
Map
Location
AircraftType
Displayed in
2
Displayed in
draw(rRoute)
-latitudedouble -longitudedouble -timeZoneTimeZ
one distanceTo(lLocation)
-nameString -speedint flightTime(oLocation,
dLocation)
1
1
Timeline
draw(rRoute)
26
FlightFinder Object Diagram
1st
1Route
2nd
NV514Flight
Leg

-flightNumberNV514
-seats34 -departureTime1600Z -arrivalTime1900Z
Leg
AF302Flight
LambertAirfield
GUI
-seats3 -departureTime1200Z -arrivalTime1400Z
-flightNumberAF302
-nameLambert Field -icaoIdentifierKSTL

O
AndrewsAirfield
LAXAirfield
Sep26Schedule
-nameAndrews AFB -icaoIdentifierKADW
-nameLA Intl Airport -icaoIdentifierKBLV
D
Map
-updatedSep 26/1200Z -sourcehttp//www
O

DCLocation
ScottAirfield
D
-latitude38-48N -longitude076-51W -timeZoneEAST
ERN
-nameScott AFB -icaoIdentifierKBLV
O
C-9BAircraftType
Timeline
-nameC-9B -speed450 knots
LALocation
Key O Origin D Destination
-latitude33-57N -longitude118-24W -timeZonePACI
FIC
D
27
Class Critique
  • Multiple instances must be possible
  • Each uniquely identifiable
  • Cant be subdivided into distinct classes
  • Multiple attributes needed to describe
  • No empty attribute values
  • Methods needed
  • At least for creation and modification

28
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

29
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

30
(No Transcript)
31
Idea Rally
  • Pitches rigidly timed (90 seconds)
  • Focus on the points that you believe will most
    impress your classmates
  • Not graded
  • Discussion afterwards

32
Show and Tell
  • What cool resources have you found?
  • Books and Web sites?
  • What new Java tricks have you learned?
  • What do you need to know to make progress?

33
Coming up
  • Exercise 3 (self-graded)
  • Will post by Friday evening
  • Not Graded
  • Next week
  • Object-oriented programming
  • Read HFJ 7,8, and 9
  • Collaboration and sequence diagrams
  • Read UML, sessions 16-19

34
Muddiest Point(s)
  • The most confusing thing discussed
  • Modular programming Java
  • UML
  • One sentence each
Write a Comment
User Comments (0)
About PowerShow.com