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

Similar documents
Software Engineering

Exam in TDDB84: Design Patterns,

CSC207H: Software Design SOLID. CSC207 Winter 2018

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

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

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Reengineering II. Transforming the System

6.001 Notes: Section 6.1

Object-Oriented Design II - GRASP

Open Closed Principle (OCP)

Curriculum Map Grade(s): Subject: AP Computer Science

Object-Oriented Design I

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO

Lecture 1: Overview

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

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

Object Oriented Programming

Object-Oriented Design

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

Single Responsibility Principle (SRP)

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

CSE 12 Abstract Syntax Trees

Introduction to Object-Oriented Programming

Object-Oriented Analysis and Design Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology-Kharagpur

CITS5501 Software Testing and Quality Assurance Formal methods

CSE 70 Final Exam Fall 2009

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

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

Inheritance and Substitution (Budd chapter 8, 10)

Introduction. Object Orientated Analysis and Design. Benjamin Kenwright

Module 10 Inheritance, Virtual Functions, and Polymorphism

CS 520 Theory and Practice of Software Engineering Fall 2018

An Overview of Visual Basic.NET: A History and a Demonstration

1: Introduction to Object (1)

A Proposal for Work. Getting To Know Us. Proposed Project Timeline. Project Goals Discussion Week 1

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

Computer Science 4U Unit 1. Programming Concepts and Skills Modular Design

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

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

CS 520 Theory and Practice of Software Engineering Fall 2017

Design. Eric McCreath

Patterns and Testing

5. Application Layer. Introduction

Bridge Pattern. Used to decouple an abstraction from its implementation so that the two can vary independently

+ Abstract Data Types

09. Component-Level Design

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Design Patterns: State, Bridge, Visitor

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation

Software Design and SOLID Principles

CS 320 Introduction to Software Engineering Spring March 06, 2017

Understading Refactorings

CSE 401/M501 Compilers

Java Multiple Choice Questions With Answers Doc

Object Oriented Software Design - I

Practical Object-Oriented Design in Ruby

(Refer Slide Time: 02.06)

Object-Oriented Concepts and Design Principles

Inheritance and Polymorphism

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13

Object-Oriented Design

Software Design and Analysis for Engineers

CSC207 Week 3. Larry Zhang

Intro to: Design Principles

What are the characteristics of Object Oriented programming language?

GRASP Design Patterns A.A. 2018/2019

Object-Oriented Design I - SOLID

CS 326: Operating Systems. Lecture 1

Example: Count of Points

step is to see how C++ implements type polymorphism, and this Exploration starts you on that journey.

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

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

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Object Fundamentals Part Two. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 3 09/01/2009

Inheritance and Polymorphism in Java

The 10 Minute Guide to Object Oriented Programming

Adding content to your Blackboard 9.1 class

CS487 Midterm Exam Summer 2005

Inheritance, Polymorphism and the Object Memory Model

CPSC 310 Software Engineering. Lecture 11. Design Patterns

Chapter 1: Principles of Programming and Software Engineering

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

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

CSE wi Final Exam 3/12/18. Name UW ID#

CS112 Lecture: Working with Numbers

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

Introduction. In this preliminary chapter, we introduce a couple of topics we ll be using DEVELOPING CLASSES


Principles of Object-Oriented Design

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

SOFTWARE ENGINEERING Prof.N.L.Sarda Computer Science & Engineering IIT Bombay. Lecture #10 Process Modelling DFD, Function Decomp (Part 2)

As a programmer, you know how easy it can be to get lost in the details

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Unit 4: Client View of a Component Methods

COURSE 2 DESIGN PATTERNS

Chapter 8: Class and Method Design

JAVA: A Primer. By: Amrita Rajagopal

Transcription:

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

What is this class about? While this class is called Design Patterns, there are many other items of critical importance that will be discussed Object Oriented Analysis, Design, and Programming will be a centerpiece of class discussion on a daily basis. We ll just say OO to describe in general anything Object Oriented in nature. We will learn about Code Smells. It s a funny sounding term the first couple of times you hear it, but there s nothing funny about Code Smells they are warning signs that something is amiss with your code. We will also learn basic refactoring principles. Once we can identify code smells, we need to fix them (time and ability permitting). We can use OO principles and Design Patterns to aid in the refactoring process.

What is this class about? We will also learn fundamental design principles These will aid us in developing code that is intent-revealing, easy to test, easy to maintain, easy to modify, and much, much more Here are a few examples of design principles we will learn to live by Program to an interface, not an implementation Favor composition over inheritance Encapsulate what varies SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion (each of these five principles will be discussed during lecture as we are exposed to patterns and other principles that use them)

What is this class about? This class is a lite version of Software Engineering We will use a great deal of terminology that is related to fundamental principles of good software engineering, with an eye on object oriented analysis, design, and programming Coupling and cohesion are two terms we will learn early on as a basis for meaningful discussion regarding OO software development We will talk about the basic steps of the Software Life Cycle We think about Programming in the Large (PITL) Up until now, must programs you have written are at most 1000 lines of code In this class we will begin thinking about writing code that will be part of large projects/code bases. There could be hundreds of other developers that interact with the code you write. With this in mind, we want to design our classes and methods carefully to avoid unintended interactions and behaviors when others interact with our code

