Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 17 Object Oriented Design II.

Similar presentations


Presentation on theme: "1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 17 Object Oriented Design II."— Presentation transcript:

1 1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 17 Object Oriented Design II

2 2 CS 501 Spring 2002 Administration Design Presentations Sign up with Rosemary Adessa Quiz 3 On Thursday this week -- no alternatives Final grades will be based on best 3 quizzes

3 3 CS 501 Spring 2002 The Waterfall Model Requirements Analysis System design Unit & Integration Testing System Testing Operation & Maintenance Program design Coding Acceptance Testing Requirements Design Implementation

4 4 CS 501 Spring 2002 The Unified Modeling Language UML is a standard language for modeling software systems Serves as a bridge between the requirements specification and the implementation. Provides a means to specify and document the design of a software system. Is process and programming language independent. Is particularly suited to object-oriented program development.

5 5 CS 501 Spring 2002 Useful Texts Grady Booch, James Rumbaugh, Ivar Jacobson, The Unified Modeling Language. Addison-Wesley 1999. Grady Booch, Object-Oriented Analysis and Design with Applications, second edition. Benjamin/Cummings 1994. Rob Pooley, Perdita Stevens, Using UML Software Engineering with Objects and Components. Addison-Wesley 1999.

6 6 CS 501 Spring 2002 Rational Rose Rational Rose is a system for creating and managing UML diagrams. It is available on all Computer Science Department computers. See: http://adm/Software/purify_install.htm for installation instructions.

7 7 CS 501 Spring 2002 The Importance of Modeling A model is a simplification of reality. We build models so that we can better understand the system we are developing. We build models of complex system because we cannot comprehend such a system in its entirety. Models can be informal or formal. The more complex the project the more valuable a formal model becomes. BRJ

8 8 CS 501 Spring 2002 Principles of Modeling The choice of what models to create has a profound influence on how a problem is attacked and how a solution is shaped. Every model can be expressed at different levels of precision. The best models are connected to reality. No single model is sufficient. Every nontrivial system is best approached through a small set of nearly independent models. BRJ

9 9 CS 501 Spring 2002 Modeling Classes Given a real-life system, how do you decide what classes to use? What terms do the users and implementers use to describe the system? They are candidates for classes. Is each candidate class crisply defined? For each class, what is its set of responsibilities? Are the responsibilities evenly balanced among the classes? What attributes and operations does each class need to carry out its responsibilities?

10 10 CS 501 Spring 2002 Noun Identification: A Library Example The library contains books and journals. It may have several copies of a given book. Some of the books are reserved for short-term loans only. All others may be borrowed by any library member for three weeks. Members of the library can normally borrow up to six items at a time, but members of staff may borrow up to 12 items at one time. Only members of staff may borrow journals. The system must keep track of when books and journals are borrowed and returned and enforce the rules.

11 11 CS 501 Spring 2002 Noun Identification: A Library Example The library contains books and journals. It may have several copies of a given book. Some of the books are reserved for short-term loans only. All others may be borrowed by any library member for three weeks. Members of the library can normally borrow up to six items at a time, but members of staff may borrow up to 12 items at one time. Only members of staff may borrow journals. The system must keep track of when books and journals are borrowed and returned and enforce the rules.

12 12 CS 501 Spring 2002 Candidate Classes Librarythe name of the system Book Journal Copy ShortTermLoanevent LibraryMember Weekmeasure MemberOfLibraryrepeat Itembook or journal Timeabstract term MemberOfStaff Systemgeneral term Rulegeneral term

13 13 CS 501 Spring 2002 Relations between Classes Bookis anItem Journalis anItem Copyis a copy of a Book LibraryMember Item MemberOfStaffis aLibraryMember Is Item needed?

14 14 CS 501 Spring 2002 Operations LibraryMemberborrowsCopy LibraryMemberreturnsCopy MemberOfStaffborrowsJournal MemberOfStaffreturnsJournal Item not needed yet.

15 15 CS 501 Spring 2002 Class Diagram MemberOfStaffBookCopyJournal is a copy of 1..* 1 LibraryMember 1 0..* 0..12 1 on loan

16 16 CS 501 Spring 2002 Rough Sketch: Wholesale System A wholesale merchant supplies retail stores from stocks of goods in a warehouse. What classes would you use to model this business?

17 17 CS 501 Spring 2002 Rough Sketch: Wholesale System RetailStore Warehouse Order Invoice Product Shipment Merchant

