Presentation is loading. Please wait.

Presentation is loading. Please wait.

3 Designing applications

Similar presentations


Presentation on theme: "3 Designing applications"— Presentation transcript:

1 3 Designing applications
Objektorienterade applikationer d2, förel. 3 3 Designing applications (BK chap. 15) DAT055, 16/17, lp 3

2 Main concepts to be covered
Objektorienterade applikationer d2, förel. 3 Main concepts to be covered OOA and OOD Discovering classes CRC cards Designing interfaces Development process models Modeling languages Modeling in UML Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

3 Objektorienterade applikationer d2, förel. 3
OOA and OOD Object Oriented Analysis Identifies the entities (objects) of a system, their relationships, and cooperation. Focus on “what” rather than “how”. Object Oriented Design Detailed design Data representation, method signatures,… System design Platforms, languages, environment, hardware,… Kravaanalysen kommer först den ingår inte I OOA. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

4 Object oriented analysis
Objektorienterade applikationer d2, förel. 3 Object oriented analysis A large and complex area. The verb/noun method is suitable for relatively small problems. CRC cards support the analysis. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

5 Objektorienterade applikationer d2, förel. 3
The verb/noun method The nouns in a description refer to ‘things’. A source of classes and objects. The verbs refer to actions. A source of interactions between objects. Actions are behavior, and hence methods. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

6 Objektorienterade applikationer d2, förel. 3
A problem description The cinema booking system should store seat bookings for multiple theatres. Each theatre has seats arranged in rows. Customers can reserve seats and are given a row number and seat number. They may request bookings of several adjoining seats. Each booking is for a particular show (i.e., the screening of a given movie at a certain time). Shows are at an assigned date and time, and scheduled in a theatre where they are screened. The system stores the customers’ telephone number. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

7 Objektorienterade applikationer d2, förel. 3
Nouns and verbs Cinema booking system Stores (seat bookings) Stores (telephone number) Theatre Has (seats) Movie Customer Reserves (seats) Is given (row number, seat number) Requests (seat booking) Time Date Seat booking Show Is scheduled (in theatre) Seat Seat number Telephone number Row Row number Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

8 Objektorienterade applikationer d2, förel. 3
Using CRC cards First described by Kent Beck and Ward Cunningham. Each index card records: A class name. The class’s responsibilities. The class’s collaborators. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

9 Objektorienterade applikationer d2, förel. 3
A CRC card Class name Collaborators Responsibilities Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

10 Objektorienterade applikationer d2, förel. 3
A partial example CinemaBookingSystem Collaborators Can find shows by title and Show day. Stores collection of shows. Collection Retrieves and displays show details. ... Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

11 Objektorienterade applikationer d2, förel. 3
Scenarios An activity that the system has to carry out or support. Sometimes known as use cases. Used to discover and record object interactions (collaborations). Can be performed as a group activity. Icketeknisk aktivitet Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

12 Objektorienterade applikationer d2, förel. 3
Scenario analysis Scenarios serve to check the problem description is clear and complete. Sufficient time should be taken over the analysis. The analysis will lead into design. Spotting errors or omissions here will save considerable wasted effort later. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

13 Objektorienterade applikationer d2, förel. 3
Class design Scenario analysis helps to clarify application structure. Each card maps to a class. Collaborations reveal class cooperation/object interaction. Responsibilities reveal public methods. And sometimes fields; e.g. “Stores collection ...” Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

14 Designing class interfaces
Objektorienterade applikationer d2, förel. 3 Designing class interfaces Replay the scenarios in terms of method calls, parameters and return values. Note down the resulting signatures. Create outline classes with public-method stubs. Careful design is a key to successful implementation. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

15 Objektorienterade applikationer d2, förel. 3
Documentation Write class comments. Write method comments. Describe the overall purpose of each. Documenting now ensures that: The focus is on what rather than how. That it doesn’t get forgotten! Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

16 Objektorienterade applikationer d2, förel. 3
Cooperation Team-working is likely to be the norm not the exception. Documentation is essential for team working. Clean O-O design, with loosely-coupled components, also supports cooperation. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

