! Needles Complexity! make design more general than needed " e.g. interfaces and/or abstract classes with just one implementor

Size: px
Start display at page:

Download "! Needles Complexity! make design more general than needed " e.g. interfaces and/or abstract classes with just one implementor"

Transcription

1 Bibliography Principles and Rules of Object-Oriented Design Dr. Radu Marinescu 67 Dr. Radu Marinescu 68 Signs of Rotting Design [Martin, 2002]! Rigidity! code difficult to change (Continuity)! management reluctance to change anything becomes policy! Fragility! code breaks in unexpected places (Protection)! even small changes can cause cascading breaks! Immobility! code is so tangled that it's impossible to reuse anything (Composability) " lots of semantical (or even syntactical) duplication! Viscosity! much easier to hack than to preserve original design " easy to do the wrong thing, but hard to do the right thing (R.Martin)! software viscosity and environment viscosity Dr. Radu Marinescu 69 Signs of Rotting Design (2) [Martin, 2002]! Needles Complexity! make design more general than needed " e.g. interfaces and/or abstract classes with just one implementor! constructs and mechanisms that are never used! Needles Repetition! copy-paste-adapt " bugs are cloned as well! sign of a missing abstraction! Opacity! convoluted manner of writing code (hampers understandability)! pair-programming and refactoring may help fighting against opaque code Dr. Radu Marinescu 70

