Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

Similar documents
Work groups meeting 3

Work groups meeting 3

Design Patterns. Gunnar Gotshalks A4-1

CS/CE 2336 Computer Science II

Object-Oriented Design

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

CPSC 310 Software Engineering. Lecture 11. Design Patterns

An Introduction to Patterns and Pattern Languages. Overview. Patterns -- Why? Patterns -- Why?

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Design Patterns and Frameworks 1) Introduction

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Design Patterns. An introduction

CSC7203 : Advanced Object Oriented Development. J Paul Gibson, D311. Design Patterns

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

An Introduction to Patterns

Introduction and History

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Lecture 13: Design Patterns

A Rapid Overview of UML

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Object-Oriented Design

The Software Design Process. CSCE 315 Programming Studio, Fall 2017 Tanzir Ahmed

Object-Oriented Design Patterns

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Patterns for polymorphic operations

L02.1 Introduction... 2

Foundations of Software Engineering Design Patterns -- Introduction

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Design Patterns. CSC207 Fall 2017

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini

PATTERNS AND SOFTWARE DESIGN

Responsibilities. Using several specific design principles to guide OO design decisions.

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

Patterns of learning

17. GRASP: Designing Objects with Responsibilities

Software Engineering

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

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Using Design Patterns in Java Application Development

Design Patterns. CSC207 Winter 2017

Coordination Patterns

Review Software Engineering October, 7, Adrian Iftene

VOL. 4, NO. 12, December 2014 ISSN ARPN Journal of Science and Technology All rights reserved.

CHAPTER 5 GENERAL OOP CONCEPTS

Reuse at Design Level: Design Patterns

CS251 Software Engineering Lectures 18: Intro to DP

Design Patterns (DP) In the beginning. It s not a course about DP (just a little) A lot of good design and efficient implementation is based on DP

Topics in Object-Oriented Design Patterns

