CS 43111 Collaborations and Hierarchies CS 4311 Chapters 5 and 6 of Wirfs-Brock, R., Wilkerson, B., and Wiener, L., Designing Object- Oriented Software,

Slides:



Advertisements
Similar presentations
11 Contracts CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 6)
Advertisements

Modeling Main issues: What do we want to build How do we write this down.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
1 Object-oriented design Part 2: OO tools & UML. 2 CRC cards Design tool & method for discovering classes, responsibilities, & relationships Record on.
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
Modeling Main issues: What do we want to build How do we write this down ©2008 John Wiley & Sons Ltd. vliet.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall A.1.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
UML – Class Diagrams.
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2002] February 27, 2007.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Chapter Chapter 1 Introduction to Object-Oriented Programming and Software Development.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
Chapter 10 Classes Continued
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
Unified Modeling Language
Object-Oriented Analysis and Design
Introduction To System Analysis and design
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
Object-Oriented Systems Analysis and Design Using UML
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 4th Edition Copyright © 2012 John Wiley & Sons, Inc. All rights.
Lab 04.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 Object-oriented and Structured System Models.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
CS Collaborations and Hierarchies CS 4311 Chapters 5 and 6 of Wirfs-Brock, R., Wilkerson, B., and Wiener, L., Designing Object- Oriented Software,
Class Diagrams Identifying and representing Classes Object Web, Bapayya Choudhary Maganti.
Developed by Reneta Barneva, SUNY Fredonia for CSIT 425 Requirements Modeling.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
CS Overview of CRC CS 4311 B. Beck and W. Cunningham, A Laboratory for Teaching Object-Oriented Thinking, OOPSLA ’89, October 1-6, R. Wirfs-Brock,
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
© 2005 Prentice Hall9-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Course Instructor: Kashif Ihsan 1. Chapter # 3 2.
UML as a Specification Language for Embedded Systems. By, Mir Ahmed Ali, Asst. Professor, ECM department, SNIST. By, Prof. Narsiah sir, Director of School.
Design Jon Walker. More UML ● What is UML again?
Class Diagram. Classes Software Design (UML) Class Name attributes operations A class is a description of a set of objects that share the same attributes,
CSCI-383 Object-Oriented Programming & Design Lecture 10.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design,
SWE 4743 Responsibility Driven Design with CRC cards Richard Gesick.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] CS 426 Senior Projects in Computer Science University of Nevada,
Introduction to UML and Rational Rose UML - Unified Modeling Language Rational Rose 98 - a GUI tool to systematically develop software through the following.
Chapter 11 Inheritance © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured and Object-Oriented.
UML CSE 470 : Software Engineering. Unified Modeling Language UML is a modeling language to express and design documents, software –Particularly useful.
Sections Inheritance and Abstract Classes
Main issues: • What do we want to build • How do we write this down
Chapter 5: Structural Modeling
Chapter 11 Object-Oriented Design
Collaborations and Hierarchies
Software Engineering Lecture #11.
Appendix A Object-Oriented Analysis and Design
Analysis models and design models
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Object Oriented System Design Class Diagrams
Appendix A Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Presentation transcript:

CS Collaborations and Hierarchies CS 4311 Chapters 5 and 6 of Wirfs-Brock, R., Wilkerson, B., and Wiener, L., Designing Object- Oriented Software, Prentice Hall, 1990.

2 CS 4311 Outline Collaborations  Identifying collaborations  Recording collaborations Hierarchies  Hierarchy graphs  Venn diagrams

3 CS 4311 Motivation for Collaborations Two ways to perform responsibilities  ? Collaboration is  Request from one object to another in order to fulfill a responsibility.

4 CS 4311 Motivation (Cont.) Why identify collaborations?  Collaborations represents flow of control and information through the system,  May identify misplaced responsibilities, and  May identify missing responsibilities.  In sum, shows dynamics of the system.

5 CS 4311 Finding Collaborations Look at each responsibility of each class:  Is the class capable of fulfilling this responsibility by itself?  If not, where can it get what it needs? Look at each class:  What other classes needs what this class does or knows?

6 CS 4311 Finding More Collaborations Examine relationships between classes, especially:  The “is-part-of” relationship, and  The “has-knowledge-of” relationship.

