S.Ducasse Stéphane Ducasse 1 Design Heuristics.

Slides:



Advertisements
Similar presentations
Software Engineering Class design. Class design – ADT Abstract Data Types:  Why use ADT? Hidden implementation details Changes do not affect whole program.
Advertisements

Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
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 Java permits you to use your user defined classes to create programs using inheritance.
Stéphane Ducasse2.1 OOP? What is OOP? Why? OOP in a nutshell.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
Stéphane Ducasse«ChapterNr».1 Arthur Riel Design Heuristics from Object-Oriented Design Heuristics by Arthur Riel Read the Heuristics… –Find reasons why.
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Basic OOP Concepts and Terms
November 13, 2006ECEN 5543 / CSCI 5548 – Testing OO University of Colorado, Boulder 1 Testing Object-Oriented Software Principles Summary ECEN 5543 / CSCI.
Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.
The Relationships Between Classes & Objects Presented by Tim Sweeney.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Lecturer: Dr. AJ Bieszczad Chapter 66-1 Object-Oriented analysis and design Special nature of OO development Use cases Design with UML OO system design.
PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Chapter 10 Class and Method Design
L6-1-S1Design Heuristics - 1 © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department,
Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION.
CSE 403 Lecture 7 UML Class Diagrams Reading:
BACS 287 Basics of Object-Oriented Programming 1.
1 CSE 403 Object-Oriented Design Reading: Object Oriented Design Heuristics Ch. 2-3, by Authur Riel These lecture slides are copyright (C) Marty Stepp,
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
1 CSE 331 Object-Oriented Design Heuristics slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
S.Ducasse Stéphane Ducasse 1 Classes and Metaclasses - an Analysis.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Relational Databases and Transaction Design Lecture 27.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Class Diagrams Identifying and representing Classes Object Web, Bapayya Choudhary Maganti.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
Object-Oriented Design Justin Callanan CS 597. Object-Oriented Basics ● Data is stored and processed in “objects” ● Objects represent generalized real.
Chapter 12 Support for Object oriented Programming.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
S.Ducasse Stéphane Ducasse 1 Object-Oriented Programming.
Relationships Relationships between objects and between classes.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
1 TCSS 360, Spring 2005 Lecture Notes Design Guidelines 2 Relevant Reading: Object-Oriented Design Heuristics Arthur Riel.
Internet and Intranet Protocols and Applications Lecture 5a: HTTP Client-Server Design and Implementation February 15, 2005 Arthur Goldberg Computer Science.
Object-Oriented Principles Applications to Programming.
Classes and Objects: The Building Blocks of the Object-Oriented Paradigm Presented by Tara Struble.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Why Use Classes - Anatomy of a Class.
S.Ducasse Stéphane Ducasse 1 Essential OO Concepts Stéphane Ducasse.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Analysis Yaodong Bi. Introduction to Analysis Purposes of Analysis – Resolve issues related to interference, concurrency, and conflicts among use cases.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
Stéphane Ducasse 1 Some Points on Classes.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Object and Class Structuring Chapter 9 Part of Analysis Modeling Designing Concurrent, Distributed, and Real-Time Applications with UML Hassan Gomaa (2001)
Exceptions Lecture 11 COMP 401, Fall /25/2014.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Lecture 12 Implementation Issues with Polymorphism.
Chapter 6: The Analysis Workflow Chapter 7: Classes and Objects Chapter 8: Finding Analysis Classes [Arlow and Neustadt, 2005] CS 426 Senior Projects in.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
CSCE 240 – Intro to Software Engineering Lecture 3.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
TIM 58 Chapter 8: Class and Method Design
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
CIS 375 Bruce R. Maxim UM-Dearborn
Basic OOP Concepts and Terms
CS 112 Programming 2 Lecture 02 Abstract Classes & Interfaces (2)
CSE 403 Object-Oriented Design Reading:
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Presentation transcript:

S.Ducasse Stéphane Ducasse 1 Design Heuristics

S.Ducasse License: CC-Attribution-ShareAlike

S.Ducasse 3 Roadmap Inspired from Object-Oriented Design Heuristics by Arthur Riel Read the Heuristics… Find reasons why We will discuss them during the lectures

S.Ducasse 4 Different Relationships Uses Contains Specializes

S.Ducasse 5 Hidding Data All data should be hidden within its class