17 Objektorienterade applikationer d2, förel. 3
Prototyping Supports early investigation of a system. Early problem identification. Incomplete components can be simulated. E.g. always returning a fixed result. Avoid random behavior which is difficult to reproduce. GUI-prototyp utan underliggande intelligens - eller simulerad sådan Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

18 Development process models
Objektorienterade applikationer d2, förel. 3 Development process models Waterfall model Analysis Design Implementation Unit testing Integration testing Delivery No provision for iteration. Denna modell har svårt att klara förändringskrav. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

19 Development process models (2)
Objektorienterade applikationer d2, förel. 3 Development process models (2) Iterative incremental development Use early prototyping. Frequent client interaction. Iteration over: Analysis Design Prototype Client feedback A growth model is the most realistic. Milstolpar <-> inkrement Inkrement – en väldefinierad portion funktionalitet. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

20 Graphical modeling languages
Objektorienterade applikationer d2, förel. 3 Graphical modeling languages A modeling language has a graphical syntax (and a more or less well defined semantics). Graphical modeling focus on conceptual aspects of a design. OMT = Object Modeling Technique (Michael Blaha,Jim Rumbaugh, William Premerlani) Booch (Grady Booch) UML = Unified Modeling Language (Jacobson,...) Hög abstraktionsnivå I början. Man kan även beskriva vissa implementeringsaspekter. Modellering != programmering? UML -> programmeringsspråk? Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

21 Objektorienterade applikationer d2, förel. 3
UML diagram types Static design view Class diagrams (static relations) Component diagrams (modularization) Deployment diagrams (run-time config.) Dynamic design view Use case diagrams (user level behavior) Scenario diagrams (object cooperation) State diagrams (individual object behavior) Det finns massor här. Vi skummar bara lite på ytan. Aktivitetsdiagram Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

22 Objektorienterade applikationer d2, förel. 3
Class diagrams Class icons Type relationships Inheritance (“is a”) Implementation Object relationships Dependency Association (“knows”) Aggregation (“has”) Composition (“contains”) ClassName Vi har sett en del klassdiagram. Några kommentarer om skillnader mellan olika relationer. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

23 Inheritance relationships
Objektorienterade applikationer d2, förel. 3 Inheritance relationships Superclass Subclass Superinterface Subinterface Interface Implementation Class extension Interface extension Interface implementation Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

24 Objektorienterade applikationer d2, förel. 3
Class icons Class icon Stereotype Class name <<abstract>> Thing - size : int + getSize() : int # setSize(n:int) : void Variables Access modifier Private – Protected # Public Methods Man kan ta med olika mycket detaljer I olika ikoner och diagram. Ta inte med attribut som motsvaras av en relationspil. Return type Parameter Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

25 Object relation properties
Objektorienterade applikationer d2, förel. 3 Object relation properties Multiplicity Exactly x x Zero or more * Range x to y x..y x or more x.. Name Navigability * update owned owner Ingen pil = navigerbar i båda riktningarna Multiplicitet kan sättas ut i båda ändarna Role Role Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

26 Aggregation and composition
Objektorienterade applikationer d2, förel. 3 Aggregation and composition whole Aggregate Component Aggregate Component Aggregation Composition part Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

27 Aggregation and composition (2)
Objektorienterade applikationer d2, förel. 3 Aggregation and composition (2) University Student Department * 1 A department belongs to a university. The life time of a department is bounded by the life time of the university to which it belongs. (strong aggregation) The life time of a student is independent of the life time of the department. (weak aggregation) Vid starkt aggregat är multipliciteten alltid 1 på aggregatsidan. Vid svagt aggregat kan den vara * Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

28 Aggregation vs inheritance
Objektorienterade applikationer d2, förel. 3 Aggregation vs inheritance Sometimes aggregation is a natural alternative to inheritance. Ask the question: Which is most natural to say, that an A has a B or, that an A is a B? List Queue The list is an internal implementation detail of this queue. Is a queue really a list? Do we want a queue to provide general list operations? Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 ANIMERA DAT055, 16/17, lp 3