Refactoring, Design Patterns and Extreme Programming %-(&7,9(

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Essential Skills for the Agile Developer. Agile. copyright Net Objectives, Inc.

Design Patterns. CSCE Lecture 17-10/28/2015 (Partially adapted from Head First Design Patterns by Freeman, Bates, Sierra, and Robson)

DESIGN PATTERN - INTERVIEW QUESTIONS

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

L18.1 Introduction... 2

3 Product Management Anti-Patterns by Thomas Schranz

Chapter 5 Object-Oriented Programming

Crash course on design patterns

Advanced Object Oriented PHP

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

An Introduction to Patterns

Object Oriented Paradigm

Lecture Material. Design Patterns. Visitor Client-Server Factory Singleton

Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson January 20, 2005

Tuesday, October 4. Announcements

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Lecture 19: Introduction to Design Patterns

Kerievsky_book.fm Page 355 Thursday, July 8, :12 PM. Index

Design Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

Why a Design Pattern. History of Design Pattern. Properties

OO Frameworks. Introduction. Using Frameworks

The Bridge Pattern. I derive the Bridge pattern by working through an example. I will go into great detail to help you learn this pattern.

Research Article A Design Pattern Approach to Improve the Structure and Implementation of the Decorator Design Pattern

Patterns and Testing

CSE 70 Final Exam Fall 2009

Software Engineering I (02161)

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

administrivia today UML start design patterns Tuesday, September 28, 2010

Programmazione. Prof. Marco Bertini

Object Oriented Programming. Michał Bereta

Influence of Design Patterns Application on Quality of IT Solutions

Object-Oriented Design

Object-Oriented Concepts and Design Principles

1 Software Architecture

Technical Metrics for OO Systems

11/12/12. Objectives DESIGN PATTERNS. Design Pattern. Defined Design Patterns. Applying Design Patterns. Motivating Example

Improve Your SystemVerilog OOP Skills

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

Design Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles

Transcription:

Inheritance EEC 521: Software Engineering Software Design Design Patterns: Decoupling Dependencies 10/15/09 EEC 521: Software Engineering 1 Inheritance is the mechanism by which one class can acquire properties/responsibilities of another class If your application is going to include a bunch of classes that are related, and have a lot in common, then a good way of designing these classes is to put all the common properties and responsibilities in a single base class Individual classes inherit commonalities from the base class Each of the classes that inherit from a base class is called a derived class or a subclass 10/15/09 EEC 521: Software Engineering 3 Dealing with Change Changing requirements Code needs to be flexible Cohesion: how closely operations in a routine are related Coupling: how strongly operations in a routine are dependent on each other Polymorphism The ability to appear in many forms In OO, polymorphism allows a client to treat an object of a derived class as though it were an object of a base class Dynamic dispatch Strong cohesion + loose coupling = easy to change 10/15/09 EEC 521: Software Engineering 2 10/15/09 EEC 521: Software Engineering 4

Coupling and OO Design OO way of reusing code Inheritance and polymorphism Unfortunately, it is very easy to misuse inheritance Concrete dependencies between classes (and objects) makes change difficult Inheritance may cause unnatural relationships between classes Inheritance also results in tight coupling between classes 10/15/09 EEC 521: Software Engineering 5 Patterns are Discovered Patterns are discovered from existing work, not invented Alexander and his collaborators studied their past work and found 253 patterns from a number of buildings and urban settings The gang of four studied a number of OO systems and found 23 patterns It makes sense: Something called a pattern cannot be prescriptive; it has to be descriptive 10/15/09 EEC 521: Software Engineering 7 So, is OO bad? What are you trying to say? Of course OO is not bad! But there are many pitfalls that one needs to be wary of Fortunately, several of these pitfalls have already been identified and solved Design Patterns! What is a Pattern? Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice C. Alexander, The Timeless Way of Building, 1979 10/15/09 EEC 521: Software Engineering 6 10/15/09 EEC 521: Software Engineering 8

A (Short) History of Software Patterns 1987. Cunningham and Beck used Alexander s ideas to develop a small pattern language for Smalltalk 1990. The Gang of Four (Gamma, Helm, Johnson and Vlissides) begin work compiling a catalog of design patterns 1991. Bruce Anderson gives first Patterns Workshop at OOPSLA 1993. Kent Beck and Grady Booch sponsor the first meeting of what is now known as the Hillside Group 1994. First Pattern Languages of Programs (PLoP) conference 1995. The Gang of Four (GoF) publish the Design Patterns book Classification of Design Patterns Purpose Creational Patterns. Concern the process of object creation Structural Patterns. Deal with the composition of classes and objects Behavioral Patterns. Deal with the interaction between classes and objects 10/15/09 EEC 521: Software Engineering 9 10/15/09 EEC 521: Software Engineering 11 GoF Design Patterns Solution to a general design problem in a particular context A design pattern names, abstracts, and identifies key aspects of a common design structure that makes it useful for creating a reusable objectoriented design. The GoF design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. Classification of Design Patterns Scope Class Patterns. Deal with relationships between classes and their subclasses; these relationships are static Object Patterns. Deal with object relationships, and are hence dynamic 10/15/09 EEC 521: Software Engineering 10 10/15/09 EEC 521: Software Engineering 12

Some Design Principles Template Method Solution Encapsulate what varies Favor composition over inheritance Program to interfaces, not implementations 10/15/09 EEC 521: Software Engineering 13 10/15/09 EEC 521: Software Engineering 15 Dependency: Multiple behaviors Example: Sorting Several different design choices Kind of elements being sorted Mode of sorting (ascending, descending, etc.) Algorithm for sorting (quicksort, mergesort, etc.) OO Frameworks When unable to predict all possible implementations, leave hooks open Subclasses can come along and hang behavior on these hooks 10/15/09 EEC 521: Software Engineering 14 10/15/09 EEC 521: Software Engineering 16

Strategy Pattern Solution 10/15/09 EEC 521: Software Engineering 17 Dynamic Reconfiguration On-the-fly behavior modification Injecting new behavior into running applications without stopping them High availability 10/15/09 EEC 521: Software Engineering 18