S.Ducasse 6 No Dependence on Clients Users of a class must be dependent on its public interface, but a class should not be dependent on its users

S.Ducasse 7 Class = one Clear Responsibility Minimize the number of messages in the protocol of a class

S.Ducasse 8 Supporting Polymorphism Implement a minimal interface that all classes understand To send the same message to different objects To be able to substitute them Remember: grObjects do: [:each | each translate: Example: Object>>printString, Object>>copy…

S.Ducasse 9 Clear Public Interface Do not put implementations details such as common-code private functions into the public interface of a class Example: Private/protected in C++ Private method categories in Smalltalk Do not clutter the public interface of a class with items that clients are not able to use or are not interested in using

S.Ducasse 10 Minimize Class Interdependencies A class should only use operations in the public interface of another class or have nothing to do with that class

S.Ducasse 11 Class = one Responsibility A class should capture one and only one key abstraction

S.Ducasse 12 Strengthen Encapsulation Keep related data and behavior in one place Spin off non related information into another class => Move Data Close to Behavior

S.Ducasse 13 Object: a Cohesive Entity Most of the methods defined on a class should be using most of the instance variables most of the time

S.Ducasse 14 Roles vs. Classes Be sure the abstractions you model are classes and not the roles objects play Are mother and father classes or role of Person? No magic answer: Depend on the domain Do they have different behavior? So they are more distinct classes

S.Ducasse 15 one Class = one Responsibility Distribute system intelligence horizontally as uniformly as possible, i.e., the top-level classes in a design should share the work

S.Ducasse 16 one Class = one Responsibility Do not create god classes/objects (classes that control all other classes). Be very suspicious of class whose names contains Driver, Manager, System, SubSystem.

S.Ducasse 17 Model and Interfaces Model should never be dependent on the interface that represents it. The interface should be dependent on the model What is happening if you want two different Uis for the same model?

S.Ducasse 18 Basic Checks for God Class Beware of classes that have many accessor methods defined in their public interface. May imply that data and behavior is not being kept at the same place Beware of classes having methods that only operate on a proper subset of the instance variables.

S.Ducasse 19 One Class: One Responsibility One responbility: coordinating and using other objects OrderedCollection maintains a list of objects sorted by arrival order: two indexes and a list Class should not contain more objects than a developper can fit in his short-term memory. (6 or 7 is the average value)

S.Ducasse 20 Classes Evaluation Model the real world whenever possible Eliminate irrelevant classes Eliminate classes that are outside of the system A method is not a class. Be suspicious of any class whose name is a verb or derived from a verb, especially those that only one piece of meaningful behavior

S.Ducasse 21 Minimizing Coupling between Classes Minimize the number of classes with which another class collaborates Minimize the number of messages sent between a class and its collaborators Counter example: Visitor patterns Minimize the number of different messages sent between a class and its collaborators

S.Ducasse 22 Use

S.Ducasse 23 About the Use Relationship When an object use another one it should get a reference on it to interact with it Ways to get references (containment) instance variables of the class Passed has argument Ask to a third party object (mapping…) Create the object and interact with it

S.Ducasse 24 Containment and Uses If a class contains object of another class, then the containing class should be sending messages to the contained objects (the containment relationship should always imply a uses relationships) A object may know what it contains but it should not know who contains it.

S.Ducasse 25 Representing Semantics Constraints How do we represent possibilities or constraints between classes? Appetizer, entrée, main dish… No peas and corn together… It is best to implement them in terms of class definition but this may lead to class proliferation => implemented in the creation method

S.Ducasse 26 Objects define their logic When implementing semantic constraints in the constructor of a class, place the constraint definition as far down a containment hierarchy as the domain allows => Objects should contain the semantic constraints about themselves

S.Ducasse 27 Third party constraint holder If the logic of a constraint is volatile, then it is better to represent it in a separate object

S.Ducasse 28 Classes - Subclasses Superclass should not know its subclasses Subclasses should not use directly data of superclasses If two or more classes have common data and behavior, they should inherit from a common class that captures those data and behavior

S.Ducasse 29 Controversial All abstract classes must be base classes All base classes should be abstract classes => Not true they can have default value method

S.Ducasse 30 Avoid Type Checks Explicit case analysis on the type of an objects is usually an error. An object is responsible of deciding how to answer to a message A client should send message and not discriminate messages sent based on receiver type

S.Ducasse 31 Summary Digest Read code Think about it Be critic