Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Modular Programming and UML Class and Object Diagrams Session 4 LBSC 790 / INFM 718B Building the Human-Computer Interface."— Presentation transcript:

1 Modular Programming and UML 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? ??

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 GUI’s

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

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 Bill’s 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 AA/ Sabre Traveler Select Search Process Sched > 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 map+timeline+text 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 Bill’s Budget Flight Finder

23 Flies betweenContains FlightFinder Class Diagram (1) Route GUI Map Timeline Location Airfield Leg AircraftType Schedule Flight * 1 1 * 2 1..911..** * 0..1 1 1 1 1 * Sequence of Displayed in 2 1 Travel between Uses

24 Relationships Object relationships –Has-a –Aggregation –Composition Class relationships –Generalization (“extends”) –“Implements”

25 Flies between * 0..1 1 1 FlightFinder Class Diagram (2) Route GUI Map Timeline Location Airfield Leg AircraftType Schedule Flight 1 * 1..911..** Sequence of 2 1 Travel between +addLeg(l:Leg) +summary():String +search(p:Param) +display(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) Contains Uses Displayed in 1 1 Displayed in 1 * 2 *

26 D FlightFinder Object Diagram 1: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

27 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

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

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


Download ppt "Modular Programming and UML Class and Object Diagrams Session 4 LBSC 790 / INFM 718B Building the Human-Computer Interface."

Similar presentations


Ads by Google