7 CS 4311 “Is-part-of” Relationship May imply responsibilities for maintaining information. May fulfill responsibilities by delegating them. Two of relationships:  Composite  Aggregate (or container) Q: Which relationship is more likely to require collaborations?

8 CS 4311 “Has-knowledge-of” Relationship May know other classes that are not in part-of relationships (i.e., associations in UML). May imply responsibilities to know information, and thus collaborations. Q: Can you think of an example?

9 CS 4311 Recording Collaborations Write the name of the server (or helper) class on the CRC card of the client. Write the name directly to the right of the responsibility the collaboration fulfills. Class: Person Responsibilities Collaborations Knows name Knows address AddressBook Knows phone number PhoneBook … Client Server (or helper)

10 CS 4311 Collaboration Graph Graphical representation of collaborations Arrow from client to a “contract” of the server, denoted by a semicircle  Contract: group of responsibilities (more on this later) Person AddressBook 1 PhoneBook 2

11 CS 4311 Example: Mail-Order System Class ResponsibilitiesCollaborators Catalog Create a catalog Mail a catalog OrderProcess an order Track an order Product Ship a product Payment Supplier Customer

12 CS 4311 Other Tools - UML UML interaction diagrams  Sequence diagram  Communication diagram (a.k.a. collaboration diagram)

13 CS 4311 Sequence Diagram message lifetime control object

14 CS 4311 Sequence Diagram Collaboration

15 CS 4311 Communication Diagram object link message

16 CS 4311 Communication Diagram Collaboration

17 CS 4311 Outline Collaborations Hierarchies  Hierarchy graph  Venn diagram

18 CS 4311 Review of CRC Process 1. Exploratory phase  Identify a preliminary list of classes, responsibilities and collaborations. 2. Analysis phase  Obtain a more global understanding of the design, e.g., by using tools such as: – Hierarchy graphs, – Venn diagrams, and – Contracts.

19 CS 4311 Hierarchy Graph A graphical representation of inheritance between related classes. A hierarchy graph is a general tree. The nodes are classes and the arcs represent inheritance. Ancestor nodes are superclasses of descendent nodes, which are subclasses.

20 CS 4311 Example - Notation of [Wirfs-Brock-etal90] - Leaf nodes are often concrete classes. - Non-leaf nodes are often abstract classes. PartTime FullTime Employee

21 CS 4311 In UML … Employee {abstract} PartTime FullTime Employee (or )

22 CS 4311 Abstract Classes Classes that cannot be instantiated. Designed only to be inherited from, thus allowing reuse and avoiding duplication. Used to factor common behaviors among classes.

23 CS 4311 Finding Abstract Classes At the exploratory stage, all identified classes are probably concrete and some may have been identified as abstract. But, do you have all your abstract classes? That is, have you used the power of abstraction (factoring behavior)?

24 CS 4311 Another Example of Hierarchy Graph Ordered Collection Indexable Collection Magnitude ArrayMatrixStringDate

25 CS 4311 Venn Diagram Another tool to understand inheritance relationships. Views a class as a set of responsibilities. Thus, an intersection among classes:  Denotes common responsibilities, and thus  May indicates an abstract superclass.

26 CS 4311 Example PartTime FullTime Employee PartTime set of responsibilities Employee set of objects PartTime FullTime Employee FullTime

27 CS 4311 Exercise Ordered Collection Indexable Collection Magnitude ArrayMatrixStringDate Draw a Venn diagram for the following hierarchy graph.

28 CS 4311 In Sum, Hierarchies … Are for reviewing the inheritance relationships, and Use hierarchy graphs and Venn diagrams as a notation and an analysis tool

29 CS 4311 Building Good Hierarchies Model “is-a” relationships. Factor common responsibilities as high as possible. Make sure abstract classes do not inherit from concrete classes. Eliminate classes that do not add functionality.

30 CS 4311 Example – Using Venn Diagram To Check Hierarchy A B If B supports only a part of responsibilities defined for A, what does the Venn diagram look like? How to fix this?

31 CS 4311 Example – Factoring Responsibilities Ellipse Element Text Element Line Element Rectangle Element Group Element Drawing Element

32 CS 4311 Group Exercise Suppose that you are designing a new Java compiler and you identified the following concrete classes for various kinds of declarations allowed in Java. - Class Declaration - Interface Declaration - Field Declaration - Method Declaration - Local Variable Declaration - Method Parameter Declaration Organize the above classes into a class hierarchy.