Object- oriented Design Principles

Slides:



Advertisements
Similar presentations
Object-Oriented Application Frameworks Much of the cost and effort stems from the continuous re- discovery and re-invention of core concepts and components.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
IMS1805 Systems Analysis Topic 3: Doing Analysis (continued from previous weeks)
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Object-Oriented Metrics. Characteristics of OO ● Localization ● Encapsulation ● Information hiding ● Inheritence ● Object abstraction.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
BACS 287 Basics of Object-Oriented Programming 1.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
Chapter 1: Introduction to Design Patterns. SimUDuck Example.
Introduction to Object-oriented programming and software development Lecture 1.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Objects and Components. The adaptive organization The competitive environment of businesses continuously changing, and the pace of that change is increasing.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
CSC 395 – Software Engineering Lecture 12: Reusability –or– Programming was Bjarne Again.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
DAAD project “Joint Course on OOP using Java” On Object Oriented modeling in Java (Why & How) Ana Madevska Bogdanova Institute of informatics Faculty of.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Elements of OO Abstraction Encapsulation Modularity Hierarchy: Inheritance & Aggregation 4 major/essential elements3 minor/helpful elements Typing Concurrency.
CS2110: SW Development Methods Inheritance in OO and in Java Part 2: Topics: Forms of inheritance Interfaces in Java.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd.
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.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
Inspired by the Oulipu. The 3 Tenets of OO Encapsulation Polymorphism Inheritance.
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
Basic Characteristics of Object-Oriented Systems
CSCE 240 – Intro to Software Engineering Lecture 3.
Object Oriented Systems Design
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Design Patterns: MORE Examples
Programming paradigms
MPCS – Advanced java Programming
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
SOFTWARE DESIGN AND ARCHITECTURE
Advanced Programming Behnam Hatami Fall 2017.
OO Design Patterns - Decorator
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
Presentation transcript:

Object- oriented Design Principles

The pyramid of OO Abstract/ Philosophical Practical PBA WEB – BEWP

Object-orientation is good! PBA WEB – BEWP

Object-orientation is good? PBA WEB – BEWP

Object-orientation is good (?) Why are we learning about object-orientation in the first place? Other ”paradigms” for programming exist, for instance functional programming and logic programming However, OO is currently the dominating paradigm for programming – more or less an industry standard PBA WEB – BEWP

Object-orientation is good! Object-orientation has proven to be a friutful way of connecting real life and software development However, there are certain ”rules” to obey when playing the OO-game… At the top, we rely on a few Object-Oriented concepts PBA WEB – BEWP

Object-oriented concepts Abstraction Encapsulation Polymorphism Inheritance (Composition) PBA WEB – BEWP

Abstraction The idea that we focus only on the essence of a concept Inessential details are ”abstracted away” Abstraction works at multiple levels Can be a challenge to find the appropriate level of abstraction Abstractions are manifested through interfaces, which define behaviors PBA WEB – BEWP

Encapsulation The idea not to expose details about how behaviors are achieved Concepts are considered black boxes This enables us to change how behaviors are achieved, without affecting the user of a particular concept PBA WEB – BEWP

Polymorphism The idea that concrete instances of a behavior can take many forms All animals can eat – but do so in very different ways… Eating is polymorphic behavior – it can take many forms, but has the same essence Allows us to focus on the essence of the behavoir, neglecting actual behaviors PBA WEB – BEWP

Inheritance The idea that concepts can inherit behaviors from other, more general concepts Allows us to reuse behaviors that have previously been defined We can easily define hierarchies of related concepts, only needing to add genuinely new behaviors PBA WEB – BEWP

Composition The idea that new concepts can be com-posed by combining existing concepts A supplement/alternative to inheritance A different approach to reuse Composition helps us realise has-a relations between concepts, inheritance is used for is-a relations PBA WEB – BEWP

Fine, but… The OO-concepts are nice, but not particularly operational We need something more concrete The OO-principles provide more specific guidelines PBA WEB – BEWP

The Object-oriented principles 1. Encapsulate the aspects of your application that vary 2. Favor composition over inheritance 3. Program to an interface, not an implementation 4. Strive for loose couplings between objects that interact 5. Make classes open for extension, closed for modification 6. Depend on abstractions, not concrete classes 7. Only talk to your closest friends 8. Don’t call us, we’ll call you 9. A class should only have one reason to change PBA WEB – BEWP

OO principles Where do these principles come from…? Not from ”proofs” or theory… Condensed best practices from real life Principles are to some extent overlapping PBA WEB – BEWP

OO principles ”Encapsulate the aspects of your applica-tion that vary” Promotes reusability When designing classes for a system of concepts, put the varying elements into separate classes Can be realised both through inheritance and composition, often using interfaces PBA WEB – BEWP

OO principles ”Program to an interface, not an imple-mentation” An essential idea; if we know the interface, we do not need to know any details about a specific implementation (weak coupling) Allows us the change the implementation without affecting the user This is more or less encapsulation PBA WEB – BEWP

OO principles ”Make classes open for extension, closed for modification” Very important principle! Once we have a well-documented, well-tested class, we should not change it! If we need more functionality, achieve it through extension, using inheritance and/or composition Keep classes as ”pure” as possible PBA WEB – BEWP

OO principles ”Only talk to your closest friends” Hmm, what does that mean…? A typical application architecture divides classes into a number of layers Classes in one layer should only know classes in the next layer (loose couplings) Avoid reliance on the specific composition of a class PBA WEB – BEWP

OO principles What is best, and why…? double temp = station.GetThermometer().GetTemperature(); double temp = station.GetStationTemperature(); We should not rely on specifics about how a Station is implemented Only one ”.” in a line of code… PBA WEB – BEWP

OO principles ”Don’t call us, we’ll call you” The Hollywood Agent principle… A more advanced principle; instead of imple-menting an algorithm using a lot of calls to generic classes, implement a generic algo-rithm with ”plugins” for specialised behavior Also known as Inversion of Control ”Encapsulate what varies…” PBA WEB – BEWP

Beyond principles We can use these OO principles directly when developing software Next step is Design Patterns, which describe designs for solving common problems, relying on the OO principles PBA WEB – BEWP