The Relationships Between Classes & Objects Presented by Tim Sweeney.

Slides:



Advertisements
Similar presentations
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Advertisements

Software Engineering Key design concepts Design heuristics Design practices.
CIT731: Database Development Object Oriented Modeling (OOM)
Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Inheritance Inheritance Reserved word protected Reserved word super
Object-Oriented PHP (1)
Stéphane Ducasse«ChapterNr».1 Arthur Riel Design Heuristics from Object-Oriented Design Heuristics by Arthur Riel Read the Heuristics… –Find reasons why.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Software Testing and Quality Assurance
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
OBJECT ORIENTED ANALYSIS & DESIGN Vassilka Kirova Department of Computer & Information Science NJIT.
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Unified Modeling (Part I) Overview of UML & Modeling
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Object-oriented Programming Concepts
The Software Design Process CPSC 315 – Programming Studio Fall 2009.
L6-1-S1Design Heuristics - 1 © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department,
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
The Unified Modeling Language (UML) Class Diagrams.
IT PUTS THE ++ IN C++ Object Oriented Programming.
Objectives Design Class Diagrams Issues in system design Generalization Review UML papers.
BY VEDASHREE GOVINDA GOWDA
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Object Oriented Software Development
The Software Development Life Cycle: An Overview
The Design Discipline.
E-Learning Material Web Application Design 2. Web Application Design Use cases Guidelines Exceptions Interaction Sequence diagrams Finding objects.
Object Oriented Concepts & Principles Ingrid Kirschning & Gerardo Ayala.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Unified Modeling Language, Version 2.0
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
S.Ducasse Stéphane Ducasse 1 Design Heuristics.
GRASP: Designing Objects with Responsibilities
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
CS 4850: Senior Project Fall 2014 Object-Oriented Design.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Fundamentals of Computer Science The Object-Oriented Paradigm and UML.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Object-oriented Design and Programming CS 2210: SW Development Methods Reading: Chapter 2 of MSD text – Section on UML: look at class diagrams but.
1 Class responsibilities & relationships. 2 Responsibilities Responsibilities describe a class’s purpose in terms of its functionality Responsibilities.
Relationships Relationships between objects and between classes.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble.
Object Oriented Programming
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Object-Oriented Design Concepts University of Sunderland.
Rohini Sharma Roll No. RA1809A01 Regd. No M.Tech.(CSE) Part Time 3 rd Semester.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Object-Orientated Analysis, Design and Programming
Sections Inheritance and Abstract Classes
Relationships amongst Objects
The Movement To Objects
The Object-Oriented Thought Process Chapter 1
OOP What is problem? Solution? OOP
INTRODUCTION TO OOP Objective:
3 Fundamentals of Object-Oriented Programming
Object-Oriented Design
Lecture 22 Inheritance Richard Gesick.
The Object-Oriented Thought Process Chapter 07
CS 8532: Advanced Software Engineering
Object Oriented System Design Class Diagrams
The OOTP is intended to get you thinking about how OO concepts are used in designing object-oriented systems. Note: not talking about OO technologies that.
Presentation transcript:

The Relationships Between Classes & Objects Presented by Tim Sweeney

How are classes and objects organized best? Four basic relationships in the OO paradigm Uses Containment (implies a uses relationship as well) Inheritance Association What are the heuristics governing how to sort desired behavior into these relationships, and how best to implement them?

What are our goals for these rules? The general goals of object oriented programming Ease of understanding Potential for reuse of code Anticipating needs and fulfilling them in the design stage

Overview of heuristics Uses How do we implement the uses relationship? When can we turn use into containment? Collaboration With how many classes and in how many ways should an object collaborate with others?

Overview of heuristics Containment When is containment the right relationship? How many objects should be contained? What should an object know about its container? Semantic Constraints At what level should we impose our semantic constrains on objects?

Uses Can an object send a message directly to another class? That means a uses relationship is needed. How do we know where to send the message? #1 implementation: Containment (ATM -> Cash Dispenser) We’ll come back to this later.

Uses #2: Parameter passing #2a: Global data as parameter #3: Use of a third party class #4: Built on need #5: Defined during construction

Complexity of uses relationship # of classes X communicates with # of methods X uses to communicate # of messages sent by X’s methods We can see this illustrated in a class diagram – how many classes does one class communicate with, and how many messages are sent?

Minimization of collaboration Minimize the # of classes collaborated with Much larger design issue than methods or messages Where possible, use information hiding and containment to reduce the number of classes “Can I replace this group of classes with one class containing the group, thereby reducing the number of collaborations?”

Minimization of collaboration Minimize the number of messages sent between a class and a collaborator. Minimize the number of different messages sent. Minimize fanout (the product of the messages defined by the class and the messages they send). Balance class use with message use. Class use is harder to justify.

Containment When abstraction is possible, it should be used (this minimizes the number of classes that need to be communicated with). Containment is powerful for keeping uses relationships from getting out of hand.

Heuristics of containment Containment should always imply use. (If a containing class does not communicate with its contents, why does it have them?) exception: container classes (vector, etc.) Methods of a class should be using most of the data members most of the time. (Otherwise the class is too abstract and should be split.)

Heuristics of containment Keep the number of contained classes small. (Should fit in short-term memory or so). This is related to our earlier uses heuristic. Distribute the containment hierarchy narrowly and deeply. (Mostly for reuse.)

Attributes vs. contained classes Fundamental data without behaviors are not the same as contained classes. Don’t create classes simply to contain attributes.

More hierarchy heuristics Two balancing principles: a class should be oblivious to its container, and also oblivious to the objects it shares that container with. Oblivious to container: an AlarmClock in a BedRoom should be the same as an AlarmClock in a TimeLockSafe.

Hierarchy Oblivious to objects in same container: The container should mediate communication between its contained objects as opposed to causing uses relationships between each of them. These two principles can contradict each other—but only in certain cases.

Containment versus uses Student/Alarm clock Classroom/students Automobile/engine “If I remove the contained object, is the behavior of the containing class modified?” Yes == strong containment, or composition No == weak containment

Semantic constraints Best to keep constraints in the class definition. When not possible, put them in the behavior (usually constructor). Place the constraint as far down the containment hierarchy as possible.

Semantic information As opposed to capturing the information in the construction, we can check the state of created objects for validity when they are used. If the information is volatile, place in a third- party object. If the information is stable, place that information in the classes involved.