Object-Oriented Design II

Similar documents
Object-Oriented Design II - GRASP

Object-Oriented Design I - SOLID

Object-Oriented Design I

Software Engineering

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

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

Inheritance and object compatibility

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

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

GRASP Design Patterns A.A. 2018/2019

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

Object-Oriented Design

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

CSC207H: Software Design SOLID. CSC207 Winter 2018

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

Chapter 5 Object-Oriented Programming

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

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

OO Design Principles

What is a Programming Paradigm

Four More GRASP Principles CSSE 574: Session 5, Part 2

Object-Oriented Design

Design patterns. Jef De Smedt Beta VZW

Principles of Object-Oriented Design

CHAPTER 9 DESIGN ENGINEERING. Overview

GRASP 2. CSC 440: Software Engineering Slide #1

CS 520 Theory and Practice of Software Engineering Fall 2018

Software Design and SOLID Principles

Chapter 8: Class and Method Design

Object-Oriented Design

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

Lessons Learned. Johnny Bigert, Ph.D., Skype/Microsoft October 26, 2011

Intro to: Design Principles

17.11 Bean Rules persistent

ADVANCED SOFTWARE DESIGN LECTURE 4 GRASP. Dave Clarke

CS 320 Introduction to Software Engineering Spring March 06, 2017

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

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

Object Relationships

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 11/03/2015

Object Oriented Programming: Based on slides from Skrien Chapter 2

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

COURSE 2 DESIGN PATTERNS

CS 520 Theory and Practice of Software Engineering Fall 2017

Advanced JML Erik Poll Radboud University Nijmegen

CSC Advanced Object Oriented Programming, Spring Specification

Patterns and Testing

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

Introduction to Unified Modelling Language (UML)

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

Inheritance. One class inherits from another if it describes a specialized subset of objects Terminology:

Object-Oriented Concepts and Design Principles

The following topics will be covered in this course (not necessarily in this order).

Chapter 8: Enhanced ER Model

Chapter 10 Classes Continued. Fundamentals of Java

Today. CSE341: Programming Languages. Late Binding in Ruby Multiple Inheritance, Interfaces, Mixins. Ruby instance variables and methods

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

Unified Modeling Language (UML) Class Diagram

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

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

Design Principles: Part 2

Advances in Programming Languages

Design Principles: Part 2

Open Closed Principle (OCP)

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

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

Introduction to Software Engineering. 5. Modeling Objects and Classes

[ L5P1] Object-Oriented Programming: Advanced Concepts

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

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

Rushikesh K Joshi. Department of Computer Science and Engineering Indian Institute of Technology Bombay

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4-1

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

Design by Contract in Eiffel

SOLID: Principles of OOD

CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods. Dan Grossman Autumn 2018

Component-Level Design

New Programming Paradigms

CSE 70 Final Exam Fall 2009

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

Object Oriented Software Design - I

Department of Computer Science Undergraduate Events

Software Engineering Design & Construction

Design Concepts. Slide Set to accompany. Software Engineering: A Practitioner s Approach, 7/e by Roger S. Pressman

Inheritance and Substitution (Budd chapter 8, 10)

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

Lecture 8: Chapter 8!

First IS-A Relationship: Inheritance

Single Responsibility Principle (SRP)

Exam in TDDB84: Design Patterns,

(Practical) SW Architectures. November 14, 2013

Lecture: Modular Design

CSCI 3155: Principles of Programming Languages Exercise sheet #12 26 June 2007

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

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

Software Development. Modular Design and Algorithm Analysis

The major elements of the object-oriented model

Programmazione. Prof. Marco Bertini

Transcription:

Object-Oriented Design II SWEN-261 Introduction to Software Engineering Department of Software Engineering Rochester Institute of Technology Controller Pure fabrication Open/close Polymorphism Liskov substitution

The lesson continues building your object-oriented design skills with several other design principles. These are also principles from SOLID and GRASP 2

Controller specifies a separation of concerns between the UI tier and other system tiers. Assign responsibility to receive and coordinate a system operation to a class outside of the UI tier. "Controller" is an overused term in software design. In GRASP, this is not the view "controller" which is firmly in the UI tier. In simple systems, it may be a single object that coordinates all system operations. In more complex systems, it is often multiple objects from different classes each of which handles a small set of closely related operations. 3

Here is how GRASP controllers fit into the software architecture. View controllers work through these classes Some Appl Tier class Some Model Tier class View controllers work through these classes Simple System More Complex System UI Tier Appl Tier UI Tier Appl Tier Operation Subsystem Operation Model Tier Model Tier Op1 Op2 Op3 4 Where in the sample webapp is there a GRASP-style controller?

Pure Fabrication is sometimes needed to balance other design principles. Assign a cohesive set of responsibilities to a non-domain entity in order to support high cohesion and low coupling. Your design should be primarily driven by the problem domain. To maintain a cohesive design you may need to create classes that are not domain entities. In the previous slide, the Operation Subsystem was a pure fabrication. 5 What were pure fabrications in the sample webapp? How could you have implemented it without those fabrications?

The Open/closed principle deals with extending and protecting functionality. Software entities should be open for extension, but closed for modification. Software functionality should be extendable without modifying the base functionality. Mostly provided by features of implementation language: inheritance, interface Your design should consider appropriate use of Inheritance from abstract classes Implementation of interfaces Dependency injection provides a mechanism for extending functionality without modification. 6

Polymorphism creates a hierarchy when related behavior varies by class. Assign responsibility for related behavior that varies by class by using polymorphic behavior. Polymorphism is a primary object-oriented concept and should be used whenever possible Bad code smells that indicate a potential class hierarchy and use of polymorphism Conditional that selects behavior based on a "type" attribute Use of instanceof or similar language constructs to select operations to perform 7

The Liskov substitution principle constrains the pre- and post-conditions of operations. Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program Pre-conditions specify what must be true before a method call. Post-conditions specify what will be true after a method call. Design by Contract is a programming technique that requires formal definition of the pre- and postconditions and has language support for it. 8

Any subclass of a class should be able to substitute for the superclass without error. A subclass must not violate any of the pre- or post-conditions guaranteed by the superclass. Superclass clients count on the pre- and postconditions being true even when polymorphism has the client interacting with a subclass. To maintain a pre-condition, a subclass must not narrow the pre-condition, i.e. be a subset. To maintain a post-condition, a subclass must not broaden the post-condition, i.e. be a superset. 9

Here is what Liskov substitution allows. mathop() must accept a param of 1 through 10. It could accept a wider range, i.e. 1 to 15. If client reference is to: DoMath Doubler mathop() can not quadruple the value of the parameter because that would lead to a broader post-condition, i.e. return value between 4 and 40. mathop() could have a narrower post-condition of 3 to 17, i.e. it is a PlusTwo class for its full range of input. 10