Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 501: Software Engineering Fall 1999

Similar presentations


Presentation on theme: "CS 501: Software Engineering Fall 1999"— Presentation transcript:

1 CS 501: Software Engineering Fall 1999
Lecture 17 Object-Oriented Design II

2 Administration  Recitation session: Rational Rose
 Submission of Assignment 4

3 The "Hello, World" Example
import java.awt.Graphics; class HelloWorld extends java.applet.Applet { public void paint (Graphics g) { g.drawString ("Hello, World!", 0, 10); } Example from: BJR

4 Abstraction for HelloWorld
class HelloWorld paint() name annotation g.drawString ("HelloWorld", 0, 10)" operations

5 Class Diagram Applet Note that the Applet and Graphics classes are shown elided. generalization HelloWorld paint() dependency Graphics

6 Class Inheritance Diagram
Object Panel interface Component ImageObserver Applet Container HelloWorld

7 Packaging Classes java applet HelloWorld package awt Graphics lang

8 Notation for Classes and Objects
AnyClass attribute1 attribute2 operation1() operation2() anObject:AnyClass or :AnyClass or anObject or AnyClass The names of objects are underlined.

9 Sequence Diagram:Painting Mechanism
:Thread :Toolkit :ComponentPeer target:HelloWorld run run callbackLoop handleExpose paint

10 Component Diagram executable component hello.java hello.hml
HelloWorld.class hello.jpg

11 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?

12 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.

13 Candidate Classes Library the name of the system Book Journal Copy
ShortTermLoan event LibraryMember Week measure MemberOfLibrary repeat Item book or journal Time abstract term MemberOfStaff System general term Rule general term

14 Relations between Classes
Book is an Item Journal is an Item Copy is a copy of a Book LibraryMember Item MemberOfStaff is a LibraryMember Is Item needed?

15 Operations LibraryMember borrows Copy LibraryMember returns Copy
MemberOfStaff borrows Journal MemberOfStaff returns Journal Item appears not to be needed.

16 Class Diagram MemberOfStaff LibraryMember 1 1 on loan on loan 0..*
0..12 Journal Copy is a copy of 1..* Book

17 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?

18 Rough Sketch: Wholesale System
RetailStore Order Merchant Product Warehouse Shipment Invoice

19 Rough Sketch: Wholesale System
Merchant RetailStore name address contactInfo financialInfo Shipment Responsibilities -track status of shipped products Warehouse Order Product responsibility (text field) Reversals damaged() return() wrongItem() Invoice

20 Expanding a Class: Modeling Financial Information
RetailStore association * Transaction Which class is responsible for the financial records for a store? Payment Invoice

21 Modeling Invoice Shipment ??? RetailStore invoiceRecord goodsShipped
invoiceNumber +goodsShipped() -sendInvoice() PartsList adornments + public - private

22 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.

23 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.


Download ppt "CS 501: Software Engineering Fall 1999"

Similar presentations


Ads by Google