29 Aggregation, association and dependency relationships
Objektorienterade applikationer d2, förel. 3 Aggregation, association and dependency relationships Many clients share a server. No client owns the server. Internal state Utility Client * 1 Server someMethod(Utility x) : void Borde vi inte ha komposition här? Servern kan gå ner,men tillståndet överlever på disk tills den kommer upp igen. (Objektströmmar…) Allmänt: Rita flera diagram. Inte allt i ett enda. Relationer utan klassdetaljer i ett. Klassdetaljer utan relationer i ett annat. A server owns it’s internal state. It is not shared by others. A dependency is more volatile than an association. A server uses the utility temporarily. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

30 Objektorienterade applikationer d2, förel. 3
Use case modeling Use case view Captures the behavior of a system as it appears to a user outside the system boundary. Main inventor - Ivar Jacobson Actor External part that interacts with the system. Idealized user: human, other system, process, ... Use case External system behavior, meaningful to an actor. A piece of interactive functionality as a sequence of messages between an actor and a system. Ett litet steg mot funktionsorienterat synsätt. Ett användningsfall skall beskriva en meningsfull tjänst – inte för smått alltså! Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

31 Objektorienterade applikationer d2, förel. 3
Use case diagrams Use case icons Actor icons Use case relationships Generalization Inclusion Extension Participation use case name actor name Ovalen talar bara om att det finns och vad det heter. Resten finns I ett strukturerat dokument. Relationerna har vissaberöringspunkter med klassrelationer. <<include>> <<extend>> Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

32 Use case diagram for a university
Objektorienterade applikationer d2, förel. 3 Use case diagram for a university University system System boundary registration teacher student course activities examination secretary report credits Aktörer kan vara andra system. LADOK kanske borde vara en aktör här? Läs inte dessa diagram som flödesplaner! view credits Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

33 Objektorienterade applikationer d2, förel. 3
Use case parts Whole use case course activities <<include>> <<include>> <<include>> attend lab supervision attend lectures do home work Sådana delar kan återanvändas i andra användningsfall: Ex. Autentiseringsproceduren i en bankomat kan användas för flera olika tjänster. Use case fragment Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

34 Generalization – specialization and extension
Objektorienterade applikationer d2, förel. 3 Generalization – specialization and extension examination <<include>> <<include>> Generalization submit labs do exam Specialization <<extend>> submit bonus do written exam do oral exam Det utvidgade användningsfallet “vet inte om utvidgningen” – men man kör hela. Use case extension One of the special use cases may be substituted for the general use case. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

35 Objektorienterade applikationer d2, förel. 3
Scenario diagrams A scenario diagram visualizes how cooperating objects implement a use case, or part of a use case. There are two main types of scenario diagrams Cooperation diagrams Focus on object cooperation aspects. Sequence diagrams Visualize the temporal orderings of messages sent between cooperating objects. Användbart till lite av varje Man kan göra informella sådana för att beskriva allt möjligt. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

36 Objektorienterade applikationer d2, förel. 3
Sequence diagrams System boundary Instance Instance name Class external actor t i m e : Client server : Server Time line select(x) Message Activation requestX() Return Tydliggör objektsamarbete I ett användningsfall. Användbara för att få fram metoder och parametrar – och ibland nya klasser. Finns mer här skapa objekt alternativt flöde Destruction Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 ANIMERA DAT055, 16/17, lp 3

37 Ex. A cash machine scenario
Objektorienterade applikationer d2, förel. 3 Ex. A cash machine scenario customer : CardUnit : CPU : Keyboard : GUI : BillFeader : ReceiptPrinter insert(card) check(card) msg(”type PID”) type(PID) check() msg(”select amount”) type(amount) Focus of control Ganska svag formalism Beskriver ett möjligt scenario Lite fusk här, men visar idén. Synkront – asynkront req(amount) deliver($) Return arrows omitted in lower part print(receipt) Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

38 Objektorienterade applikationer d2, förel. 3
Review Class collaborations and object interactions must be identified. CRC analysis supports this. An iterative approach to design, analysis and implementation can be beneficial. Regard software systems as entities that will grow and evolve over time. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3

39 Objektorienterade applikationer d2, förel. 3
Review Work in a way that facilitates collaboration with others. Design flexible, extendible class structures. Being aware of existing design patterns will help you to do this. Continue to learn from your own and others’ experiences. Objektorienterade applikationer, DAT055, DAI2, 16/17, lp 3 DAT055, 16/17, lp 3


Download ppt "3 Designing applications"

Similar presentations


Ads by Google