Software Engineering

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

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

COURSE 2 DESIGN PATTERNS

CSC207H: Software Design SOLID. CSC207 Winter 2018

Chapter 5 Object-Oriented Programming

Intro to: Design Principles

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

Object-Oriented Concepts and Design Principles

Object-Oriented Design

Single Responsibility Principle (SRP)

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

17.11 Bean Rules persistent

SOLID: Principles of OOD

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

Object-Oriented Design I - SOLID

Inheritance and object compatibility

Basic design patterns

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

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

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

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

Object-Oriented Design

Object-Oriented Design II

CS 520 Theory and Practice of Software Engineering Fall 2018

Summary of the course lectures

CS 320 Introduction to Software Engineering Spring March 06, 2017

CS 520 Theory and Practice of Software Engineering Fall 2017

Open Closed Principle (OCP)

Single Responsibility Principle

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

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

GRASP Design Patterns A.A. 2018/2019

Exam in TDDB84: Design Patterns,

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

Component-Level Design

CSE 70 Final Exam Fall 2009

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

Design Principles: Part 2

Software Design and SOLID Principles

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

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

CHAPTER 5 GENERAL OOP CONCEPTS

Influence of Design Patterns Application on Quality of IT Solutions

Princípy tvorby softvéru Dizajnové princípy

09. Component-Level Design

Patterns and Testing

Agile Software Development

Compositional Design Principles

Principles of Object-Oriented Design

Design Principles: Part 2

Software Development

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

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

Principles of OO Design

Inheritance (Chapter 7)

Introduction to Object-Oriented Programming

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

INTERNAL ASSESSMENT TEST III Answer Schema

Liskov Substitution Principle

EasyChair Preprint. Software Metrics Proposal for Conformity Checking of Class Diagram to SOLID Design Principles

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

OO Design Principles

Object-Oriented Design II - GRASP

ROBOT OOP. Learning the basics of Object Oriented Programming using robots from popular culture

OO Class Design Principles

CS342: Software Design. November 21, 2017

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

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

Example: Count of Points

C++ Inheritance and Encapsulation

Conception Orientée Objets. Programmation SOLID

CHAPTER 5: PRINCIPLES OF DETAILED DESIGN

Software Engineering Fall 2014

Object Relationships

CS 320 Introduction to Software Engineering Spring March

Advanced WCF 4.0 .NET. Web Services. Contents for.net Professionals. Learn new and stay updated. Design Patterns, OOPS Principles, WCF, WPF, MVC &LINQ

What is a Programming Paradigm

Object-Oriented Design

Produced by. Agile Software Development. Eamonn de Leastar

Build Testable Client and Service Applications

Bruno Bossola SOLID Design Principles

Unified Modeling Language (UML) Class Diagram

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

Object-Oriented Design

Application-Oriented System Design

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

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

Dependency Injection & Design Principles Recap Reid Holmes

Java 程式設計入門. 講師 : 陳昭源 CSIE, NTU September 28, 2005

QUESTIONS FOR AVERAGE BLOOMERS

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

CHAPTER 9 DESIGN ENGINEERING. Overview

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

Object-Oriented Design I

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Agile Principles, Patterns, and Practices in C#

Understading Refactorings

Inheritance -- Introduction

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

JAVA MOCK TEST JAVA MOCK TEST II

Transcription:

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 the same Encapsulate behaviors that change based on object type DP2. Program to an interface, not an implementation Function overloading is an example of programming to an implementation DP3. Favor composition over inheritance Better to achieve polymorphic behavior and code reuse through composition than inheritance

DP1. Identify aspects of the application that vary and separate them from what stays the same A typical scenario Subclasses overload inherited functions (behaviors) Issues Added behaviors are statically inherited by all subclasses Must override behavior in subclass Significant maintenance overhead

DP1. Identify aspects of the application that vary and separate them from what stays the same Refactored using the design principle Behaviors dynamically associated when objects of subclasses are created Adding behaviors does not require modification of existing code

DP2. Programming to an interface, not an implementation Programming to an implementation When your code uses knowledge of the underlying implementation When your code relies directly on concrete classes When your code is concerned with how something is implemented rather than on what it does Result: high coupling between codes Programming to an interface When your code relies on abstract classes, not their implementations When your code dynamically creates and assigns behavior (polymorphism) Result: low coupling

DP3. Favor composition over inheritance Inheritance Benefits Implementation is straightforward Code can be easy to change New implementations can be easy to make and extend Disadvantages If superclass changes then subclasses may have to change also (tight coupling) Exposes a subclass to the implementation details of the superclass (breaks encapsulation) Inheritance determined at compile time (base code added to every child class), not at run-time White-box reuse, since internal details of superclass are often visible to the subclasses

DP3. Favor composition over inheritance Composition Benefits Contained objects accessed by the containing class solely through their interfaces Black-box reuse, internal details of contained objects are not visible Good encapsulation Fewer implementation dependencies (loose coupling) Composition can be defined dynamically at run-time Disadvantages Design tends to have more objects and tends to be more complex Interfaces identifying composition blocks must be carefully designed (see DP1) Extreme composition can lead to overly simple superclass that only delegates to others

DP3. Favor composition over inheritance When to use inheritance or composition Coad s rule - use inheritance only when all of the following criteria are satisfied: A subclass expresses is a special kind of relationship and not is a role played by a An instance of a subclass never needs to be come an object of another class A subclass extends, rather than overrides or nullifies, the responsibilities of its superclass A subclass does not extend the capabilities of what is merely a utility class For a class in the actual problem domain, the subclass specializes a role, transaction, or device.

SOLID https://en.wikipedia.org/wiki/solid_(object-oriented_design) (SRP) Single responsibility principle A class should have a single responsibility All services should be aligned with this responsibility (high cohesion) (OCP) Open/closed principle Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification Achieved through inheritance from abstract classes or interfaces (LSP) Liskov substitution principle If S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program

SOLID (ISP) Interface segregation principle Many client-specific interfaces are better than one general-purpose interface No client should be forced to depend on methods it does not use (DIP) Dependency inversion principle High-level modules should not depend on low-level modules. Both should depend on abstractions Abstractions should not depend on details. Details should depend on abstractions