1 / 24

Class Diagrams Oct 20, 2006

Class Diagrams Oct 20, 2006. Recap: CRC Cards Process. Initial class list Refined class list while (More use case scenarios left) do Take a use case scenario Assign responsibilities to classes Find super- and sub-classes Find collaborators od. Today’s Lecture.

lorainel
Download Presentation

Class Diagrams Oct 20, 2006

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class Diagrams Oct 20, 2006

  2. Recap: CRC Cards Process • Initial class list • Refined class list • while (More use case scenarios left) • do • Take a use case scenario • Assign responsibilities to classes • Find super- and sub-classes • Find collaborators • od

  3. Today’s Lecture • Class Diagrams Basics • Class Diagram Notations • Classifier, attributes, operations • Interface implementation, subclassing • Dependency • Associations (multiplicities) • Application of information hiding and DSMs

  4. Example: Switch-Motor System • Scenario: Motor can run, when the Switch state is on • Class list: Switch and Motor • R1: Store the decision condition • R2: Make a decision • R3: Run the motor

  5. Class Diagram • UML Design Notation • Shows classes, their attributes and methods • Interfaces • Collaborations • Dependency, Generalization, Relationships • Remember: Design - complete description of structure and partial description of function • A class diagram describes the structure

  6. Class Diagram View Motor Switch 1 -switch:Switch -state:bool switch +run() +getState():bool

  7. Common Stereotypes • <<interface>> • <<type>> structure & behavior • <<enumeration>> collection of discrete values • <<implementationClass>> helper class • <<class>> is assumed by default

  8. Attribute Name, Types Motor - switch : Switch +run() Visibility Attribute Type Attribute Name * Also multiplicity, default value, and property

  9. Visibility • public → + • private → - • protected → # • package → ~ • derived → /

  10. Alternative Notation Motor +run() Switch -state:bool +getState():bool Multiplicity 1 switch Association (Containment)

  11. Operations: Visibility, Args, Return Types Switch -state : bool +getState(): bool +setState(bool) Return Type Visibility Operations Argument Type

  12. A Slightly Complex Example <<interface>> ISort <<interface>> IStorage +sort(IStorage) +add(int) +length():int +itemAt(int):int +setAt(int, int) +createNew():IStorage MergeSort QuickSort … … +sort(IStorage) +sort(IStorage) Array LinkedList … … +add(int) … +add(int) … SortingApplication storage:IStorage sort:ISort 1 sort storage +Main(string[]):int 1

  13. Hiding Design Decision <<interface>> IElement IntElement <<interface>> ISort item:int <<interface>> IStorage +get():int +set(int) +sort(IStorage) +add(IElement) +length():int +itemAt(int):IElement +setAt(int, IElement) +createNew():IStorage MergeSort QuickSort … … +sort(IStorage) +sort(IStorage) Array LinkedList … … +add(IElement) … +add(IElement) … SortingApplication 0..* 1 storage:IStorage sort:ISort 1 sort storage +Main(string[]):int 1

  14. Additional Dependencies <<interface>> IElement IntElement <<interface>> ISort item:int <<interface>> IStorage +get():int +set(int) +sort(IStorage) +add(IElement) +length():int +itemAt(int):IElement +setAt(int, IElement) +createNew():IStorage MergeSort QuickSort … … +sort(IStorage) +sort(IStorage) Array LinkedList … … +add(IElement) … +add(IElement) … 0..* 1 sort SortingApplication 1 1 storage:IStorage sort:ISort storage +Main(string[]):int

  15. Architectural Style: Layered <<interface>> IElement IntElement <<interface>> ISort item:int <<interface>> IStorage +get():int +set(int) SortingApplication +sort(IStorage) storage:IStorage sort:ISort +add(IElement) +length():int +itemAt(int):IElement +setAt(int, IElement) +createNew():IStorage +Main(string[]):int MergeSort QuickSort … … +sort(IStorage) +sort(IStorage) Array LinkedList … … +add(IElement) … +add(IElement) … 0..* 1 1 storage sort 1 Layer 2 Layer 1

  16. Architectural Style: 3-tiered UI <<interface>> IElement app:SortingApplication IntElement +Main(string[]):int <<interface>> ISort item:int <<interface>> IStorage +get():int +set(int) SortingApplication +sort(IStorage) storage:IStorage sort:ISort +add(IElement) +length():int +itemAt(int):IElement +setAt(int, IElement) +createNew():IStorage +sort(…):IStorage MergeSort QuickSort … … +sort(IStorage) +sort(IStorage) Array LinkedList … … +add(IElement) … +add(IElement) … 0..* 1 1 1 app storage sort 1 Layer 3 Layer 2 Layer 1

  17. Design Structure Matrix View: Naïve Design

  18. DSM View: Sorting Type & Storage Type Hidden

  19. DSM View: Element Type Hidden

  20. DSM View: UI Type Hidden

  21. Reorganized Final DSM View

  22. Summary • Class diagrams represent design structure • Three parts: name, attribute, operations • Visibility, attribute type, multiplicity • Association, association multiplicity • Generalization i.e. interface impl, subclassing • Composition i.e. class A contains class B • Applied information hiding, DSM, layering

  23. R1: Ask the user for an input list of numbers; R2: Ask the user for the choice of storage technique for the numbers. Two storage techniques are supported Array that inherits from java.util.ArrayList and Linked List that inherits from java.util.LinkedList, R3: Ask the user for the choice of sorting algorithm. Two sorting algorithms merge sort and quick sort, are supported. R4: Sort the numbers, and R5: Output the sorted numbers. Problem Description: design and implement a sorting application for positive integers. This application must: Initial Class List: Refined Class List:

More Related