Design Patterns. Structural Patterns. Oliver Haase
|
|
- Amelia Nicholson
- 5 years ago
- Views:
Transcription
1 Design Patterns Structural Patterns Oliver Haase 1
2 Purpose Structural patterns describe how to compose classes (incl. interfaces) and objects to get larger structures. Class based structural patterns use interface and implementation inheritance to compose classes and interfaces. Object based structural patterns use aggregation, composition, and associations to compose objects, in order to gain new functionality. 2
3 Adapter 3
4 Motivation Assume, a framework defines a base class (interface) that the specific custom class has to extend (implement), in order to be used in place of the base class (interface). The custom class might not be able to be hooked in this way, because 1.it is unmodifiable (e.g. third party software), or 2.it cannot extend the base class because it already has its own superclass. 4
5 Idea Write an adapter that adapts the custom class' interface to the required framework interface. 5
6 Example Situation: framework custom class VectorUtils filter(vector): Vector <<interface>> Colored isred()? Toy getcolor() for ( Colored item: in) if ( item.isred() ) out.add(item) How to make legacy class Toy look as if it had type Colored? 6
7 Example Solution 1: Object Adapter VectorUtils filter(vector): Vector for ( Colored item: in) if ( item.isred() ) out.add(item) framework <<interface>> Colored isred() custom class Toy getcolor() ToyAdapter toy isred() return toy.getcolor() == RED 7
8 Object Adapter - Code public class ToyAdapter implements Colored { private Toy toy; public ToyAdapter() { this.toy = new public boolean isred() { return toy.getcolor() == RED; 8
9 Example Solution 2: Class Adapter VectorUtils filter(vector): Vector for ( Colored item: in) if ( item.isred() ) out.add(item) framework <<interface>> Colored isred() custom class Toy getcolor() ToyAdapter isred() return getcolor() == RED 9
10 Class Adapter - Code public class ToyAdapter extends Toy implements Colored { public ToyAdapter() { public boolean isred() { return getcolor() == RED; 10
11 Object Adapter - Structure works with target interface. defines interface that the client uses. legacy class. Client Target operation() AdaptedClass similaroperation() Adapter adaptee operation() adaptee. similaroperation() adapts interface of AdaptedClass to required Target interface. 11
12 Class Adapter - Structure Client Target operation() AdaptedClass similaroperation() Adapter operation() similaroperation() 12
13 Class vs. Object Adapter Class Adapter single inheritance only applicable if Target is an interface only adapts AdaptedClass, not its subtypes Adapter can override some of AdaptedClass's behavior preserves object unity (Adapter & AdaptedClass) Object Adapter single inheritance always applicable adapts AdaptedClass and all its subtypes hard to override AdaptedClass's behavior ( subtype AdaptedClass, then adapt this subtype) requires two objects per adapted entity 13
14 Discussion Adapter might draw on multiple classes to provide target interface. Adapter deals with interface inheritance. For legacy code, this is completely sufficient ( legacy code can and need not be modified to take advantage of implementation inheritance). For new code that need not use implementation inheritance, the adapter pattern is sufficient, too. Other scenarios will be considered in the following section. 14
15 Implementation Reuse Patterns 15
16 Motivation Assume, a framework provides a base class that implements certain functionality that custom classes can subtype so as to inherit this functionality. The custom class might not able to be hooked in this way, because it already has its own superclass and thus cannot subclass the base class. However, it wants to benefit from the base class's functionality anyway. Note: This situation does not apply to unmodifiable legacy or third party software, which cannot and need not use the base functionality. 16
17 Situation framework BaseService operation() OwnSuper CustomService1 someoperation()... operation()...? CustomService2 otheroperation()... call of operation()... 17
18 Idea Use composition and delegation instead of inheritance. 18
19 Solution Case 1: BaseService is a concrete class framework BaseService operation() OwnSuper CustomService1 someoperation()... operation()... CustomService2 delegate otheroperation()... delegate.operation()... 19
20 Solution Case 2: BaseService is an abstract class framework BaseService operation() OwnSuper CustomService1 someoperation() SimpleBaseService operation() CustomService2 delegate otheroperation()... operation() delegate.operation()... 20
21 More Complex Situation Assume, a framework provides a base class that defines an interface that the specific custom class has to implement (interface inheritance), and implements certain functionality that custom classes that subtype the base class will inherit (implementation inheritance). The custom class might not able to be hooked in this way, because it already has its own superclass and thus cannot subclass the base class. Note: Third party software that cannot be modified can only be hooked in via an adapter cannot (and need not) use base functionality. 21
22 Idea Combine Adapter and Delegation patterns, i.e. use an adapter for interface inheritance and delegation for implementation inheritance. 22
23 Case 1: Concrete Base Class framework BaseService operation2() OwnSuper ConcreteService1? ConcreteService2 operation1'() operation2() call of operation2() adapt ConcreteService2 to BaseService interface let ConcreteService2 use BaseService.operation2() 23
24 Case 1: Concrete Base Class framework BaseService operation2() OwnSuper ConcreteService1 operation2() Adapter delegate delegate.operation1'() ConcreteService2 delegate operation1'() delegate.operation2() 24
25 Case 2: Abstract Base Class framework BaseService operation2() OwnSuper ConcreteService1 operation2()? ConcreteService2 delegate operation1'() delegate.operation2() adapt ConcreteService2 to BaseService interface let ConcreteService2 use BaseService.operation2() 25
26 Case 2: Abstract Base Class framework BaseService operation2() OwnSuper ConcreteService1 operation2() SmartAdapter delegate ConcreteService2 delegate operation1'() delegate.operation1'() delegate.operation2() Solution: SmartAdapter combines Adapter and SimpleBaseService functionality. 26
27 How is it Done Right? Providing a base class that needs to be extended for interface and implementation inheritance is not the silver bullet But then, how is it done right? provide for interface inheritance: an interface, and for implementation inheritance: - an (abstract, incomplete) skeletal implementation, or - a (concrete, complete) simple implementation of the interface 27
28 Interface & Implementation a) skeletal implementation b) simple implementation <<interface>> Service operation2() <<interface>> Service operation2() AbstractService operation2() operation3() SimpleService operation2() operation3() Note the naming convention for skeletal implementations! 28
29 Interface & Implementation Interface & implementation inheritance thru subclassing <<interface>> Service operation2() (using skeletal implementation, analogous for simple implementation) AbstractService operation2() operation3() ConcreteService otheroperation() operation3() 29
30 Interface & Implementation Pure interface inheritance <<interface>> Service operation2() AbstractService operation2() operation3() OwnSuper ConcreteService operation2() 30
31 Interface & Implementation Implementation inheritance thru delegation: 1) using simple implementation <<interface>> Service operation2() SimpleService operation2() operation3() ConcreteService delegate delegate.operation3() 31
32 Interface & Implementation Implementation inheritance thru delegation: 1) using skeletal implementation <<interface>> Service operation2() AbstractService operation2() operation3() SimpleService ConcreteService delegate operation2() delegate.operation3() 32
33 Adapting Legacy Code, I Class adapter: <<interface>> Service operation2() AbstractService operation2() operation3() LegacyCode similaroperation() Adapter similaroperation() 33
34 Adapting Legacy Code, II Object adapter: <<interface>> Service operation2() AbstractService operation2() operation3() LegacyCode similaroperation() Adapter delegate delegate.similaroperation() 34
35 Adapting Legacy Code, III If implementation inheritance helps adapting: <<interface>> Service operation2() SimpleService operation2() operation3() LegacyCode similaroperation() Adapter delegate operation3(); delegate.similaroperation() 35
36 Alternative Option : Reverse Delegation <<interface>> Service OwnSuper operation() if ( specialization!= null ) specialization.operation() else // own implementation SimpleService specialization: Service operation() ConcreteService1 anotheroperation() ConcreteService2 operation() anotheroperation() Note: specialization object usually passed into SimpleService s c'tor. 36
37 Reverse Delegation - Example Java Thread Class interface Runnable OwnSuper run() // create new thread if ( specialization!= null ) specialization.run() else this.run() { Thread specialization: Runnable start() run() run() MyThread2 MyThread1 run() 37
38 Delegation vs. Reverse Delegation Delegation + client uses instance of ConcreteService with its extended interface - ConcreteService must implement delegation Reverse Delegation - client uses instance of Service with its narrow interface + ConcreteService does not need to implement delegation 38
39 Proxy 39
40 Description Also known as: Surrogate Purpose: Control access to a subject through indirection, i.e. a placeholder object (proxy) that provides the same interface and that delegates operation calls to the actual subject. Computer Science is the discipline that believes all problems can be solved with one more layer of indirection. - Dennis DeBruler. 40
41 Applicability Common reasons to hide a subject behind a proxy: local placeholder for remote communication; basic idea behind Remote Procedure Call (RPC), Remote Method Invocation (RMI) Remote Proxy create expensive objects only on demand Virtual Proxy Example: high resolution graphic in text document, virtual proxy might only know size (bounding box) and position. 41
42 Applicability Common reasons to hide a subject behind a proxy: control access to original subject Protection Proxy access control can mean to only filter out interfaces that shall not be usable, or a full-fledged authentication and authorization mechanism. need for an intelligent reference that e.g. counts number of existing references to subject (needed for automatic garbage collection) Smart Reference 42
43 Structure Client interface through which clients access subject Subject operation() has reference to real subject controls access to real subject might create real subject on demand further functionality depends on kind of proxy Proxy delegate operation() RealSubject operation() The real thing delegate.operation() 43
44 Implementation Example: A service interface that contains methods for usage, for administration, and methods to get a usage or administration proxy: public interface ServiceUsage { void use(); public interface ServiceAdmin { void administrate(int state); public interface Service extends ServiceAdmin, ServiceUsage { ServiceAdmin getadminproxy(); ServiceUsage getusageproxy(); 44
45 Implementation Simple Service implementation... public class ConcreteService implements Service { private int state; private class ConcreteAdminProxy implements ServiceAdmin public void administrate(int state) { ConcreteService.this.administrate(state); private class ConcreteUsageProxy implements ServiceUsage public void use() { ConcreteService.this.use(); 45
46 Implementation... public ServiceAdmin getadminproxy() { return new public ServiceUsage getusageproxy() { return new public void administrate(int state) { this.state = public void use() { System.out.println("state: " + state); 46
47 Implementation Sample application that creates a ConcreteService, then feeds an administration thread with an AdministrationProxy and a usage thread with a UsageProxy. public class Application { private static class AdminThread extends Thread { private final ServiceAdmin serviceadmin; public AdminThread(ServiceAdmin serviceadmin) { this.serviceadmin = serviceadmin; public void run() { for ( int value = 0; true; value++ ) { serviceadmin.administrate(value); try { TimeUnit.SECONDS.sleep(5); catch ( Exception e) { 47
48 Implementation... continued... private static class UsageThread extends Thread { private final ServiceUsage serviceusage; public UsageThread(ServiceUsage serviceusage) { this.serviceusage = serviceusage; public void run() { while ( true ) { serviceusage.use(); try { TimeUnit.SECONDS.sleep(2); catch ( Exception e) { 48
49 Implementation... continued: public static void main(string[] args) { ConcreteService service = new ConcreteService(); ServiceAdmin sa = service.getadminproxy(); ServiceUsage su = service.getusageproxy(); new AdminThread(sa).start(); new UsageThread(su).start(); 49
50 Implementation Variant with dynamic proxies: Java allows to create dynamic proxies that implement a set of interfaces specified at run-time. public class ConcreteService implements Service public ServiceAdmin getadminproxy() { return (ServiceAdmin) Proxy.newProxyInstance( ServiceAdmin.class.getClassLoader(), new Class[] {ServiceAdmin.class, new public ServiceUsage getusageproxy() { return (ServiceUsage) Proxy.newProxyInstance( ServiceUsage.class.getClassLoader(), new Class[] {ServiceUsage.class, new DelegationHandler(this));... 50
51 Implementation Class DelegationHandler forwards all incoming calls to delegate object: public class DelegationHandler implements InvocationHandler { private Service delegate; public DelegationHandler(Service delegate) { this.delegate = public Object invoke(object proxy, Method method, Object[] args) throws Throwable { return method.invoke(delegate, args); 51
52 Implementation Java 5 uses dynamic proxies for Java RMI: When an RMI server object is exported, the runtime system (Java virtual machine) creates a dynamic proxy (RMI stub) that implements the respective remote interface, and forwards all methods calls to the remote server object. This obsoletes the necessity to create stub classes (rmic) beforehand. 52
53 Bridge 53
54 Purpose Decouple abstraction (interfaces) and implementation, such that both can evolve independently of each other. A computer once beat me at chess, but it was no match to me at kick-boxing - Emo Philips 54
55 Motivation Communication send(op, params): void receive(): Result TcpCommunication send(op, params): void receive(): Result UdpCommunication send(op, params): void receive(): Result Scenario: Provide more comfortable RemoteOpComm interface without modification of existing type hierarchy. 55
56 Motivation Communication send(op, params): void receive(): Result TcpCommunication send(op, params): void receive(): Result UdpCommunication send(op, params): void receive(): Result RemoteOpComm invoke(op, params): Result send(op, params) return receive() 56
57 Motivation Communication send(op, params): void receive(): Result TcpCommunication send(op, params): void receive(): Result UdpCommunication send(op, params): void receive(): Result RemoteOpComm invoke(op, params): Result send(op, params) return receive() TcpRemOpComm send(op, params): void receive(): Result UdpRemOpComm send(op, params): void receive(): Result Problem: Implementation classes TCPCommunication and UDPCommunication must be duplicated. 57
58 Solution using Bridge Pattern Client Communication impl send(op, params): void receive(): Result CommunicationImpl send(op, params): void receive(): Result Bridge impl.send(op, params) return impl.receive() RemoteOpComm invoke(op, params): Result send(op, params) return receive() TcpCommunication send(op, params): void receive(): Result UdpCommunication send(op, params): void receive(): Result 58
59 General Structure defines interface for implementation classes (can differ from Abstraction) Client defines interface of the abstraction maintains reference to implementor instance Abstraction impl operation() Implementor operation() Bridge impl.operation() Specialization specialoperation() ConcreteImplementorA operation() ConcreteImplementorB operation() extends Abstraction through usage of Abstraction s operations provides implementation of Implementor interface 59
60 Implications the abstractions (left hand side) use only the functionality provided by class Implementor. Additional functionality in the subclasses cannot be taken advantage of; additional functionality in sub-interfaces must be achieved only through usage of the general functionality as contained in the root interface Abstraction. Bridge leads to loose coupling of abstraction and implementation Implementor object can be replaced at run-time 60
61 Implementation Who decides when and how, what particular Implementor object to use? Option 1: Specialization object, based on the params passed in at construction time. Example: Collection object that gets initialized with small initial size uses LinearList implementation. Large Collection object uses BTree implementation. (Note: Implementation can be dynamically replaced as the collection grows.) 61
62 Implementation Option 1I: Others decide creational patterns! Specialization object gets fed with factory or prototype Dependency injection Specialization object gets passed in Implementor object by Client. 62
Design Patterns and Frameworks Command
Design Patterns and Frameworks Command Oliver Haase Oliver Haase Emfra Command 1/13 Description Classification: Object-based behavioral pattern Purpose: Encapsulate a command as an object. Allows to dynamically
More informationSoftware Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt.
Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Summer Semester 2015 Proxy Pattern From the client s point of view, the proxy
More informationSoftware Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt.
Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Winter Semester 16/17 Proxy Pattern From the client s point of view, the proxy
More informationFactory Method. Comp435 Object-Oriented Design. Factory Method. Factory Method. Factory Method. Factory Method. Computer Science PSU HBG.
Comp435 Object-Oriented Design Week 11 Computer Science PSU HBG 1 Define an interface for creating an object Let subclasses decide which class to instantiate Defer instantiation to subclasses Avoid the
More informationSoftware Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt.
Summer Term 2018 1 Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Proxy Pattern 2 From the client s point of view, the proxy
More informationDesign Patterns. Decorator. Oliver Haase
Design Patterns Decorator Oliver Haase 1 Motivation Your task is to program a coffee machine. The machine brews plain coffee, coffee with cream, sugar, sweetener, and cinnamon. A plain coffee costs 0,90,
More informationIntroduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of
Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Computer Science Technische Universität Darmstadt Dr.
More informationFinal Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format
Final Exam Final Exam Review CS 4354 Fall 2012 Jill Seaman Friday, December 14, 11AM Closed book, closed notes, clean desk Content: Textbook: Chapters 1, 2, 4-10 Java Lectures, GRASP + JUnit 35% of your
More informationCS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)
CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationSoftware Design COSC 4353/6353 D R. R A J S I N G H
Software Design COSC 4353/6353 D R. R A J S I N G H Design Patterns What are design patterns? Why design patterns? Example DP Types Toolkit, Framework, and Design Pattern A toolkit is a library of reusable
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 informationChair of Software Engineering. Languages in Depth Series: Java Programming. Prof. Dr. Bertrand Meyer. Exercise Session 10
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Exercise Session 10 Today s Exercise Session Pattern of the Day Proxy Quizzes 2 Proxy Pattern Structural
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
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 informationRemote Procedure Call
Remote Procedure Call Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: Module (remote object) exports operations, invoked with call. call blocks (delays
More informationDesign Pattern and Software Architecture: IV. Design Pattern
Design Pattern and Software Architecture: IV. Design Pattern AG Softwaretechnik Raum E 3.165 Tele.. 60-3321 hg@upb.de IV. Design Pattern IV.1 Introduction IV.2 Example: WYSIWYG Editor Lexi IV.3 Creational
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 informationComponent ConcreateComponent Decorator ConcreateDecoratorA ConcreteDecoratorB
Comp435 Object-Oriented Design Week 12 Computer Science PSU HBG Attach additional responsibilities to an object dynamically Provide a flexible alternative to subclassing for extending functionality Attach
More informationIndex. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107
A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105
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 informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
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 informationObject Oriented Paradigm
Object Oriented Paradigm Ming-Hwa Wang, Ph.D. Department of Computer Engineering Santa Clara University Object Oriented Paradigm/Programming (OOP) similar to Lego, which kids build new toys from assembling
More informationCOURSE 2 DESIGN PATTERNS
COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
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 informationTowards Reengineering: An Approach Based on Reverse Inheritance. Application to Java
Towards Reengineering: An Approach Based on Reverse Inheritance. Application to Java Ciprian-Bogdan Chirilă, Pierre Crescenzo, Philippe Lahire chirila@cs.utt.ro Pierre.Crescenzo@unice.fr Philippe.Lahire@unice.fr
More informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 1 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Definition A pattern is a reusable solution to a commonly occurring problem within
More informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
More informationEINDHOVEN UNIVERSITY OF TECHNOLOGY
EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationG Programming Languages Spring 2010 Lecture 9. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 9 Robert Grimm, New York University 1 Review Last week Modules 2 Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic
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 information2.1 Design Patterns and Architecture (continued)
MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Timed Automata
More information2.1 Design Patterns and Architecture (continued)
MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Abstract
More informationObject-oriented Software Design Patterns
Object-oriented Software Design Patterns Concepts and Examples Marcelo Vinícius Cysneiros Aragão marcelovca90@inatel.br Topics What are design patterns? Benefits of using design patterns Categories and
More informationDecorator Pattern. Decorator Pattern. Decorator Problems Decorator Examples Proxy Pattern. Motivation Structure Decorator vs Inheritance vs Strategy
Decorator Pattern Decorator Pattern Motivation Structure Decorator vs Inheritance vs Strategy Decorator Problems Decorator Examples Proxy Pattern 1 Vibrating & Skin Phones 2 Implementation with Inheritance
More informationUsing the Bridge Design Pattern for OSGi Service Update
Using the Bridge Design Pattern for OSGi Service Update Hans Werner Pohl Jens Gerlach {hans,jens@first.fraunhofer.de Fraunhofer Institute for Computer Architecture and Software Technology (FIRST) Berlin
More informationAbstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.
a and Interfaces Class Shape Hierarchy Consider the following class hierarchy Shape Circle Square Problem AND Requirements Suppose that in order to exploit polymorphism, we specify that 2-D objects must
More informationTop Down Design vs. Modularization
6.170 Quiz Review Topics: 1. Decoupling 2. 3. AF & RI 4. Iteration Abstraction & Iterators 5. OMs and Invariants 6. Equality, Copying, Views 7. 8. Design Patterns 9. Subtyping 10. Case Studies Decomposition
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 informationRemote Method Invocation
Remote Method Invocation RMI Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in 1 Agenda Introduction Creating
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 informationTHOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS
THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS LOGISTICS HW3 due today HW4 due in two weeks 2 IN CLASS EXERCISE What's a software design problem you've solved from an idea you learned from someone else?
More informationComposite Pattern - Shapes Example - Java Sourcecode
Composite Pattern - Shapes Example - Java Sourcecode In graphics editors a shape can be basic or complex. An example of a simple shape is a line, where a complex shape is a rectangle which is made of four
More informationWhat is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?
What is a Pattern? Lecture 40: Design Patterns CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki "Each pattern describes a problem which occurs over and over again in our environment, and then describes
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 informationbe 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
UNIT 4 GRASP GRASP: Designing objects with responsibilities Creator Information expert Low Coupling Controller High Cohesion Designing for visibility - Applying GoF design patterns adapter, singleton,
More informationObject Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)
Introduction Objective To support interoperability and portability of distributed OO applications by provision of enabling technology Object interaction vs RPC Java Remote Method Invocation (RMI) RMI Registry
More informationPrototype Description. Interpreter. interpreter Calculator Design Rationales. Prototype Participants. Interpreter with Factory Method.
Onno van Roosmalen Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek October 3, 2014 Content Implementation Description with Factory Participants Implementation Description with Factory
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 informationCH. 2 OBJECT-ORIENTED PROGRAMMING
CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED
More informationChapter 8, Object Design: Reusing Pattern Solutions
Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Reusing Pattern Solutions Application Objects and Solution Objects Application objects, also called domain objects,
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 informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 12 Thomas Wies New York University Review Last lecture Modules Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationA Reconnaissance on Design Patterns
A Reconnaissance on Design Patterns M.Chaithanya Varma Student of computer science engineering, Sree Vidhyanikethan Engineering college, Tirupati, India ABSTRACT: In past decade, design patterns have been
More informationSoftware Engineering Design & Construction
Winter Semester 17/18 Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt A Critical View on Inheritance 2 A Critical View On Inheritance
More informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
More informationKeywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.
Comparative Study In Utilization Of Creational And Structural Design Patterns In Solving Design Problems K.Wseem Abrar M.Tech., Student, Dept. of CSE, Amina Institute of Technology, Shamirpet, Hyderabad
More informationIntroflection. Dave Landers BEA Systems, Inc.
Introflection Dave Landers BEA Systems, Inc. dave.landers@bea.com Agenda What is Introflection? Primary Classes and Objects Loading Classes Creating Objects Invoking Methods Java Beans Proxy What is Introflection?
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 informationSingleton Pattern Creational
Singleton Pattern Creational Intent» Ensure a class has only one instance» Provide a global point of access Motivation Some classes must only have one instance file system, window manager Applicability»
More informationObject Oriented Methods with UML. Introduction to Design Patterns- Lecture 8
Object Oriented Methods with UML Introduction to Design Patterns- Lecture 8 Topics(03/05/16) Design Patterns Design Pattern In software engineering, a design pattern is a general repeatable solution to
More informationIntroduction to Software Engineering: Object Design I Reuse & Patterns
Introduction to Software Engineering: Object Design I Reuse & Patterns John T. Bell Department of Computer Science University of Illinois, Chicago Based on materials from Bruegge & DuToit 3e, Chapter 8,
More informationExtensibility Patterns: Extension Access
Design Patterns and Frameworks Dipl.-Inf. Florian Heidenreich INF 2080 http://st.inf.tu-dresden.de/teaching/dpf Exercise Sheet No. 5 Software Technology Group Institute for Software and Multimedia Technology
More informationExercise: Singleton 1
Exercise: Singleton 1 In some situations, you may create the only instance of the class. 1 class mysingleton { 2 3 // Will be ready as soon as the class is loaded. 4 private static mysingleton Instance
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationDesign Patterns Revisited
CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public.it-sudparis.eu/~gibson/teaching/csc7322/ Design Patterns Revisited /~gibson/teaching/csc7322/l13-designpatterns-2.pdf
More informationChapter 4 Remote Procedure Calls and Distributed Transactions
Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 4 Remote Procedure Calls and Distributed Transactions Outline
More informationAppendix A - Glossary(of OO software term s)
Appendix A - Glossary(of OO software term s) Abstract Class A class that does not supply an implementation for its entire interface, and so consequently, cannot be instantiated. ActiveX Microsoft s component
More informationCommunication and Distributed Processing
Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 4 Remote Procedure Calls and Distributed Transactions Outline
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 informationObject Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.
CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java
More informationCS 520 Theory and Practice of Software Engineering Fall 2018
Today CS 520 Theory and Practice of Software Engineering Fall 2018 Object Oriented (OO) Design Principles September 13, 2018 Code review and (re)design of an MVC application (and encapsulation) Polymorphism
More informationMethodHandle implemention tips and tricks
MethodHandle implemention tips and tricks Dan Heidinga J9 VM Software Developer daniel_heidinga@ca.ibm.com J9 Virtual Machine 2011 IBM Corporation MethodHandles: a 30 sec introduction A method handle is
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
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 informationChair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: reflection
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: reflection Outline Introductory detour: quines Basic reflection Built-in features Introspection Reflective method invocation
More informationArgument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.
Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar
More informationAdapter pattern. Acknowledgement: Freeman & Freeman
Adapter pattern Acknowledgement: Freeman & Freeman Example Scenario The European wall outlet exposes one interface for getting power The adapter converts one interface into another The US laptop expects
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 informationCompaq Interview Questions And Answers
Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not
More informationSDC Design patterns GoF
SDC Design patterns GoF Design Patterns The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products. The design pattern is a description of communicating
More informationDesigning and Writing a Program. Divide and Conquer! The Design-Code-Debug Cycle. Documentation is Code. Pair Programming 3/8/2012
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 13: Designing, Coding, and Documenting Designing and Writing a Program Don't sit down at the terminal
More informationThe Proxy Pattern. Design Patterns In Java Bob Tarr
The Proxy Pattern Intent Provide a surrogate or placeholder for another object to control access to it Also Known As Surrogate Motivation A proxy is a person authorized to act for another person an agent
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. SE3A04 Tutorial. Jason Jaskolka
SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November 18/19, 2014 Jason Jaskolka 1 / 35 1
More informationADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya
ADAPTER Presented By: Mallampati Bhava Chaitanya Topics Intent Motivation Applicability Structure Participants & Collaborations Consequences Sample Code Known Uses Related Patterns Intent Convert the interface
More informationSoftware Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns
Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Today we are going to talk about an important aspect of design that is reusability of design. How much our old design
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 informationDesign Patterns. Claus Jensen
Design Patterns Claus Jensen What is a Design Pattern? A design pattern Abstracts a recurring design structure Distils design experience Promotes reuse of design and code Gives an opportunity to see how
More informationObject-Oriented Oriented Programming Adapter Pattern. CSIE Department, NTUT Woei-Kae Chen
Object-Oriented Oriented Programming Adapter Pattern CSIE Department, NTUT Woei-Kae Chen Adapter: Intent Convert the interface of a class into another interface clients expect. Adapter lets classes work
More informationComposite Pattern. IV.4 Structural Pattern
IV.4 Structural Pattern Motivation: Compose objects to realize new functionality Flexible structures that can be changed at run-time Problems: Fixed class for every composition is required at compile-time
More informationThe GoF Design Patterns Reference
The GoF Design Patterns Reference Version.0 / 0.0.07 / Printed.0.07 Copyright 0-07 wsdesign. All rights reserved. The GoF Design Patterns Reference ii Table of Contents Preface... viii I. Introduction....
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 informationDesign Patterns. (and anti-patterns)
Design Patterns (and anti-patterns) Design Patterns The Gang of Four defined the most common object-oriented patterns used in software. These are only the named ones Lots more variations exist Design Patterns
More informationMore on Inheritance. Interfaces & Abstract Classes
More on Inheritance Interfaces & Abstract Classes Java interfaces A Java interface is used to specify minimal functionality that a client requires of a server. A Java interface contains: method specifications
More informationINTERNAL ASSESSMENT TEST III Answer Schema
INTERNAL ASSESSMENT TEST III Answer Schema Subject& Code: Object-Oriented Modeling and Design (15CS551) Sem: V ISE (A & B) Q. No. Questions Marks 1. a. Ans Explain the steps or iterations involved in object
More informationOverview of Java Threads (Part 3)
Overview of Java Threads (Part 3) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning
More information