Object-Oriented Programming

Slides:



Advertisements
Similar presentations
Creational Patterns (2) CS350/SE310 Fall, Lower the Cost of Maintenance Economic Goal Coupling-Cohesion, Open-Close, Information-Hiding, Dependency.
Advertisements

Winter 2007ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Open-closed principle.
Strategy Pattern1 Design Patterns 1.Strategy Pattern How to design for flexibility?
Inheritance issues SE-2811 Dr. Mark L. Hornick 1.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Delegates & Events Observer and Strategy Patterns Game Design Experience Professor Jim Whitehead January 30, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
Spring 2010ACS-3913 Ron McFadyen1 Duck Example Consider the text example (up to page 6). Each type of duck is a subclass of Duck Most subclasses implement.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
COMP 121 Week 02. Agenda Review this week’s expected outcomesReview this week’s expected outcomes Review Guided Learning Activity solutionsReview Guided.
DAAD project “Joint Course on OOP using Java” Design Patterns in the course ‘OOP in Java’ - first experiences Ana Madevska Bogdanova Institute of informatics.
Design Patterns.
Chapter 1: Introduction to Design Patterns. SimUDuck Example.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
CS 210 Introduction to Design Patterns September 7 th, 2006.
Session 21 Chapter 10: Mechanisms for Software Reuse.
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
1 Computer Science 340 Software Design & Testing Inheritance.
DAAD project “Joint Course on OOP using Java” On Object Oriented modeling in Java (Why & How) Ana Madevska Bogdanova Institute of informatics Faculty of.
Design Patterns
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
OO as a language for acm l OO phrase l Mental model of key concepts.
The Strategy Pattern SE-2811 Dr. Mark L. Hornick 1 Class 1-2.
Week 6, Class 1 & 2: Decorators Return Exam Questions about lab due tomorrow in class? Threads Locking on null object invokeLater & the squares example.
Object Oriented Software Development
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
SE-2811 Software Component Design Week 1, Day 2 (and 1-3 and 2-1) SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1.
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
The Strategy Pattern SE-2811 Dr. Mark L. Hornick 1.
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
CS 210 Introduction to Design Patterns August 29, 2006.
Inspired by the Oulipu. The 3 Tenets of OO Encapsulation Polymorphism Inheritance.
CS 210 Review October 3, 2006.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
Decorator Design Pattern Phillip Shin. Overview Problem Solution Example Key points.
It started with a simple … A highly successful duck pond simulation game called SimUDuck The game can show a large variety of duck swimming and making.
SE-2811 Software Component Design Week 1, Day 2 Making teams Warm-up exercise Design pattern defined SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick.
Systems Requirements SE 3821 Design? Algorithms CS 2852.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
SE-2811 Software Component Design Week 1, Day 1 Design pattern defined Code that needs a design pattern… SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick.
SE 461 Software Patterns Welcome to Design Patterns.
Intro to Design Pattern
Design Patterns: MORE Examples
Sections Inheritance and Abstract Classes
Strategy Pattern.
Week 2, Day 1: The Factory Method Pattern
Behavioral Design Patterns
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Week 4 Object-Oriented Programming (1): Inheritance
Types of Programming Languages
object oriented Principles of software design
Design Patterns
Strategy Design Pattern
SE-2811 Software Component Design
OO Design - Observer Pattern
SE-2811 Software Component Design
MSIS 670 Object-Oriented Software Engineering
lecture 08, OO Design Principle
OO Design Patterns - Decorator
SE-2811 Software Component Design
State Design Pattern Brandon Jacobsen.
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Delegation vs inheritance
Design Patterns Lecture part 1.
14. Factory Pattern SE2811 Software Component Design
14. Factory Pattern SE2811 Software Component Design
Software Design Lecture : 27.
Presentation transcript:

Object-Oriented Programming OO Design Patterns Object-Oriented Programming

Simple SimUDuck app A duck pond simulation game A large variety of duck species swimming and making quacking sounds Examples of duck species: mallards, red head ducks, mandarin ducks Đại học Công nghệ - ĐHQG HN OO Design Pattern

First Solution Đại học Công nghệ - ĐHQG HN OO Design Pattern

Then… ducks need to fly How to change the design? Đại học Công nghệ - ĐHQG HN OO Design Pattern

What about rubber duckies? Đại học Công nghệ - ĐHQG HN OO Design Pattern

What about decoy ducks? Đại học Công nghệ - ĐHQG HN OO Design Pattern

Disadvantage of using inheritance to provide Duck behavior? A. Code is duplicated across subclasses. B. Runtime behavior changes are difficult C. We can’t make duck dances. D. Hard to gain knowledge of all duck behaviors E. Ducks can’t fly and quack at the same time F. Changes can unintentionally affect other ducks What do you think? Đại học Công nghệ - ĐHQG HN OO Design Pattern

Your solution? Đại học Công nghệ - ĐHQG HN OO Design Pattern

Using interfaces? What do you think about this design? Đại học Công nghệ - ĐHQG HN OO Design Pattern

Separate things that vary from things that stay the same Design Principle #1 Separate things that vary from things that stay the same Đại học Công nghệ - ĐHQG HN OO Design Pattern

Separating what varies from what stays the same Đại học Công nghệ - ĐHQG HN OO Design Pattern

Program to an interface not an implementation Design Principle #2 Program to an interface not an implementation Đại học Công nghệ - ĐHQG HN OO Design Pattern

Đại học Công nghệ - ĐHQG HN OO Design Pattern

Examples Đại học Công nghệ - ĐHQG HN OO Design Pattern

Examples Programming to an implementation Programming to an interface/superclass can assign the concrete implementation at run-time Đại học Công nghệ - ĐHQG HN OO Design Pattern

Behavior interfaces and classes Other types of objects can reuse fly and quack behaviors We can add new behaviors w/o modifying any of the existing behavior classes or touching any of the Duck classes that use flying behavior Đại học Công nghệ - ĐHQG HN OO Design Pattern

Behavior interfaces and classes Other types of objects can reuse fly and quack behaviors We can add new behaviors w/o modifying any of the existing behavior classes or touching any of the Duck classes that use flying behavior Đại học Công nghệ - ĐHQG HN OO Design Pattern

Behavior interfaces and classes Other types of objects can reuse fly and quack behaviors We can add new behaviors w/o modifying any of the existing behavior classes or touching any of the Duck classes that use flying behavior Đại học Công nghệ - ĐHQG HN OO Design Pattern

Superclass Duck Đại học Công nghệ - ĐHQG HN OO Design Pattern

Superclass Duck Đại học Công nghệ - ĐHQG HN OO Design Pattern

Duck’s Subclasses Đại học Công nghệ - ĐHQG HN OO Design Pattern

Setting Behavior dynamically How? Đại học Công nghệ - ĐHQG HN OO Design Pattern

Favor composition over inheritance Design Principle #3 Favor composition over inheritance Đại học Công nghệ - ĐHQG HN OO Design Pattern

The pattern Đại học Công nghệ - ĐHQG HN OO Design Pattern

Homework Đại học Công nghệ - ĐHQG HN OO Design Pattern