18 18 CS 501 Spring 2002 Rough Sketch: Wholesale System Warehouse Order Invoice Product Merchant RetailStore name address contactInfo financialInfo Shipment Responsibilities -track status of shipped products Reversal damaged() return() wrongItem() responsibility (text field)

19 19 CS 501 Spring 2002 Expanding a Class: Modeling Financial Information RetailStore Transaction 1 * association Invoice Payment Which class is responsible for the financial records for a store?

20 20 CS 501 Spring 2002 Modeling Invoice Shipment Invoice invoiceNumber +goodsShipped() -sendInvoice() goodsShipped PartsList adornments + public - private RetailStore ??? invoiceRecord

21 21 CS 501 Spring 2002 Lessons Learned Design is empirical. There is no single correct design. During the design process: Eliding: Elements are hidden to simplify the diagram Incomplete: Elements may be missing. Inconsistency: The model may not be consistent The diagram is not the whole design. Diagrams must be backed up with specifications.

22 22 CS 501 Spring 2002 Levels of Abstraction The complexity of a model depends on its level of abstraction: High-levels of abstraction show the overall system. Low-levels of abstraction are needed for implementation. Two approaches: Model entire system at same level of abstraction, but present diagrams with different levels of detail. Model parts of system at different levels of abstraction.

23 23 CS 501 Spring 2002 Actor and Use Case Diagram An actor is a user of a system in a particular role. An actor can be human or an external system. A use case is a a task that an actor needs to perform with the help of the system. Borrow book BookBorrower

24 24 CS 501 Spring 2002 Use Cases and Actors A scenario is an instance of a use case Actor is role, not an individual (e.g., librarian can have many roles) Actor must be a "beneficiary" of the use case (e.g., not librarian who processes book when borrowed) In UML, the system boundary is the set of use cases.

25 25 CS 501 Spring 2002 Use Cases for Borrowing Books Borrow copy of book BookBorrower Return copy of book Reserve book Extend loan

26 26 CS 501 Spring 2002 Relationships Between Use Cases: > BookBorrower Check for reservation Extend loan > Borrow copy of book

27 27 CS 501 Spring 2002 Relationships Between Use Cases: > Borrow copy of book BookBorrower Refuse loan >

28 28 CS 501 Spring 2002 Use Cases in the Development Cycle Use cases are a tool in requirements analysis Intuitive -- easy to discuss with clients Use cases are often hard to translate into class models Scenarios are useful to validate design

29 29 CS 501 Spring 2002 An Exam Question: Object Oriented Design A system generates weather maps using data collected from unattended weather stations. Each weather station collects meteorological data and produces summaries of the data. On request, it sends the summary information to an area computer. The area computer uses a database of digitized maps to generate a set of local weather maps.

30 30 CS 501 Spring 2002 Exam Question: Noun Identification A system generates weather maps using data collected from unattended weather stations. Each weather station collects meteorological data and produces summaries of the data. On request, it sends the summary information to an area computer. The area computer uses a database of digitized maps to generate a set of local weather maps.

31 31 CS 501 Spring 2002 Exam Question: Candidate Classes Systemgeneral term WeatherMap Datasame as MeteorologicalData WeatherStationis this a general term? MeteorologicalDatahow does this relate to WeatherStation? DataSummaryhow does this relate to MeteorologicalData? AreaComputerhardware Databasegeneral term DigitizedMap

32 32 CS 501 Spring 2002 Exam Question: Observations about the Candidate Classes WeatherMapis a DigitizedMap is derived from 1...* DataSummary WeatherStationhas a set of MeteorologicalData MeteorologicalData DataSummaryis derived from MeteorologicalData DigitizedMap Can Meteorological Data be an attribute of WeatherStation? Can DataSummary be combined with WeatherMap?

33 33 CS 501 Spring 2002 Exam Question: Attributes and Operations WeatherStation location metereologicalData collectData() getSummary() WeatherMap location date-time geographicData weather gatherData() printMap() DigitizedMap location geographicData printMap() Or should MetereologicalData be a separate object?

34 34 CS 501 Spring 2002 Exam Question: Class Diagram DigitizedMap 1...* 1 WeatherStation location metereologicalData collectData() getSummary() WeatherMap location date-time geographicData weather gatherData() printMap() summary


Download ppt "1 CS 501 Spring 2002 CS 501: Software Engineering Lecture 17 Object Oriented Design II."

Similar presentations


Ads by Google