TDDB84 Design Patterns Lecture 06
|
|
- Neal Richard
- 6 years ago
- Views:
Transcription
1 Lecture 06 Mediator, Adapter, Bridge Peter Bunus Dept of Computer and Information Science Linköping University, Sweden The Mediator Peter Bunus 2 1
2 Peter Bunus 3 The Mediator Non Software Example Control Tower Mediator Flight 34 Flight 456 Air Force One Flight 111 The Mediator defines an object that controls how a set of objects interact. The pilots of the planes approaching or departing the terminal area communicate with the tower, rather than explicitly communicating with one another. The constraints on who can take off or land are enforced by the tower. the tower does not control the whole flight. It exists only to enforce constraints in the terminal area. Peter Bunus 4 2
3 The Mediator Another Example Bob lives in the HouseOfFuture where everthing is automated: When Bob hits the snooze button of the alarm the coffee maker starts brewing coffee No coffee in weekends... onevent(){ checkcalendar(); checksprinkler(); startcoffee(); //do more stuff onevent(){ checkcalendar(); checkalarm(); //do more stuff onevent(){ checkdayoftheweek(); doshower(); docoffee(); doalarm(); //do more stuff onevent(){ checkcalendar(); checkshower(); checktemperature //do more stuff Peter Bunus 5 The Mediator in Action With a Mediator added to the system all the appliance objects can be greatly simplified They tell the mediator when their state changes They respond to requests from the Mediator It s such a relief, not having to figure out that Alarm clock picky rules if(alarmevent)(){ checkcalendar(); checkshower(); checktemp(); //do more stuff if(weekend){ checkweather(); if(trashday){ resetalarm(); Peter Bunus 6 3
4 Mediator and MFC (Microsoft Foundation Classes) The Client creates afontdialog and invokes it. The list box tells the FontDialog ( it's mediator ) that it has changed The FontDialog (the mediator object) gets the selection from the list box The FontDialog (the mediator object) passes the selection to the entry field edit box Peter Bunus 7 Actors in the Mediator Pattern Mediator defines an interface for communicating with Colleague objects ConcreteMediator implements cooperative behavior by coordinating Colleague objects knows and maintains its colleagues Colleague classes (Participant) each Colleague class knows its Mediator object (has an instance of the mediator) each colleague communicates with its mediator whenever it would have otherwise communicated with another colleague Peter Bunus 8 4
5 Yet Another Example Robbery in progress. I need backup Officer down, officer down!!! We have casualties Peter Bunus 9 Mediator advantages and disadvantages Changing the system behavior means just sub classing the mediator. Other objects can be used as is. Since the mediator and its colleagues are only tied together by a loose coupling, both the mediator and colleague classes can be varied and reused independent of each other. Since the mediator promotes a One-to-Many relationship with its colleagues, the whole system is easier to understand (as opposed to a many-to-many relationship where everyone calls everyone else). It helps in getting a better understanding of how the objects in that system interact, since all the object interaction is bundled into just one class - the mediator class. Since all the interaction between the colleagues are bundled into the mediator, it has the potential of making the mediator class very complex and monolithically hard to maintain. Peter Bunus 10 5
6 Issues When an event occurs, colleagues must communicate that event with the mediator. This is somewhat reminiscent of a subject communicating a change in state with an observer. One approach to implementing a mediator, therefore, is to implement it as an observer following the observer pattern. Peter Bunus 11 Time For Course Evaluation What I have liked about this course What I didn t liked about this course What should be improved Peter Bunus 12 6
7 The Adapter Peter Bunus 13 Adapter Non Software Example Peter Bunus 14 7
8 Time to be Adaptive Remember my Ducks? public interface Duck { public void quack(); public void fly(); public class MallardDuck implements Duck { public void quack() { System.out.println("Quack"); I m flying Quack public void fly() { System.out.println("I'm flying"); Peter Bunus 15 The New Bird Now it is time for the newest fowl on the block public interface Turkey { public void gobble(); public void fly(); public class WildTurkey implements Turkey { public void gobble() { System.out.println("Gobble gobble"); public void fly() { System.out.println("I'm flying a short distance"); Peter Bunus 16 8
9 Adapting Turkeys Now let s say you are short on Ducks and you would like to use some Turkey objects in their place. So let s write an adapter. public class TurkeyAdapter implements Duck { Turkey turkey; public TurkeyAdapter(Turkey turkey) { this.turkey = turkey; public void quack() { turkey.gobble(); First you need to adapt the interface of the type you are adapting to. This is the interface your client expect to see Next we need to get a refence to the object that we are adapting Now we need to implement all the methods in the interface public void fly() { for(int i=0; i < 5; i++) { turkey.fly(); Even though both interface have a fly() method, Turkeys fly a short spurts they can do long distance flying like ducks Peter Bunus 17 Duck Test Drive public class DuckTestDrive { public static void main(string[] args) { MallardDuck duck = new MallardDuck(); WildTurkey turkey = new WildTurkey(); Duck turkeyadapter = new TurkeyAdapter(turkey); System.out.println("The Turkey says..."); turkey.gobble(); turkey.fly(); System.out.println("\nThe Duck says..."); testduck(duck); System.out.println("\nThe TurkeyAdapter says..."); testduck(turkeyadapter); static void testduck(duck duck) { duck.quack(); duck.fly(); Peter Bunus 18 9
10 Adapting Ducks public class DuckAdapter implements Turkey { Duck duck; Random rand; public DuckAdapter(Duck duck) { this.duck = duck; rand = new Random(); public void gobble() { duck.quack(); public void fly() { if (rand.nextint(5) == 0) { duck.fly(); Peter Bunus 19 Turkey Test Drive public class TurkeyTestDrive { public static void main(string[] args) { MallardDuck duck = new MallardDuck(); Turkey duckadapter = new DuckAdapter(duck); for(int i=0;i<10;i++) { System.out.println("The DuckAdapter says..."); duckadapter.gobble(); duckadapter.fly(); Peter Bunus 20 10
11 Adapter Example Peter Bunus 21 Class Adapter A class adapter uses multiple inheritance to adapt one interface to another Peter Bunus 22 11
12 Object Adapter An object adapter relies on object composition Peter Bunus 23 The Bridge Peter Bunus 24 12
13 Bridge Non Software Example Peter Bunus 25 Remote Control Imagine that you are going to revolutionize extreme lounging by writting the code for a new remote control for TVs There will be a lots of implementations one for each model of a TV Peter Bunus 26 13
14 The Remote Control Example This an abstraction. It could be an iterface or an abstract class RemoteControl +on() +off() +setchannel() Every Remote has the same abstraction LGControl SonyControl GrundigControl Lots of implementations for each TV +on() +off() +setchannel() +on() +off() +setchannel() { tunechannel(chanel) +on() +off() +setchannel() Peter Bunus 27 Dilema A product usually is refined many times. So the remote are going to change We have already abstracted the user interface so we can vary the implementation over many TVs We need to vary the abstraction as well since remotes are changing (eventually improving) Peter Bunus 28 14
15 The Bridge Pattern Remote Control Example The Bridge allows you to vary the implementation and the abstraction by placing the two in a separate class hierarchy Abstraction class hierarchy The relantionship between the two is refered to as the bridge Implementation class hierarchy All methods in the abstraction are implemented in terms of the abstraction Concrete subclasses are implemented in terms of the abstraction, not the implementation Peter Bunus 29 Advantages/Disadvantages Decouples an implementation so that is not bound permanently to an interface Abstraction and implementation can be extended independently Changes to concrete abstraction classes don t affect the client Useful in graphic and windowing systems that need to run over multiple platforms Useful any time you need to vary an interface and an implementation in different ways Increases complexity Peter Bunus 30 15
16 The Bridge Pattern Structure Peter Bunus 31 The Bridge Example Peter Bunus 32 16
17 Bridge An Example Peter Bunus 33 17
TDDB84: Lecture 6. Adapter, Bridge, Observer, Chain of Responsibility, Memento, Command. fredag 4 oktober 13
TDDB84: Lecture 6 Adapter, Bridge, Observer, Chain of Responsibility, Memento, Command Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter Template method Behavioral
More informationFACADE & ADAPTER CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 7 09/13/2011
FACADE & ADAPTER CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 7 09/13/2011 1 Goals of the Lecture Introduce two design patterns Facade Adapter Compare and contrast the two patterns 2 Facade
More informationMore Patterns. Acknowledgement: Head-first design patterns
More Patterns Acknowledgement: Head-first design patterns Chain of Responsibility Acknowledgement: Head-first design patterns Problem Scenario: Paramount Pictures has been getting more email than they
More informationTDDB84: Lecture 5. Singleton, Builder, Proxy, Mediator. fredag 27 september 13
TDDB84: Lecture 5 Singleton, Builder, Proxy, Mediator Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter Template method Behavioral Iterator Mediator Chain of responsibility
More informationDefine an object that encapsulates how a set of objects interact.
MEDIATOR Presented By: Mallampati Bhava Chaitanya Intent Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other
More information07. ADAPTER AND FACADE PATTERNS. Being Adaptive
BIM492 DESIGN PATTERNS 07. ADAPTER AND FACADE PATTERNS Being Adaptive Adapters all around us Have you ever needed to use a US-made laptop in a European country?? Can you think different kinds of power
More informationTDDB84. Summary & wrap-up & some tips & some design patterns & some other stuff. tisdag 20 oktober 15
TDDB84 Summary & wrap-up & some tips & some design patterns & some other stuff Agenda Course goals, expectations Writing papers: FAQ Design Patterns revisited Course summary Life after the course Course
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Adapter 1 Adapters in real life (anglo-centric.) Object-Oriented Adapters Hugly Duckling example public interface Duck { public void display(); public void
More informationProgrammazione. Prof. Marco Bertini
Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Design patterns Design patterns are bug reports against your programming language. - Peter Norvig What are design
More informationDesign Patterns (Part 2) CSCE Lecture 18-10/25/2016 (Partially adapted from Head First Design Patterns by Freeman, Bates, Sierra, and Robson)
Design Patterns (Part 2) CSCE 740 - Lecture 18-10/25/2016 (Partially adapted from Head First Design Patterns by Freeman, Bates, Sierra, and Robson) Objectives for Today The point of OO: Separate what changes
More informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Adapter 1 Adapters in real life (anglo-centric.) Object-Oriented Adapters public interface Duck { public void display(); public void swim(); public class
More informationDesign Patterns: State, Bridge, Visitor
Design Patterns: State, Bridge, Visitor State We ve been talking about bad uses of case statements in programs. What is one example? Another way in which case statements are sometimes used is to implement
More informationTDDB84 Design Patterns Lecture 05. Builder, Singleton, Proxy. pelab
Lecture 05 Builder, Singleton, Proxy Peter Bunus Dept of Computer and Information Science Linköping University, Sweden petbu@ida.liu.se The Constitution of Software Architects Encapsulate what varies.
More informationModellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico
Modellistica Medica Maria Grazia Pia INFN Genova Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico 2002-2003 Lezione 9 OO modeling Design Patterns Structural Patterns Behavioural Patterns
More informationObject-Oriented Concepts and Design Principles
Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation
More informationCOSC 3351 Software Design. Design Patterns Behavioral Patterns (I)
COSC 3351 Software Design Design Patterns Behavioral Patterns (I) Spring 2008 Purpose Creational Structural Behavioral Scope Class Factory Method Adapter(class) Interpreter Template Method Object Abstract
More informationTDDB84 Design Patterns Lecture 09. Interpreter, Facade
Lecture 09 Interpreter, Facade Peter Bunus Dept of Computer and Information Science Linköping University, Sweden petbu@ida.liu.se Interpreter Peter Bunus 2 1 The Interpreter Non Software Example Musical
More informationDesign Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)
Design Pattern CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) A. Design Pattern Design patterns represent the best practices used by experienced
More informationTDDB84 Design Patterns Lecture 02. Factory Method, Decorator
Lecture 02 Factory Method, Decorator Peter Bunus Dept of Computer and Information Science Linköping University, Sweden petbu@ida.liu.se Factory Method Pattern Peter Bunus 2 1 Time for Lunch Joe, with the
More informationDesign Patterns: Template Method, Strategy, State, Bridge
Design Patterns: Template Method, Strategy, State, Bridge [HFDP, Ch. 8] Say we have two classes whose code looks similar, but isn t identical. We can duplicate the code, but change it where changes are
More information! Statechart diagrams contain. ! States. ! Transitions. ! States : A,B,C, A is initial state. ! Labels : 0,1. ! Transitions:
Lecture 3! UML diagrams! state-chart diagrams! Design Pattern Hat Problem! Three persons each one wearing a hat that is either red or blue with 5% probability.! A person can see the colours of the other
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Mediator Memento Prototype 1 Design patterns, Laura Semini, Università di Pisa, Dipartimento di Informatica. Mediator 2 Design patterns, Laura Semini, Università
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Bridge 1 The Bridge Pattern The Bridge Pattern permits to vary the implementation and abstraction by placing the two in seperate hierarchies. Decouple an
More informationAn Introduction to Patterns
An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture
More informationStructural Design Patterns. CSE260, Computer Science B: Honors Stony Brook University
Structural Design Patterns CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 Structural Design Patterns Design patterns that ease the design by identifying
More informationSoftware Eningeering. Lecture 9 Design Patterns 2
Software Eningeering Lecture 9 Design Patterns 2 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator, Facade, Flyweight,
More informationDesign Patterns Reid Holmes
Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary
More informationDesign Patterns Lecture 2
Design Patterns Lecture 2 Josef Hallberg josef.hallberg@ltu.se 1 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator,
More informationCSE 70 Final Exam Fall 2009
Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15
More informationInheritance and Polymorphism in Java
Inheritance and Polymorphism in Java Introduction In this article from my free Java 8 course, I will be discussing inheritance in Java. Similar to interfaces, inheritance allows a programmer to handle
More informationEPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns
EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 6: Design Patterns Links to Design Pattern Material 1 http://www.oodesign.com/ http://www.vincehuston.org/dp/patterns_quiz.html Types of Design Patterns 2 Creational
More informationDesign patterns. Jef De Smedt Beta VZW
Design patterns Jef De Smedt Beta VZW Who Beta VZW www.betavzw.org Association founded in 1993 Computer training for the unemployed Computer training for employees (Cevora/Cefora) 9:00-12:30 13:00-16:00
More informationThe Factory Method Pattern
The Factory Method Pattern Intent: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses. 1 The
More informationDesign Patterns Design patterns advantages:
Design Patterns Designing object-oriented software is hard, and designing reusable object oriented software is even harder. You must find pertinent objects factor them into classes at the right granularity
More informationInheritance and Interfaces
Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical
More informationDesign Patterns V Structural Design Patterns, 2
Structural Design Patterns, 2 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Department of Computer Science The Australian National University 19.1 1 2 Formal 3 Formal 4 Formal
More informationLecture 20: Design Patterns II
Lecture 20: Design Patterns II Software System Design and Implementation ITCS/ITIS 6112/8112 001 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte Nov.
More informationCSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich
CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and
More informationObject-Oriented Design
Object-Oriented Design Lecturer: Raman Ramsin Lecture 15: Object-Oriented Principles 1 Open Closed Principle (OCP) Classes should be open for extension but closed for modification. OCP states that we should
More informationUsing Design Patterns in Java Application Development
Using Design Patterns in Java Application Development ExxonMobil Research & Engineering Co. Clinton, New Jersey Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S.
More informationCSE wi Final Exam 3/12/18. Name UW ID#
Name UW ID# There are 13 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationRelationships amongst Objects
Relationships amongst Objects By Rick Mercer with help from Object-Oriented Design Heuristics Arthur Riel Addison-Wesley, 1996, ISBN 0-201-6338-X 8-1 Outline Consider six relationships between objects
More informationDesign Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1
What is a Design Pattern? Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights and other writers rarely
More informationHuman Computer Interaction Lecture 08 [ Implementation Support ] Implementation support
Human Computer Interaction Lecture 08 [ Implementation Support ] Imran Ihsan Assistant Professor www.imranihsan.com aucs.imranihsan.com HCI08 - Implementation Support 1 Implementation support programming
More informationThe Strategy Pattern Design Principle: Design Principle: Design Principle:
Strategy Pattern The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Design
More informationOverview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008
Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object
More informationimplementation support
Implementation support chapter 8 implementation support programming tools levels of services for programmers windowing systems core support for separate and simultaneous usersystem activity programming
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Startegy 1 Strategy pattern: the duck 2 Strategy pattern: the duck 3 The rubber duck 4 First solution Override fly() Class Rubberduck{ fly() { \\ do nothing
More informationPolymorphism. Final Exam. November 26, Method Overloading. Quick Review of Last Lecture. Overriding Methods.
Final Exam Polymorphism Time: Thursday Dec 13 @ 4:30-6:30 p.m. November 26, 2007 Location: Curtiss Hall, room 127 (classroom) ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
More informationDESIGN PATTERN - INTERVIEW QUESTIONS
DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions
More informationECE 449 OOP and Computer Simulation Lecture 11 Design Patterns
ECE 449 Object-Oriented Programming and Computer Simulation, Fall 2017, Dept. of ECE, IIT 1/60 ECE 449 OOP and Computer Simulation Lecture 11 Design Patterns Professor Jia Wang Department of Electrical
More informationProduced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar
Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationAgile Architecture. The Why, the What and the How
Agile Architecture The Why, the What and the How Copyright Net Objectives, Inc. All Rights Reserved 2 Product Portfolio Management Product Management Lean for Executives SAFe for Executives Scaled Agile
More informationTDDB84 Design Patterns Lecture 10. Prototype, Visitor
Lecture 10 Prototype, Visitor Peter Bunus Dept of Computer and Information Science Linköping University, Sweden petbu@ida.liu.se Prototype Peter Bunus 2 Prototype Non Software Example Peter Bunus 3 Motivational
More informationTDDB84 Design Patterns Lecture 10. Prototype, Visitor
Lecture 10 Prototype, Visitor Peter Bunus Dept of Computer and Information Science Linköping University, Sweden petbu@ida.liu.se Prototype Peter Bunus 2 1 Prototype Non Software Example Peter Bunus 3 Motivational
More informationProduced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar
Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationBridge Pattern. Used to decouple an abstraction from its implementation so that the two can vary independently
Bridge Pattern Used to decouple an abstraction from its implementation so that the two can vary independently What that means Abstraction and implementation are not related in the sense that the implementation
More informationHW3a solution. L1 implies there must be an f1 in Base L2 implies there must be an f2 in Base. So we know there is an f1 and f2 in Base
HW 3 Solution int main(int argc, char **argv) { Base *b = new Base( ); Derived *d = new Derived( ); b->f1( ); // prints "Base f1" L1 b->f2( ); // prints "Base f2" L2 d->f1( ); // prints "Base f1" L3 d->f2(
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 8(b): Abstract classes & Polymorphism Lecture Contents 2 Abstract base classes Concrete classes Polymorphic processing Dr. Amal Khalifa,
More informationObject-Oriented Design
Object-Oriented Design Department of Computer Engineering Lecture 12: Object-Oriented Principles Sharif University of Technology 1 Open Closed Principle (OCP) Classes should be open for extension but closed
More informationConsiderations. New components can easily be added to a design.
Composite Pattern Facilitates the composition of objects into tree structures that represent part-whole hierarchies. These hierarchies consist of both primitive and composite objects. Considerations Clients
More informationExample: Count of Points
Example: Count of Points 1 public class Point { 2... 3 private static int numofpoints = 0; 4 5 public Point() { 6 numofpoints++; 7 } 8 9 public Point(int x, int y) { 10 this(); // calling Line 5 11 this.x
More informationObject-Oriented Design
Object-Oriented Design Lecturer: Raman Ramsin Lecture 20: GoF Design Patterns Creational 1 Software Patterns Software Patterns support reuse of software architecture and design. Patterns capture the static
More informationSoftware Development Project. Kazi Masudul Alam
Software Development Project Kazi Masudul Alam Course Objective Study Programming Best Practices Apply the knowledge to build a Small Software in Groups 7/10/2017 2 Programming Best Practices Code Formatting
More informationBinghamton University. CS-140 Fall Dynamic Types
Dynamic Types 1 Assignment to a subtype If public Duck extends Bird { Then, you may code:. } Bird bref; Duck quack = new Duck(); bref = quack; A subtype may be assigned where the supertype is expected
More informationTopics in Object-Oriented Design Patterns
Software design Topics in Object-Oriented Design Patterns Material mainly from the book Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides; slides originally by Spiros Mancoridis;
More informationProgramming using C# LECTURE 07. Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism
Programming using C# LECTURE 07 Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism What is Inheritance? A relationship between a more general class, called the base class
More informationImprove Your SystemVerilog OOP Skills
1 Improve Your SystemVerilog OOP Skills By Learning Principles and Patterns Jason Sprott Verilab Email: jason.sprott@verilab.com www.verilab.com Experts in SV Learn Design Patterns 2 Look, you don t need
More informationTDDB84 Design Patterns Lecture 09. State, Prototype, Visitor, Flyweight
TDDB84 Design Patterns Lecture 09 State, Prototype, Visitor, Flyweight Peter Bunus Department of Computer and Information Science Linköping University, Sweden peter.bunus@liu.se TDDB84 Design Patterns
More informationAdmin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance
Admin CS 112 Introduction to Programming q Class project Inheritance Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu 2 Recap: OOP Analysis
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
More informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 2 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Structural patterns Part 2 Decorator Intent: It attaches additional responsibilities
More informationDesign Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester
Design Patterns Comp2110 Software Design Department of Computer Science Australian National University Second Semester 2005 1 Design Pattern Space Creational patterns Deal with initializing and configuring
More informationService-Oriented Architecture
Service-Oriented Architecture The Service Oriented Society Imagine if we had to do everything we need to get done by ourselves? From Craftsmen to Service Providers Our society has become what it is today
More informationCOMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016
COMP-202: Foundations of Programming Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016 Learn about cutting-edge research over lunch with cool profs January 18-22, 2015 11:30
More informationMore About Objects. Zheng-Liang Lu Java Programming 255 / 282
More About Objects Inheritance: passing down states and behaviors from the parents to their children. Interfaces: requiring objects for the demanding methods which are exposed to the outside world. Polymorphism
More informationBEHAVIORAL DESIGN PATTERNS
BEHAVIORAL DESIGN PATTERNS BEHAVIORAL DESIGN PATTERNS Identifies common communication patterns between objects that realize these patterns Describes the objects and classes interact and divide responsibilities
More informationMOCKING TO FACILITATE UNIT TESTING. Abstract
MOCKING TO FACILITATE UNIT TESTING Abstract Unit Testing is easy if the object you're testing has no dependencies. In reality, however, objects have dependencies, often making it di!cult, if not impossible,
More informationDiscussion. Type 08/12/2016. Language and Type. Type Checking Subtypes Type and Polymorphism Inheritance and Polymorphism
Type Joseph Spring Discussion Languages and Type Type Checking Subtypes Type and Inheritance and 7COM1023 Programming Paradigms 1 2 Type Type denotes the kind of values that programs can manipulate: Simple
More informationSocket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.
Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise
More informationSOFTWARE PATTERNS. Joseph Bonello
SOFTWARE PATTERNS Joseph Bonello MOTIVATION Building software using new frameworks is more complex And expensive There are many methodologies and frameworks to help developers build enterprise application
More informationSoftware Engineering
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
More informationNotes - Recursion. A geeky definition of recursion is as follows: Recursion see Recursion.
Notes - Recursion So far we have only learned how to solve problems iteratively using loops. We will now learn how to solve problems recursively by having a method call itself. A geeky definition of recursion
More informationSoftware Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.
Software Design Patterns Jonathan I. Maletic, Ph.D. Department of Computer Science Kent State University J. Maletic 1 Background 1 Search for recurring successful designs emergent designs from practice
More informationOutline Key Management CS 239 Computer Security February 9, 2004
Outline Key Management CS 239 Computer Security February 9, 2004 Properties of keys Key management Key servers Certificates Page 1 Page 2 Introduction Properties of Keys It doesn t matter how strong your
More informationCS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers
CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some
More informationWhat is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1
Polymorphism Part 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid adult
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationInheritance. OOP: Inheritance 1
Inheritance Reuse Extension and intension Class specialization and class extension Inheritance The protected keyword revisited Inheritance and methods Method redefinition An widely used inheritance example
More informationDesign Patterns: Structural and Behavioural
Design Patterns: Structural and Behavioural 3 April 2009 CMPT166 Dr. Sean Ho Trinity Western University See also: Vince Huston Review last time: creational Design patterns: Reusable templates for designing
More informationHow Does the Implementation of the Proxy Pattern in Python Affect Flexibility as Measured by DAM, MOA, NOP and DCC?
How Does the Implementation of the Proxy Pattern in Python Affect Flexibility as Measured by DAM, MOA, NOP and DCC? Oscar Johansson TDDB84: Design Patterns Linköping University Linköping, Sweden oscjo411@student.liu.se
More informationFirst IS-A Relationship: Inheritance
First IS-A Relationship: Inheritance The relationships among Java classes form class hierarchy. We can define new classes by inheriting commonly used states and behaviors from predefined classes. A class
More informationInformation Systems Analysis and Design. XIV. Design Patterns. Design Patterns 1
XIV. Design Patterns Design Patterns 1 Program Architecture 3 tier Architecture Design Patterns 2 Design Patterns - Motivation & Concept Christopher Alexander A Pattern Language: Towns, Buildings, Construction
More informationObject- Oriented Design with UML and Java Part I: Fundamentals
Object- Oriented Design with UML and Java Part I: Fundamentals University of Colorado 1999-2002 CSCI-4448 - Object-Oriented Programming and Design These notes as free PDF files: http://www.softwarefederation.com/cs4448.html
More informationDesign Patterns Reid Holmes
Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary
More informationPolymorphism Part 1 1
Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid
More informationExpanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011
Expanding Our Horizons CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 1 Goals of the Lecture Cover the material in Chapter 8 of our textbook New perspective on objects and encapsulation
More informationCSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich
CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 09 Inheritance What is Inheritance? In the real world: We have general terms for objects in the real
More information