S.Ducasse Stéphane Ducasse 1 Some Principles Stéphane Ducasse ---

Slides:



Advertisements
Similar presentations
The Problem Decomposition of programs in terms of classes and in terms of crosscutting concerns are both useful, but languages based on source files allow.
Advertisements

Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
Chapter 14 Graph class design John Keyser’s Modifications of Slides by Bjarne Stroustrup
1 Object-Oriented Reengineering © R. Marinescu Lecture 5 Radu Marinescu Principles of Object-Oriented Design.
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 5 Architecture-Driven Component Development.
Polymorphism From now on we will use g++!. Example (revisited) Goal: Graphics package Handle drawing of different shapes Maintain list of shapes.
Common mistakes Basic Design Principles David Rabinowitz.
R R R CSE870: Advanced Software Engineering: Frameworks (Cheng, Sp2003)1 Frameworks A Brief Introduction.
Common mistakes Basic Design Principles Amit Shabtay.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 1 פרק 3 OCP.
1 OO Design Principles Project Group eXtreme Programming Md. Abul Bashar 07/09/2004.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Advanced Principles I Principles of Object-Oriented Class Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this material.
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
Principles of Object-Oriented Design SEI, SJTU WEB APPS and SERVICES.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
S.Ducasse Stéphane Ducasse 1 The VisualWorks Environment.
S.O.L.I.D. Software Development 12 January 2010 (Martin Verboon, Patrick Kalkman, Stan Verdiesen)
CPSC 372 John D. McGregor Module 4 Session 1 Design Patterns.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Design Principles iwongu at gmail dot com.
The benefits of SOLID in software development Ruben Agudo Santos (GS-AIS-HR)
 What is SOLID  The S in SOLID  The O in SOLID  The L in SOLID  The I in SOLID  The D in SOLID  Questions.
1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.
Frameworks & Patterns Use of Organized Classes. Frameworks vs Toolkits Framework Framework  Start with classes and interfaces that define a rudimentary.
Structural Pattern: Bridge When the abstract interface and the concrete implementation have been set up as parallel class hierarchies, it becomes difficult.
Software Design Principles
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
1 Interfaces and Abstract Classes Chapter Objectives You will be able to: Write Interface definitions and class definitions that implement them.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
CPSC 871 John D. McGregor Module 5 Session 1 Design Patterns.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Five design principles
S.Ducasse Stéphane Ducasse 1 Essential OO Concepts Stéphane Ducasse.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
1 Design by Principles (Robert Martin) Software Engineering.
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
Component Design Elaborating the Design Model. Component Design Translation of the architectural design into a detailed (class-based or module- based)
S.Ducasse Stéphane Ducasse 1 Decorator.
The Circle. Examples (1) – (5) Determine the center and radius of the circle having the given equation. Identify four points of the circle.
SOLID Design Principles
1 Good Object-Oriented Design Radu Marinescu Lecture 3 Principles of Object-Oriented Design Part II 19 th November 2002.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 20 - Virtual Functions Outline 20.1Introduction 20.2Type Fields and switch Statements 20.3Virtual.
S.Ducasse Stéphane Ducasse 1 Adapter.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
NCCUCS Software Engineering 補充投影片 April 14, 2014.
Beginning Software Craftsmanship Brendan Enrick Steve Smith
14 Jul 2005CSE403, Summer'05, Lecture 09 Lecture 09: Fundamental Principles and Best Practices for Software Design Valentin Razmov.
1 Advanced Object- oriented Design – Principles CS320 Fall 2005.
What is Agile Design? SRP OCP LSP DIP ISP
Interface Segregation / Dependency Inversion
OCP and Liskov Principles
More Design Heuristics
CSE687 - Object Oriented Design class notes Survey of the C++ Programming Language Jim Fawcett Spring 2004.
Subtype Polymorphism, Subtyping vs
Design Tips.
Questions First On class? On project? On material we’ve discussed?
Why OO Paradigm is better?
Principles of Object-Oriented Design
The SOLID Principles.
Principles of Object-Oriented Design Part II
Principles of Object-Oriented Design
Principles of High-Level Design
Some principles for object oriented design
Chapter 10 – Component-Level Design
Presentation transcript:

S.Ducasse Stéphane Ducasse 1 Some Principles Stéphane Ducasse

S.Ducasse License: CC-Attribution-ShareAlike

S.Ducasse 3 Open-Close Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.

S.Ducasse 4 The open-closed principle Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. Existing code should not be changed – new features can be added using inheritance or composition.

S.Ducasse 5 One kind of application enum ShapeType {circle, square}; struct Shape { ShapeType _type; }; struct Circle { ShapeType _type; double _radius; Point _center; }; struct Square { ShapeType _type; double _side; Point _topLeft; }; void DrawSquare(struct Square*) void DrawCircle(struct Circle*);

S.Ducasse 6 Example (II) void DrawAllShapes(struct Shape* list[], int n) { int i; for (i=0; i<n; i++) { struct Shape* s = list[i]; switch (s->_type) { case square: DrawSquare((struct Square*)s); break; case circle: DrawCircle((struct Circle*)s); break; } Adding a new shape requires adding new code to this method.

S.Ducasse 7 Correct Form class Shape { public: virtual void Draw() const = 0; }; class Square : public Shape { public: virtual void Draw() const; }; class Circle : public Shape { public: virtual void Draw() const; }; void DrawAllShapes(Set & list) { for (Iterator i(list); i; i++) (*i)->Draw();

S.Ducasse 8 Some Principles Dependency Inversion Principle Interface Segregation Principle The Acyclic Dependencies Principle

S.Ducasse 9 Dependency Inversion Principle High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.

S.Ducasse 10 Example void Copy() { int c; while ((c = ReadKeyboard()) != EOF) WritePrinter(c); }

S.Ducasse 11 Cont... Now we have a second writing device – disk enum OutputDevice {printer, disk}; void Copy(outputDevice dev) { int c; while ((c = ReadKeyboard()) != EOF) if (dev == printer) WritePrinter(c); else WriteDisk(c); }

S.Ducasse 12 Solution class Reader { public: virtual int Read() = 0; }; class Writer { public: virtual void Write(char)=0; }; void Copy(Reader& r, Writer& w) { int c; while((c=r.Read()) != EOF) w.Write(c); }

S.Ducasse 13 Some Principle

S.Ducasse 14 Interface Segregation Principle The dependency of one class to another one should depend on the smallest possible interface. Avoid “fat” interfaces

S.Ducasse 15 Examples

S.Ducasse 16 Solutions One class one responsibility Composition? Design is not simple

S.Ducasse 17 The Acyclic Dependency Principle The dependency structure between packages must not contain cyclic dependencies.

S.Ducasse 18 Example...Ez

S.Ducasse 19 Solutions Layering? Separation of domain/applicatin/UI

S.Ducasse 20 Packages, Modules and other The Common Closure Principle Classes within a released component should share common closure. That is, if one needs to be changed, they all are likely to need to be changed. The Common Reuse Principle The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.

S.Ducasse 21 Summary Build your own taste Analyze what you write and how?