2 Causes of Rotting Design 1. Changing Requirements! is inevitable! both better designs and poor designs have to face the changes;! good designs are stable All systems change during their life-cycles. This must be borne in mind when developing systems expected to last longer than the first version. I. Jacobson, OOSE, 1992 Read Keyboard Copy Example of Rigidity and Immobility Write Disk Write Printer enum OutputDevice {printer, disk; void Copy(OutputDevice dev){ int c; while((c = ReadKeyboard())!= EOF) if(dev == printer) WritePrinter(c); else WriteDisk(c); 2. Dependency Management! the issue of coupling and cohesion! It can be controlled! " create dependency firewalls Dr. Radu Marinescu 71 void Copy(){ int c; while ((c = ReadKeyboard())!= EOF) WritePrinter(c); Dr. Radu Marinescu 72 Open-Closed Principle (OCP) Software entities should be open for extension, but closed for modification B. Meyer, 1988 / quoted by R. Martin, 1996 Open the door...! Be open for extension! module's behavior can be extended! Be closed for modification! source code for the module must not be changed Modules should be written so they can be extended without requiring them to be modified How to make the Car run efficiently with a TurboEngine? Only by changing the Car!...in the given design Dr. Radu Marinescu 73 Dr. Radu Marinescu 74

3 ... But Keep It Closed! OCP Heuristics RTTI is Ugly and Dangerous!! A class must not depend on a concrete class!! It must depend on an abstract class......using polymorphic dependencies (calls)! RTTI is ugly and dangerous! RTTI = Run-Time Type Information! If a module tries to dynamically cast a base class pointer to several derived classes, any time you extend the inheritance hierarchy, you need to change the module! recognize them by type switch or if-else-if structures! Not all these situations violate OCP all the time! when used only as a "filter" Dr. Radu Marinescu 75 Dr. Radu Marinescu 76 Reader Keyboard Reader Copy Writer Printer Writer OCP Applied on Example Disk Writer class Reader { public: virtual int read()=0; ; class Writer { public: virtual void write(int)=0; ; void Copy(Reader& r, Writer& w){ int c; while((c = r.read())!= EOF) w.write(c); What if we decide to change that only each second character is written? Strategic Closure No significant program can be 100% closed! Closure not complete but strategic 1. Abstraction to gain explicit closure! provide class methods which can be dynamically invoked " to determine general policy decisions! design using abstract ancestor classes 2. Use "Data-Driven" approach to achieve closure! place volatile policy decisions in a separate location " e.g. a file or a separate object! minimizes future change locations R.Martin Dr. Radu Marinescu 77 Dr. Radu Marinescu 78

4 Use Abstract to Gain Closure [Martin, 2002] Data-Driven Approach to Get Closure [Martin, 2002] public interface Shape : IComparable{ void Draw(); public class Circle : Shape { public int CompareTo(object o){ if(o is Square) return -1; else return 0; Not Closed anymore to adding new Shapes! public void DrawAllShapes(ArrayList shapes) { shapes.sort(); foreach(shape shape in shapes) shape.draw(); public class ShapeComparer : IComparer { private static Hashtable priorities = new Hashtable(); static ShapeComparer() { priorities.add(typeof(circle), 1); priorities.add(typeof(square), 2); private int PriorityFor(Type type) { if(priorities.contains(type)) return (int)priorities[type]; else return 0; Dr. Radu Marinescu 79 Dr. Radu Marinescu 80 Data-Driven Approach to Get Closure (2) [Martin, 2002] Procedural Architecture is Top-Down public int Compare(object o1, object o2) { int priority1 = PriorityFor(o1.GetType()); int priority2 = PriorityFor(o2.GetType()); return priority1.compareto(priority2); Procedural Architecture public void DrawAllShapes(ArrayList shapes) { shapes.sort(new ShapeComparer()); foreach(shape shape in shapes) shape.draw(); Dr. Radu Marinescu 81 Dr. Radu Marinescu 82

5 Dependency Inversion Principle I. High-level modules should not depend on low-level modules. Both should depend on abstractions. II. Abstractions should not depend on details. Details should depend on abstractions R. Martin, 1996 Procedural Architecture Procedural vs. OO Architecture! Corrolar 1: A base class in an inheritance hierarchy should not know any of its subclasses! Corrolar 2: Modules with detailed implementations are not depended upon, but depend themselves upon abstractions! OCP states the goal; DIP states the mechanism; Object-Oriented Architecture Dr. Radu Marinescu 83 Dr. Radu Marinescu 84 DIP Related Heuristic Design to an interface, not an implementation! Design to an Interface! Abstract classes/interfaces:! tend to change less frequently! abstractions are hinge points where it is easier to extend/modify! shouldn t have to modify classes/interfaces that represent the abstraction (OCP)! Use inheritance to avoid direct bindings to classes: Client Interface (abstract class) Implementation (concrete class)! Exceptions! Some classes are very unlikely to change; " therefore little benefit to inserting abstraction layer " Example: String class! In cases like this can use concrete class directly " as in Java or C++ Dr. Radu Marinescu 85 Dr. Radu Marinescu 86

6 DIP Related Heuristic (2) Avoid Transitive Dependencies Solution to Transitive Dependencies! Use inheritance and abstract ancestor classes to effectively eliminate transitive dependencies:! also a matter of interface ownership! Avoid structures in which higher-level layers depend on lower-level abstractions:! In example below, Policy layer is ultimately dependent on Utility layer. Policy Layer depends on Policy Service Interface Policy Layer depends on Mechanism Layer depends on Utility Layer Mechanism Layer depends on Mechanism Service Interface Utility Layer Dr. Radu Marinescu 87 Dr. Radu Marinescu 88 DIP - Related Heuristic When in doubt, add a level of indirection! If you cannot find a satisfactory solution for the class you are designing, try delegating responsibility to one or more classes: When in doubt...! It is generally easier to remove or by-pass existing levels of indirection than it is to add them later: Blue class s indirect message calls to red class fail to meet some criteria (e.g. real-time constraints, etc.) Problem Holder Problem Solver So, Blue class re-implements some or all of green class s responsibilities for efficiency and calls red object directly X Dr. Radu Marinescu 89 Dr. Radu Marinescu 90

7 LSP and Replaceability Any code which can legally call another class s methods must be able to substitute any subclass of that class without modification: Liskov Substitution Principle Client Service Class Client Service Class Unexpected Subclass Dr. Radu Marinescu 91 Dr. Radu Marinescu 92 Liskov Substitution Principle (LSP)! The key of OCP: Abstraction and Polymorphism! Implemented by inheritance! How do we measure the quality of inheritance? Inheritance should ensure that any property proved about supertype objects also holds for subtype objects B. Liskov, 1987 Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. R. Martin, 1996 LSP is about Semantics and Replacement! Understand before you design! The meaning and purpose of every method and class must be clearly documented! Lack of user understanding will induce de facto violations of LSP! Replaceability is crucial! Whenever any class is referenced by any code in any system, any future or existing subclasses of that class must be 100% replaceable! Because, sooner or later, someone will substitute a subclass; " it s almost inevitable. Dr. Radu Marinescu 93 Dr. Radu Marinescu 94

8 Inheritance Appears Simple class Bird { // has beak, wings,... public void fly() {... // Bird can fly class Parrot : public Bird { // Parrot is a bird public void mimic() {... // Can Repeat words... public void fly() {... // Parrots fly in a specific way ; //... Parrot mypet; mypet.mimic(); mypet.fly(); // my pet being a parrot can Mimic() // my pet is-a bird, can fly Penguins Fail to Fly! class Penguin extends Bird { public void fly() { error ( Penguins don t fly! ); void PlayWithBird (Bird abird) { abird.fly(); // OK if Parrot. // if bird happens to be Penguin...OOOPS!!! Does not model: Penguins can t fly. It models Penguins may fly, but if they try it is error! Run-time error if attempt to fly! not desirable! Think about Substitutability - Fails LSP Dr. Radu Marinescu 95 Dr. Radu Marinescu 96 Design by Contract! Advertised Behavior of an object:! advertised Requirements (Preconditions)! advertised Promises (Postconditions) When redefining a method in a derivate class, you may only replace its precondition by a weaker one, and its postcondition by a stronger one B. Meyer, 1988 Derived class services should require no more and promise no less int Base::f(int x); // REQUIRE: x is odd // PROMISE: return even int int Derived::f(int x); // REQUIRE: x is int // PROMISE: return 8 Design by Contract! Impose a certain obligation to be guaranteed on entry by any client module that calls it: the routine's precondition! Guarantee a certain property on exit: the routine's postcondition! Maintain a certain property, assumed on entry and guaranteed on exit: the class invariant! What does it expect?! What does it guarantee?! What does it maintain? Dr. Radu Marinescu 97 Dr. Radu Marinescu 98

9 Square IS-A Rectangle? Square The Answer is...! Override setheight and setwidth! duplicated code...?! The real problem void g(rectangle& r) { r.setwidth(5); r.setheight(4); // How large is the area?! 20!... Are you sure? ;-)! Should I inherit Square from Rectangle? Dr. Radu Marinescu 99 IS-A relationship refers to the BEHAVIOR of the class! Dr. Radu Marinescu 100 LSP Related Heuristic (2) It is illegal for a derived class, to override a base-class method with a NOP method! NOP = a method that does nothing! Solution 1: Inverse Inheritance Relation! if the initial base-class has only additional behavior " e.g. Dog - DogNoWag! Solution 2: Extract Common Base-Class! if both initial and derived classes have different behaviors! for Penguins! Birds, FlyingBirds, Penguins! Classes with bad state! e.g. stupid or paralyzed dogs... Single Responsibility Principle (SRP) A class should have only one reason to change!! A Responsibility is a reason to change! Single Responsibility = increased cohesion! Not following results in needless dependencies! More reasons to change.! Rigidity, Immobility! Can be tricky to get granularity right R. Martin Dr. Radu Marinescu 101 Dr. Radu Marinescu 102

10 When SRP is violated...! The Rectangle has 2 responsibilities... due to the various clients When SRP is considered...! The bad part: ComputationalGeometryApplication depends now on GUI! could be either aggregation or inheritance! Dr. Radu Marinescu 103 Dr. Radu Marinescu 104 Common Violation of SRP! mix business rules and persistence control! should almost never be mixed! business rules change often ; persistency rules change sometimes but always for different reasons Clients should depend on slim interfaces... Dr. Radu Marinescu 105 Dr. Radu Marinescu 106

11 Interface Segregation Principle ISP Example Clients should not be forced to depend upon interfaces that they do not use. R. Martin, 1996! Door and Timed Door! lock(), unlock(), isopen()! TimedDoor beeps when door is open for too long Timer TimerClient 0..* Naïve!! Many client-specific interfaces are better than one general purpose interface Door! Consequence:! impact of changes to one interface aren t as big if interface is smaller! interface pollution clas Timer { public void register(int timeout, TimerClient cl); // ; interface TimerClient { void OnTimeOut()=0; TimedDoor Dr. Radu Marinescu 107 Dr. Radu Marinescu 108 What Can Happen?! What if......i close the door before the timeout and then open it again? :)) Separation through Multiple Interfaces! in fact implementation of multiple interfaces -> we need to identify the timeout request -> change affects the interface of TimerClient -> all clients get affected! public class Timer { public void Register(int timeout, int timeoutid, TimerClient client) {/*code*/ public interface TimerClient { void TimeOut(int timeoutid); Why should a Door subclass, that is not related to timing be affected by this change?!! Dr. Radu Marinescu 109 Dr. Radu Marinescu 110

12 Separation Through Delegation Timer 0..* TimerClient Door +ontimeout() DoorTimer Adapter thetimeddoor <<creates>> TimedDoor +reactontimeout() Rela!ii intre Clase si Obiecte ontimeout(...) { thetimeddoor.reactontimeout(...); Dr. Radu Marinescu 111 Dr. Radu Marinescu 112 Implementare Relatiei USES Prin Continere 1. Continere 2. Referinta 3. Mapare 4. Parametrii 5. Prin Constructie (Locala) 6. Prin Date Globale Prin Referinta Oracolul din Delfi ii spune cine e obietul cu care sa comunice Dr. Radu Marinescu 113 Dr. Radu Marinescu 114

13 Prin Mapper Prin Constructie Prin Parametri Prin Date Globale Dr. Radu Marinescu 115 Dr. Radu Marinescu 116 Ce conteaza cand e vorba de cuplaj? Exercitiu: In care din urmatoarele situatii cuplajul este mai redus? X Y Shy Code [PragmaticProgrammer99]! Spy, dissidents and revolutionaries! eliminating interactions protects anyone! The General contractor example! he must manage subcontractors f11() f12() f13() f11() f12() f13() Cati apeleaza? (Impact Eroare Unica)! Don't reveal yourself to others! Information Hiding modularization rule! Don't interact with too many people! Few Interfaces modularization rule Cati sunt apelati? (Impact Decuplare, Probabilitate Eroare) Dr. Radu Marinescu 117 Dr. Radu Marinescu 118

14 Law of Demeter! Weak Form Inside of a method M of a class C, data can be accessed in and messages can be sent to only the following objects:! this and super! data members of class C! parameters of the method M! object created within M " by calling directly a constructor " by calling a method that creates the object! global variables! Strong Form: In addition to the Weak Form, you are not allowed to access directly inherited members Dr. Radu Marinescu 119 class Demeter { private: A *a; public: // void example(b& b); void Demeter::example(B& b) { C c; func(); b.invert(); a = new A(); a->setactive(); c->print(); Demeter s Law on Example Any methods of an object should call only methods belonging to: itself passed parameters created objects directly held component objects Dr. Radu Marinescu 120 class Course { Instructor boring = new Instructor(); int pay = 5; public Instructor getinstructor() { return boring; public Instructor getnewinstructor() {return new Instructor(); public int getpay() {return pay; class C { Course test = new Course(); Example of LoD Violation public void badm() { test.getinstructor().fired(); public void goodm() { test.getnewinstructor().hired(); class Course { Instructor boring = new Instructor(); int pay = 5; public Instructor fireinstructor() { boring.fired(); public Instructor getnewinstructor() { return new Instructor(); public int getpay() { return pay ; class C { Course test = new Course(); How to eliminate the LoD violation? public void reformedbadm() { test.fireinstructor(); public void goodm() { test.getnewinstructor().hired(); public int goodorbadm?() { return test.getpay() + 10; public int goodorbadm() { return test.getpay() + 10; Dr. Radu Marinescu 121 Dr. Radu Marinescu 122

15 Breaking News Dr. Radu Marinescu 123 Dr. Radu Marinescu 124 The Law of Demeter for Children ;-)! You can play with yourself.! You can play with your own toys, but you can't take them apart! You can play with toys that were given to you.! You can play with toys you've made yourself. Benefits of Demeter s Law! Coupling Control! reduces data coupling! Information hiding! prevents from retrieving subparts of an object! Information restriction! restricts the use of methods that provide information! Experimental study [Basili et al., TSE, 1996] suggest that the Law of Demeter is a valid way to reduce the probability of software faults. Dr. Radu Marinescu 125 Dr. Radu Marinescu 126

16 Acceptable LoD Violations Euristici Legate De Cuplaj! If optimization requires violation! Speed or memory restrictions! Make a distinction between objects and data structures! If module accessed is a fully stabilized black box! No changes to interface can reasonably be expected due to extensive testing, usage, etc. Reduceti numarul claselor de care depinde fiecare clasa! Reduceti numarul de metode distincte apelate dintr-o clasa data! Reduceti numarul de apeluri catre alte clase pentru o clasa data!!...otherwise, do not violate this law!!! Long-term costs will be very prohibitive Dr. Radu Marinescu 127 Dr. Radu Marinescu 128 Relatia de CONTINERE (CONTAINMENT) Care clasa ai prefera sa o utilizezi? Daca o clasa, contine obiecte ale altei clase, atunci clasa care contine obiectele trebuie sa foloseasca acele obiecte. Ea si numai ea!... altfel relatia de continere e falsa!! fie clasa care contine nu are nevoie de respectivele date! fie ele sunt plasate gresit (daca sunt folosite mai mult de catre o alta clasa). A B NU CONTEAZA! Dr. Radu Marinescu 129 Dr. Radu Marinescu 130

17 Care clasa ai prefera sa o implementezi? Forma ideala a ierarhiilor de continere B Organizati relatii de continere in ierarhii adanci si inguste A Majoritate metodelor unei clase ar trebui sa foloseasca majoritatea datelor clasei!... pentru ca nu mai accesam datele partilor ci identificam servicii ale acestora! castigam flexibilitatea # modalitati multiple de reutilizare! In general ar fi bine ca o clasa sa nu contina mai mult de 6 obiecte ca atribute! Ce se intampla daca doar cateva metode folosesc majoritatea datelor? ;-) Dr. Radu Marinescu 131 Dr. Radu Marinescu 132 Constrangeri Semantice... adica ce ne facem daca avem limitari in privinta compunerii felurilor de mancare? $! Solutia I! nu las sa se construiasca obiectul! constrangerea semantica este plasata in constructorul obiectul care agrega Principles of High-Level Design! Solutia II! constructorul permitea construirea unor obiecte ilegale! testarea se face la nivelul metodelor care folosesc obiectul... o sa vedeti voi cand vorbim despre Composite ;-) Dr. Radu Marinescu 133 Dr. Radu Marinescu 134

18 High-Level Design! Dealing with large-scale systems! > 50 KLOC! team of developers, rather than an individual! Classes are a valuable but not sufficient mechanism! too fine-grained for organizing a large scale design! need mechanism that impose a higher level of order " clusters (Meyer); class-category (Booch); subject-areas (Coad) Packages! a logical grouping of declarations that can be imported in other programs (in Java and Ada)! containers for a group of classes (UML) " reason at a higher-level of abstraction Issues of High-Level Design Goal!partition the classes in an application according to some criteria and then allocate those partitions to packages Issues! What are the best partitioning criteria?! What principles govern the design of packages? " creation and dependencies between packages! Design packages first? Or classes first? " i.e. top-down vs. bottom-up approach Approach!Define principles that govern package design " the creation and interrelationship and use of packages Dr. Radu Marinescu 135 Dr. Radu Marinescu 136! Acyclic Dependencies Principle (ADP)! Stable Dependencies Principle (SDP)! Stable Abstractions Principle (SAP) Coupling Principles of OO HLD Morning-After Syndrome! You go home and discover the next morning that your stuff is not working anymore WHY?! Some worked later than you ;-)! Morning-After syndrome! Many developers modify the same source files! Unable to build a stable version of the system! Everyone tries to adapt to the changes that other made! Two solutions 1. Weekly Build 2. Eliminating Dependency Cycles Dr. Radu Marinescu 137 Dr. Radu Marinescu 138

19 The Weekly Build! Everyone ignores the other for 4 days out of 5! Works on private copies of the code! Friday the whole system is integrated! Less feasible as program grows! Build flows over in Saturday! May be it should start already on Thursday! Creeps toward the middle of the week Eliminating Dependency Cycles! Partition work in reusable packages (i.e. units of work)! When a package is working it is released for the others! Users get notified!they can decide if they want to integrate or not " They choose the integration moment " None of the teams is at the mercy of others! One Precondition: there can be no cycles in the package structure!! Bi-weekly build still not scalable Dr. Radu Marinescu 139 Dr. Radu Marinescu 140 Acyclic Graph of Dependencies! Directed Graph! Arrows indicate who depends on whom Cyclic Dependencies! When MyDialogs changes only a few other packages are affected! When MyDialogs is tested, it depends only on Windows! Release of the whole system bottom-up Dr. Radu Marinescu 141 Dr. Radu Marinescu 142

20 Acyclic Dependencies Principles (ADP) Breaking the Cycles The dependency structure for released component must be a Directed Acyclic Graph (DAG) There can be no cycles. R. Martin, 1996 Dr. Radu Marinescu 143 Dr. Radu Marinescu 144 Reader Keyboard Reader Copy Copy Program Revisited Writer Printer Writer Disk Writer class Reader { public: virtual int read()=0; ; class Writer { public: virtual void write(int)=0; ; void Copy(Reader& r, Writer& w){ int c; while((c = r.read())!= EOF) w.write(c); Why are these dependencies good? (better than earlier) Good Dependencies! Targets of unavoidable dependencies are non-volatile! unlikely to change! e.g. Reader and Writer classes have a low volatility " the Copy class is immune to changes A Good Dependency is a dependency upon something with low volatility. Dr. Radu Marinescu 145 Dr. Radu Marinescu 146

21 Stability! defined as not easily moved! a measure of the difficulty in changing a module! not a measure of the likelihood of a change! Responsibility = how many depend on a module?! Autonomy = on how many does a module depend? Stability = Responsibility + Autonomy Stability Metrics! Afferent Coupling (C a )!number of classes outside this package that depend upon the measured package " "how responsible am I?" (FAN-IN)! Efferent Coupling (C e )!number of classes outside this package that classes within the measured package depend on " "how dependent am I?" (FAN-OUT)! Instability Factor (I)! I # [0, 1]! 0 = totally stable; 1 = totally unstable Dr. Radu Marinescu 147 Dr. Radu Marinescu 148 Computing Stability Metrics Ca = 4 Ce = 3 I = 3 / 7 Stable Dependencies Principle (SDP) The dependencies between components in a design should be in the direction of stability. A component should only depend upon components that are more stable than it is. R. Martin, 1996 Depend only upon components whose I metric is lower than yours R. Martin, 1996 SDP Violation Dr. Radu Marinescu 149 Dr. Radu Marinescu 150

22 Where to Put High-Level Design?! High-level architecture and design decisions don't change often! shouldn't be volatile " place them in stable packages! design becomes hard to change " inflexible design! How can a totally stable package (I = 0) be flexible enough to withstand change?! improve it without modifying it...! Answer: The Open-Closed Principle! classes that can be extended without modifying them " Abstract Classes Stable Abstractions Principle (SAP) The abstraction of a package should be proportional to its stability! Packages that are maximally stable should be maximally abstract. Unstable packages should be concrete. R. Martin, 1996! Ideal Architecture!Unstable (changeable) packages on the top " must be concrete!stable (hard to change) package on the bottom " hard to change, but easy to extend " highly abstract (easily extended) " Interfaces have more intrinsic stability than executable code! SAP is a restatement of DIP Dr. Radu Marinescu 151 Dr. Radu Marinescu 152! Abstraction of a Package! A # [0, 1]! 0 = no abstract classes! 1 = all classes abstract Measuring Abstraction The Main Sequence! Metric A is imperfect, but usable!hybrid classes are also counted as abstract "including pure virtual functions! Alternative!find a metric based on the ratio of virtual functions Instability (I) should increase as abstraction (A) decreases. R. Martin, 2000 Dr. Radu Marinescu 153 Dr. Radu Marinescu 154

23 Main Sequence (contd.)! Zone of Pain! highly stable and concrete " rigid! famous examples: " database-schemas (volatile and highly depended-upon) " concrete utility libraries (unstable but non-volatile)! Zone of Uselessness! unstable and abstract " useless " no one depends on those classes! Main Sequence! maximizes the distance between the zones we want to avoid! depicts the balance between abstractness and stability.! Distance! Normalized Distance Measurement of OO Architectures!ranges from [0, ~0.707]!ranges from [0, 1]! 0 = package on the main sequence! 1 = package far away from main seq. Dr. Radu Marinescu 155 Dr. Radu Marinescu 156

Principles of Object-Oriented Design

Principles of Object-Oriented Design Principles of Object-Oriented Design 1 The Object-Oriented... Hype What are object-oriented (OO) methods? OO methods provide a set of techniques for analysing, decomposing, and modularising software system

More information

! Needles Complexity! make design more general than needed " e.g. interfaces and/or abstract classes with just one implementor

! Needles Complexity! make design more general than needed  e.g. interfaces and/or abstract classes with just one implementor Bibliography Principles and Rules of Object-Oriented Design Dr. Radu Marinescu 66 Dr. Radu Marinescu 67 Signs of Rotting Design [Martin, 2002]! Rigidity! code difficult to change (Continuity)! management

More information

Principles of Object-Oriented Design

Principles of Object-Oriented Design Principles of Object-Oriented Design Part II 1 The Law of Demeter Any object receiving a message in a given method must be one of a restricted set of objects. 1. Strict Form: Every supplier class or object

More information

SOLID: Principles of OOD

SOLID: Principles of OOD SOLID: Principles of OOD CS480 Software Engineering http://cs480.yusun.io February 18, 2015 Yu Sun, Ph.D. http://yusun.io yusun@cpp.edu Software Nature Software Entropy Software tends to degrade / decay

More information

Bruno Bossola SOLID Design Principles

Bruno Bossola SOLID Design Principles Bruno Bossola SOLID Design Principles About me C Developer since 1988 Java developer since 1996 XP Coach during 2000 2001 Lead coordinator and co founder of JUG Torino in 2001 Sun Java Champion since 2005

More information

Common mistakes and Basic Design Principles. David Rabinowitz

Common mistakes and Basic Design Principles. David Rabinowitz Common mistakes and Basic Design Principles David Rabinowitz Common Mistakes Repeated often Don t you make them! How to recognize the danger signals? May 28, 2008 Object Oriented Design Course 2 Danger

More information

Stability. Introduction

Stability. Introduction Stability This is the sixth of my Engineering Notebook columns for The C++ Report. The articles that appear in this column focus on the use of C++ and OOD, and address issues of software engineering. I

More information

Design Principles: Part 2

Design Principles: Part 2 Liskov Substitution Principle (LSP) Dependency-Inversion Principle (DIP) Interface-Segregation Principle (ISP) Design Principles: Part 2 ENGI 5895: Software Design Andrew Vardy Faculty of Engineering &

More information

Outline. Design Principles: Part 2. e.g. Rectangles and Squares. The Liskov Substitution Principle (LSP) ENGI 5895: Software Design.

Outline. Design Principles: Part 2. e.g. Rectangles and Squares. The Liskov Substitution Principle (LSP) ENGI 5895: Software Design. Liskov Substitution Principle (LSP) Dependency-Inversion Principle (DIP) Interface-Segregation Principle (ISP) Liskov Substitution Principle (LSP) Dependency-Inversion Principle (DIP) Interface-Segregation

More information

Design Principles: Part 2

Design Principles: Part 2 Liskov Substitution Principle (LSP) Dependency-Inversion Principle (DIP) Interface-Segregation Principle (ISP) Design Principles: Part 2 ENGI 5895: Software Design Andrew Vardy Faculty of Engineering &

More information

OO Class Design Principles

OO Class Design Principles 3.3 Class Design Principles Single Responsibility Principle (SRP) Open/Closed Principle (OCP) Liskov Substitution Principle (LSP) a.k.a. Design by Contract Dependency Inversion Principle (DIP) Interface

More information

Ingegneria del Software Corso di Laurea in Informatica per il Management. Software quality and Object Oriented Principles

Ingegneria del Software Corso di Laurea in Informatica per il Management. Software quality and Object Oriented Principles Ingegneria del Software Corso di Laurea in Informatica per il Management Software quality and Object Oriented Principles Davide Rossi Dipartimento di Informatica Università di Bologna Design goal The goal

More information

UML and Design Patterns Prof. Dr. Eric Dubuis, V. June Engineering and Information Technology. On Package Design

UML and Design Patterns Prof. Dr. Eric Dubuis, V. June Engineering and Information Technology. On Package Design On Package Design Berner Fachhochschule Engineering and Information Technology Prof. Dr. Eric Dubuis Software Engineering and Design Version June 2008 1 Content Package Design: Basic Principle Dependency

More information

Object-oriented design principles

Object-oriented design principles Object-oriented design principles Objektumorientált szoftvertervezés Object-oriented software design Dr. Balázs Simon BME, IIT Outline OO concepts Single Responsibility Principle (SRP) Open/Closed Principle

More information

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne Object design François Schwarzentruber ENS Cachan Antenne de Bretagne Outline Symptoms of rotting systems Principles of object oriented class design Principles of Package Architecture Dreams Outline Symptoms

More information

Open Closed Principle (OCP)

Open Closed Principle (OCP) Open Closed Principle (OCP) Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhán Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ SOLID Class Design Principles

More information

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne

Object design. François Schwarzentruber ENS Cachan Antenne de Bretagne Object design François Schwarzentruber ENS Cachan Antenne de Bretagne Symptoms of rotting systems (according to Robert C. Martin) Four behaviors of the developer team: Rigidity Fragility Immobility Viscosity

More information

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles Abstraction Design fundamentals in OO Systems Tool for abstraction: object Object structure: properties and values for those properties operations to query and update those properties We refer to the collection

More information

OO Package Design Principles

OO Package Design Principles 4 4.1 Packages Introduction 4.2 Packages in UML 4.3 Three Package Design Principles 4.4 Development Environment (Three more principles) 4.5 Summary 1 4.1 Packages Introduction What is a package? Classes

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecturer: Raman Ramsin Lecture 15: Object-Oriented Principles 1 Open Closed Principle (OCP) Classes should be open for extension but closed for modification. OCP states that we should

More information

17.11 Bean Rules persistent

17.11 Bean Rules persistent 17.10 Java Beans Java beans are a framework for creating components in Java. AWT and Swing packages are built within this framework Made to fit in with graphic development environments such as Jbuilder

More information

Dependency Inversion Principle (DIP) Package Design: Coupling Principles

Dependency Inversion Principle (DIP) Package Design: Coupling Principles Berner Fachhochschule Prof. Dr. Eric Dubuis Software Engineering and Design Version December 2007 1 Package Design: Basic Principle Dependency Inversion Principle (DIP) Package Design: Coupling Principles

More information

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017 CSC40232: SOFTWARE ENGINEERING Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017 Department of Computer Science and Engineering http://www.kirkk.com/modularity/2009/12/solid-principles-of-class-design/

More information

S.O.L.I.D. Principles of

S.O.L.I.D. Principles of S.O.L.I.D. Principles of Object-Oriented Class Design Fifteen Years Later. Copyright 1998-2010 by Object Mentor, Inc Portions of this material are Copyright 1998, by Addison Wesley Longman,Inc. and have

More information

Lecture: Modular Design

Lecture: Modular Design Software Engineering Lecture: Modular Design Thomas Fritz Many thanks to Philippe Beaudoin, Gail Murphy, David Shepherd, Neil Ernst and Meghan Allen Reading! For next lecture: (all required) Composite

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Department of Computer Engineering Lecture 12: Object-Oriented Principles Sharif University of Technology 1 Open Closed Principle (OCP) Classes should be open for extension but closed

More information

Chapter 8: Class and Method Design

Chapter 8: Class and Method Design Chapter 8: Class and Method Design Objectives Become familiar with coupling, cohesion, and connascence. Be able to specify, restructure, and optimize object designs. Be able to identify the reuse of predefined

More information

Component-Level Design

Component-Level Design Component-Level Design Minsoo Ryu Hanyang University Contents 1. Design Model 2. Fundamental Design Concepts 3. Component-Level Design 4. Object-Oriented Design Techniques 2 2 Data/class design Four Design

More information

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles CS 247: Software Engineering Principles Reading: none Object-Oriented Design Principles Today's Agenda Object-Oriented Design Principles - characteristics, properties, and advice for making decisions that

More information

Software Engineering

Software Engineering Software Engineering CSC 331/631 - Spring 2018 Object-Oriented Design Principles Paul Pauca April 10 Design Principles DP1. Identify aspects of the application that vary and separate them from what stays

More information

Granularity. Inheritance Bi-directional. Association. Derived A1

Granularity. Inheritance Bi-directional. Association. Derived A1 Granularity This is the fifth of my Engineering Notebook columns for The C++ Report. The articles that appear in this column focus on the use of C++ and OOD, and address issues of software engineering.

More information

CAS 703 Software Design

CAS 703 Software Design Dr. Ridha Khedri Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Other 1 2 3 4 Other Principle of Least Privilege Principle of Fail-Safe Defaults Principle of

More information

Summary of the course lectures

Summary of the course lectures Summary of the course lectures 1 Components and Interfaces Components: Compile-time: Packages, Classes, Methods, Run-time: Objects, Invocations, Interfaces: What the client needs to know: Syntactic and

More information

The Release Reuse Equivalency Principle (REP) The Common Closure Principle (CCP) The Common Reuse Principle (CRP)

The Release Reuse Equivalency Principle (REP) The Common Closure Principle (CCP) The Common Reuse Principle (CRP) Package Cohesion Principles The Release Reuse Equivalency Principle (REP) The Common Closure Principle (CCP) The Common Reuse Principle (CRP) Portions Copyright 2000 by Robert C. Martin. Page 1 The Release

More information

Highlights of Previous Lecture

Highlights of Previous Lecture Highlights of Previous Lecture Final Project Goals 1. Set up collections of Flights 2. Maintain information about reservation availability on flights 3. Respond to reservation requests 4. Set up collections

More information

Intro to: Design Principles

Intro to: Design Principles Intro to: Design Principles Pragmatic Programmer: Eliminate Effects Between Unrelated Things design components that are: self-contained, independent, and have a single, well-defined purpose Software Design

More information

SOLID Principles. Equuleus Technologies. Optional Subheading October 19, 2016

SOLID Principles. Equuleus Technologies. Optional Subheading October 19, 2016 SOLID Principles Optional Subheading October 19, 2016 Why SOLID Principles? The traits of well designed software are as follows Maintainability - The ease with which a software system or component can

More information

11/2/09. Code Critique. What goal are we designing to? What is the typical fix for code smells? Refactoring Liskov Substitution Principle

11/2/09. Code Critique. What goal are we designing to? What is the typical fix for code smells? Refactoring Liskov Substitution Principle Code Critique Identifying smells Refactoring Liskov Substitution Principle What goal are we designing to? What is the typical fix for code smells? What is a limitation of those fixes? How do we address

More information

COURSE 2 DESIGN PATTERNS

COURSE 2 DESIGN PATTERNS COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract

More information

Object Relationships

Object Relationships Object Relationships Objects can work together in three different types of relationships: Uses: An object can use another to do some work (association). Composition: A complex object may be composed of

More information

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns Last Time: Object Design Comp435 Object-Oriented Design Week 7 Computer Science PSU HBG The main idea RDD: Responsibility-Driven Design Identify responsibilities Assign them to classes and objects Responsibilities

More information

Principles of OO Design

Principles of OO Design Principles of OO Design Ing. Libor Buš PhD. Department of Software Engineering Faculty of Information Technology Czech Technical University in Prague MI-DPO WS 2010/11, Lecture 1 Evropský sociální fond

More information

1: Introduction to Object (1)

1: Introduction to Object (1) 1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface

More information

11/4/15. Review. Objec&ves. Refactoring for Readability. Review. Liskov Subs&tu&on Principle (LSP) LISKOV SUBSTITUTION PRINCIPLE

11/4/15. Review. Objec&ves. Refactoring for Readability. Review. Liskov Subs&tu&on Principle (LSP) LISKOV SUBSTITUTION PRINCIPLE Objec&ves Liskov Subs&tu&on Principle Good enough design Refactoring for Extensibility Review What are some metrics of code design? Ø How can we use the metric? Ø What is the intui&on behind the metric?

More information

Liskov Substitution Principle

Liskov Substitution Principle Liskov Substitution Principle Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhán Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ SOLID Class Design Principles

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

Object Oriented Software Design - I

Object Oriented Software Design - I Object Oriented Software Design - I Object Oriented Design Principles Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2011 G. Lipari (Scuola Superiore Sant Anna)

More information

CMPS 115 Winter 04. Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD <break> Design Patterns

CMPS 115 Winter 04. Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD <break> Design Patterns CMPS 115 Winter 04 Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD Design Patterns Changes & Lecture 9 Takeaway Changes/Notices 2/26 may be guest after all, on design-with-frameworks

More information

1 Introduction 2 Complex Systems 3 Object Model 4 Dependency Management 5 Class Design. Object Oriented Programming in Physics

1 Introduction 2 Complex Systems 3 Object Model 4 Dependency Management 5 Class Design. Object Oriented Programming in Physics Object Oriented Programming in Physics 1 Introduction 2 Complex Systems 3 Object Model 4 Dependency Management 5 Class Design 1 1 What is OO? A method to design and build large programs with a long lifetime

More information

Software Engineering I (02161)

Software Engineering I (02161) Software Engineering I (02161) Week 10 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2018 Recap Observer Pattern MVC Presentation Layer Example S.O.L.I.D. Simple Responsibility

More information

Agile Software Development

Agile Software Development Agile Software Development Principles, Patterns, and Practices Robert Cecil Martin Alan Apt Series Prentice Hall Pearson Education, Inc. Upper Saddle River, New Jersey 07458 Foreword Preface About the

More information

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Outline Subtype polymorphism Subtyping vs. subclassing Liskov Substitution Principle (LSP) Function subtyping Java subtyping Composition:

More information

Classes and Objects. Object Orientated Analysis and Design. Benjamin Kenwright

Classes and Objects. Object Orientated Analysis and Design. Benjamin Kenwright Classes and Objects Object Orientated Analysis and Design Benjamin Kenwright Outline Review Previous Weeks Object Model, Complexity,.. What do we mean by Classes and Objects? Summary/Discussion Review

More information

Design by Contract in Eiffel

Design by Contract in Eiffel Design by Contract in Eiffel 2002/04/15 ctchen@canthink.com.com.tw.tw Reference & Resource Bertrand Meyer, Object-Oriented Oriented Software Construction 2nd,, 1997, PH. Bertrand Meyer, Eiffel: The Language,,

More information

Conception Orientée Objets. Programmation SOLID

Conception Orientée Objets. Programmation SOLID Conception Orientée Objets Programmation SOLID Frédéric Mallet http://deptinfo.unice.fr/~fmallet/ F. Mallet SOLID 1 Objectives Introduce some principles to guide the design Single responsibility Open Closed

More information

C++ Modern and Lucid C++ for Professional Programmers

C++ Modern and Lucid C++ for Professional Programmers Informatik C++ Modern and Lucid C++ for Professional Programmers part 13 Prof. Peter Sommerlad Institutsleiter IFS Institute for Software Rapperswil, HS 2015 Inheritance and dynamic Polymorphism base classes,

More information

OO Design Principles

OO Design Principles OO Design Principles Software Architecture VO (706.706) Roman Kern Institute for Interactive Systems and Data Science, TU Graz 2018-10-10 Roman Kern (ISDS, TU Graz) OO Design Principles 2018-10-10 1 /

More information

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4 Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Announcements n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt

Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Summer Term 2018 Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Open-Closed Principle Extension: Extending the behavior of a

More information

Introduction to Testing and Maintainable code

Introduction to Testing and Maintainable code Introduction to Testing and Maintainable code Reasons not to write unit tests 1. I don't know how to write tests. 2. Writing tests is too hard. 3. I don't have enough time to write tests. 4. Testing is

More information

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve? Plan Design principles: laughing in the face of change Perdita Stevens School of Informatics University of Edinburgh What are we trying to achieve? Review: Design principles you know from Inf2C-SE Going

More information

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov Eliminate enterprise software design instability - protect variations! Nickolay Kofanov Owning a hammer doesn't make one an architect. Responsibility-Driven-Design The way of thinking about the design

More information

CSC207 Week 3. Larry Zhang

CSC207 Week 3. Larry Zhang CSC207 Week 3 Larry Zhang 1 Announcements Readings will be posted before the lecture Lab 1 marks available in your repo 1 point for creating the correct project. 1 point for creating the correct classes.

More information

Setting the stage... Key Design Issues. Main purpose - Manage software system complexity by improving software quality factors

Setting the stage... Key Design Issues. Main purpose - Manage software system complexity by improving software quality factors Setting the stage... Dr. Radu Marinescu 1 1946 Key Design Issues Main purpose - Manage software system complexity by...... improving software quality factors... facilitating systematic reuse Dr. Radu Marinescu

More information

OOD Smells and Principles

OOD Smells and Principles Contents OOD Smells and Principles Code Smells vs. Refactoring Design Smells vs. Design Principles SOLID Single Responsibility Principle (SRP) Open Closed Principle (OCP) C++ Object Oriented Programming

More information

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli Identify and overcome the difficulties encountered by students when learning how to program List and explain the software development roles played by students List and explain the phases of the tight spiral

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

Object-Oriented Concepts and Design Principles

Object-Oriented Concepts and Design Principles Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation

More information

Chapter 10 Classes Continued. Fundamentals of Java

Chapter 10 Classes Continued. Fundamentals of Java Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an

More information

Outline. Software Rots

Outline. Software Rots Outline Design Principles: Part 1 ENGI 5895: Software Design 1 The Need for Design Principles Andrew Vardy 2 Refactoring Faculty of Engineering & Applied Science Memorial University of Newfoundland January

More information

Single Responsibility Principle (SRP)

Single Responsibility Principle (SRP) Single Responsibility Principle (SRP) Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhán Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ SOLID Class Design

More information

S.O.L.I.D: Software Engineering Principles

S.O.L.I.D: Software Engineering Principles DCC / ICEx / UFMG S.O.L.I.D: Software Engineering Principles Eduardo Figueiredo http://www.dcc.ufmg.br/~figueiredo S.O.L.I.D Principles These principles intend to create systems that are easier to maintain

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

CSC207H: Software Design SOLID. CSC207 Winter 2018

CSC207H: Software Design SOLID. CSC207 Winter 2018 SOLID CSC207 Winter 2018 1 SOLID Principles of Object-Oriented Design How do we make decisions about what is better and what is worse design? Principles to aim for instead of rules. e.g. there is no maximum

More information

Agile Principles, Patterns, and Practices in C#

Agile Principles, Patterns, and Practices in C# Agile Principles, Patterns, and Practices in C# Robert C. Martin Micah Martin 22 Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid!ENTICE,,,.

More information

Object Fundamentals Part Three. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007

Object Fundamentals Part Three. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007 Object Fundamentals Part Three Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007 1 Lecture Goals Continue our tour of the basic concepts, terminology, and notations

More information

Inheritance, Polymorphism, and Interfaces

Inheritance, Polymorphism, and Interfaces Inheritance, Polymorphism, and Interfaces Chapter 8 Inheritance Basics (ch.8 idea) Inheritance allows programmer to define a general superclass with certain properties (methods, fields/member variables)

More information

CS 2340 Objects and Design

CS 2340 Objects and Design CS 2340 Objects and Design Software Design Christopher Simpkins chris.simpkins@gatech.edu Chris Simpkins (Georgia Tech) CS 2340 Objects and Design Software Design 1 / 6 Design Design (noun) A plan or protocol

More information

The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space.

The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space. 1 All programming languages provide abstractions. Assembly language is a small abstraction of the underlying machine. Many imperative languages (FORTRAN, BASIC, and C) are abstractions of assembly language.

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

Maintainable Software. Software Engineering Andreas Zeller, Saarland University

Maintainable Software. Software Engineering Andreas Zeller, Saarland University Maintainable Software Software Engineering Andreas Zeller, Saarland University The Challenge Software may live much longer than expected Software must be continuously adapted to a changing environment

More information

Originality is Overrated: OO Design Principles

Originality is Overrated: OO Design Principles Originality is Overrated: OO Design Principles Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 13 10/09/2007 University of Colorado, 2007 1 Lecture Goals Review material from

More information

PRINCIPLES OF SOFTWARE DESIGN

PRINCIPLES OF SOFTWARE DESIGN F. Tip and M. Weintraub PRINCIPLES OF SOFTWARE DESIGN Thanks go to Andreas Zeller for allowing incorporation of his materials THE CHALLENGE 1. Software may live much longer than expected 2. Software must

More information

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 Expanding Our Horizons CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 1 Goals of the Lecture Cover the material in Chapter 8 of our textbook New perspective on objects and encapsulation

More information

Client Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module

Client Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module Basic Class Design Goal of OOP: Reduce complexity of software development by keeping details, and especially changes to details, from spreading throughout the entire program. Actually, the same goal as

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration

More information

Inheritance and Substitution (Budd chapter 8, 10)

Inheritance and Substitution (Budd chapter 8, 10) Inheritance and Substitution (Budd chapter 8, 10) 1 2 Plan The meaning of inheritance The syntax used to describe inheritance and overriding The idea of substitution of a child class for a parent The various

More information

PROCESS DEVELOPMENT METHODOLOGY The development process of an API fits the most fundamental iterative code development

PROCESS DEVELOPMENT METHODOLOGY The development process of an API fits the most fundamental iterative code development INTRODUCING API DESIGN PRINCIPLES IN CS2 Jaime Niño Computer Science, University of New Orleans New Orleans, LA 70148 504-280-7362 jaime@cs.uno.edu ABSTRACT CS2 provides a great opportunity to teach an

More information

GRASP Design Patterns A.A. 2018/2019

GRASP Design Patterns A.A. 2018/2019 GRASP Design Patterns A.A. 2018/2019 Objectives Introducing design patterns Introduzione ai design pattern Designing objects and responsibilities GRASP design patterns A long corridor A passage room Does

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L 10.1 10.3 1 Interface Hierarchies Inheritance can

More information

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,

More information

Inheritance (Chapter 7)

Inheritance (Chapter 7) Inheritance (Chapter 7) Prof. Dr. Wolfgang Pree Department of Computer Science University of Salzburg cs.uni-salzburg.at Inheritance the soup of the day?! Inheritance combines three aspects: inheritance

More information

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation

More information

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only Chapter 10 Component-Level Design Slide Set to accompany Software Engineering: A Practitioner s Approach, 7/e by Roger S. Pressman Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman For non-profit

More information

20 Years of. Improve the Design of your Code. Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015

20 Years of. Improve the Design of your Code. Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015 20 Years of Design Patterns Improve the Design of your Code Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015 Dr Dimitris Dranidis Senior Lecturer in Computer Science Department Programme director

More information

Object-Oriented Software Engineering Practical Software Development using UML and Java

Object-Oriented Software Engineering Practical Software Development using UML and Java Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes Lecture 5 5.1 What is UML? The Unified Modelling Language is a standard graphical

More information

Object Oriented Metrics. Impact on Software Quality

Object Oriented Metrics. Impact on Software Quality Object Oriented Metrics Impact on Software Quality Classic metrics Lines Of Code Function points Complexity Code coverage - testing Maintainability Index discussed later Lines of Code KLOC = 1000 Lines

More information

Inheritance and object compatibility

Inheritance and object compatibility Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not the other way around Examples: reference/pointer can

More information

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1 Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations

More information