What is this class about? We will discuss the importance of building classes such that all instances are always in a valid state Instance fields represent the state of a class object We must ensure those fields always contain proper values we cannot trust others that consume or work with our code to do the right thing To aid in this understanding we must start with the most fundamental pieces of OO, The Pillars of OO

The Pillars of OO While there is some discussion over the true number of pillars, we will assume there are four Abstraction Encapsulation Inheritance Polymorphism These concepts represent the foundation of all things object related We must learn these first so we can talk intelligently about all that follows Knowing the pillars and what each is about can be VERY helpful at job interviews (this has been reported by your predecessors who are now in industry) They are so important that the first question on your first quiz will be to name and describe these pillars

The Pillars of OO Abstraction This is probably the best pillar to discuss first, as the others arguably follow from this one It is the notion that we have a need to represent some kind of entity in our software solution, but don t want to worry about HOW that entity works on the inside and how it represents data to do the things it needs to do For our intents and purposes, the fundamental unit of abstraction is a class A class is composed of attributes (which represent the state of a class instance) and behaviors (which represent the things a class or class instance can do) From your background, you likely know attributes as instance fields or class level fields and behaviors as the methods of a class Note that a class can also be used to represent the notion of an Abstract Data Type (ADT), but an ADT can be even more abstract than that (it can be represented via an interface). Stay tuned for more!

The Pillars of OO Encapsulation This pillar is often considered part of Abstraction, but we ll separate the two It says that a class should contain/encapsulate all things necessary to represent and do whatever that class is about (e.g. a Student class will contain all things necessary attributes and behaviors to properly represent the concept of a Student and no more) Part of the notion of encapsulation is that HOW the behaviors of a class are implemented is not something things outside the class need to know about to work effectively with the class Another notion is that the data of a class should ALWAYS be hidden from the outside world to help maintain valid state for any objects of the class SIDE NOTE: Saying always is a bit extreme on the surface, but this should be your point of view unless you can clearly justify why it is ok for other entities to directly access any data a class contains. One justification might be that the data is final and static and you want the outside world to know about it (e.g. the Math class in the Java API has PI and E as public static final fields) In a nutshell encapsulation simply says None of your darned business!

The Pillars of OO Inheritance This pillar is made possible due to the previous two (Abstraction and Encapsulation) It allows us to build a new, more specialized version of an existing class The super/parent/base class is a generalization, the sub/child/derived class is a specialization It is characterized as an is-a relationship Say it out loud and if it makes some sense you might have an inheritance relationship (e.g. Circle is a Shape or Human is a Mammal, but not Shape is a Dodecahedron) It is a white-box approach to class design In order to properly utilize inheritance you must know about the workings and perhaps the data of the super/parent/base class this violates encapsulation principles!! If you are going to override a method, you need to know the specifics of that method to ensure you do not break contract with the behavior of that method Any fields declared anything other than private (protected, for example) will allow other classes to directly access those fields. Is this what you want, especially when programming in the large? It allows for code re-use, which is nice, but the fact that it is white box says we need to be VERY careful when we use it. Many times we should instead use composition, which is a black box approach to design

The Pillars of OO Polymorphism From the roots of the word it translates as many forms Is possible due to inheritance Any sub/child/derived class object is-a super/parent/base class object Allows us to have a super/parent/base class reference to any kind of sub/child/derived class object Shape s = new Circle( ); s = new Square( ); is also ok Allows for us to utilize polymorphic behavior Recall behavior is object oriented speak for method Polymorphic behavior says the version of a method that executes is determined at runtime based on the object(s) in memory (there is a dispatch process that is used to figure out the method this dispatch process can actually break down in some circumstances the Visitor pattern can help with this problem) Thus polymorphic behavior is enabled through method override in Java Side note: Java automatically supports polymorphic behavior, languages like C++ and C# require additional syntax to formally support it

So What is a Design Pattern? It is captured design expertise that solves a certain kind of problem in a software system It can be applied to a variety of different scenarios and enhance your software solution Design Patterns typically target what are know as Non-Functional Requirements. Some examples are Readability Testability Maintainability Re-usability There are many design patterns that are not OO in nature, we aren t here to talk about those There are also what are known as Anti Patterns check Wikipedia for some fun examples of them!

Some Words Regarding Work for the Course While assignments, etc. will be posted to Canvas, note that the majority of your work will involve application of patterns we learn to some software scenario. The first few assignments will focus on single patterns We will also do some refactoring assignments that incorporate patterns and OO principles Your final assignment/project will be quite large in scope and expect you to employ the OO and design principles we have discussed throughout the quarter as well as design patterns. The final assignment will allow for collaboration with a fellow student in the class if desired There will be two quizzes, a take home midterm (which will be open book and notes, but no Googling, etc.), and an in class final