Bridge The decoupling of abstraction and implementation.

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Bridge Pattern.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
C15: Design Patterns Gamma,Helm,Johnson,Vlissides (GOF)
PATTERNS -STRUCTURAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott.
The Bridge Pattern Guang Hu February Overview MotivationMotivation ParticipantsParticipants  Structure  Applicability  Benefits  Drawbacks 
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Structural Patterns - Page L6-1 PS95&96-MEF-L13-1 Dr. M.E. Fayad Creationa l Paradigm.
Patterns Lecture 2. Singleton Ensure a class only has one instance, and provide a global point of access to it.
Basic OOP Concepts and Terms
ECE 355 Design Patterns Tutorial Part 3 Presented by Igor Ivković
Patterns – Day 6 Adapter continued Reminders: Faculty candidate talk today 4:20 PM O-167. No class next Tuesday. Course newsgroup: rhit.cs.patterns.
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
Design Pattern – Bridge (Structural) References Yih-shoung Chen, Department of Information Engineering, Feng Chia University,Taiwan, R.O.C. The Bridge.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
GoF Sections 2.7 – 2.9 More Fun with Lexi. Lexi Document Editor Lexi tasks discussed:  Document structure  Formatting  Embellishing the user interface.
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
More OOP Design Patterns
Design Patterns.
Unit 23 Bridge Summary prepared by Kirk Scott 1. Design Patterns in Java Chapter 6 Bridge Summary prepared by Kirk Scott 2.
CS 4240: Bridge and Abstract Factory Readings:  Chap. 10 and 11 Readings:  Chap. 10 and 11.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Case Studies on Design Patterns Design Refinements Examples.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Chapter 26 GoF Design Patterns. The Adapter Design Pattern.
©Fraser Hutchinson & Cliff Green C++ Certificate Program C++ Intermediate Decorator, Strategy, State Patterns.
Design Patterns in Java Chapter 1 Introduction Summary prepared by Kirk Scott 1.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Structural Design Patterns
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns V More Structural Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
Creational Patterns
Define an interface for creating an object, but let subclasses decide which class to instantiate.
Design Patterns Structural Patterns. Adapter Convert the interface of a class into another interface clients expect Adapter lets classes work together.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Design Patterns Introduction
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
Bridge Bridge is used when we need to decouple an abstraction from its implementation so that the two can vary independently. This type of design pattern.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
Adaptor Bridge Composite UNIT-IV1 Repeated key points for Structural Patterns (Intent, Motivation, Also Known As…) Code Examples Reference
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
PROTOTYPE. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract factory.
The State Design Pattern A behavioral design pattern. Shivraj Persaud
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Command Pattern. Intent encapsulate a request as an object  can parameterize clients with different requests, queue or log requests, support undoable.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
Strategy Design Pattern
Web Technologies IT230 Dr Mohamed Habib.
Design Patterns Lecture part 2.
Factory Patterns 1.
Behavioral Design Patterns
More Interfaces, Dynamic Binding, and Polymorphism
Chapter 8, Design Patterns Bridge
object oriented Principles of software design
Design Patterns Satya Puvvada Satya Puvvada.
BRIDGE PATTERN.
Structural Pattern part-I introduction
Structural Patterns: Adapter and Bridge
ECE 355 Design Patterns Tutorial Part 3
Presentation transcript:

Bridge The decoupling of abstraction and implementation

Ideas GoF Intentions –Decouple an abstraction from it implementation so that the two can vary independently Metsker –Focuses on the implementation of an abstraction

Other Structural Patterns Adapter Composite Decorator Façade Flyweight Proxy

Uses You want to avoid a permanent binding between an abstraction and it's implementation. This might be the case, for example, when the implementation must be selected or switched at run-time. Both the abstractions and their implementations should be extensible by sub-classing. In this case, the Bridge pattern lets you combine the different abstractions and implementations and extend them independently. Changes in the implementation of an abstraction should have no impact on clients; that is, their code should not have been recompiled.

Real Uses What are some common uses of the Bridge pattern? –Drivers Applications System drivers –Window Interfaces X Window System Microsoft Windows –Application Programming Interfaces MFC JDBC

UML Diagram

Drivers JDBC is an application programming interface for executing SQL statements The drivers for JDBC and the applications that use JDBC are completely independent of each other –The same application can use an Oracle driver just as easily as a MySQL or Postgres driver

Challenge 6.1 Fill in the missing type names and the missing message name following illustration Class.forName(driverName); Connection c = DriverManager.getConnection(url, user, passwd); Statement s = c.createStatement(); ResultSet r = s.executeQuery(“select name, apogee from fireworks”); while(r.next()) { String name = r.getString(“name”); int apogee = r.getInt(“apogee”); System.out.println(name + “, “ + apogee); }

Challenge 6.1 Continued Fill in the missing type names and the missing message name following illustration

Abstract Class Refactoring Sometimes it is advantageous to refactor an abstract class to a Bridge pattern to gain more flexibility in the abstraction For instance, to separate the real-world implementation and a tester implementation

MachineController Refactoring Subclasses of MachineController exist for various types of machines and for various types of controllers Steps to refactor: –Move the abstract operations in the superclass into an interface –Define implementation classes that provide different implementations of the interface –Redefine the remaining operations in the abstract class as operations of the new interface

Challenge 6.3 Fill in the missing labels for MachineController interface

Summary Decoupling interface and implementation Improved extensibility Hiding implementation details from clients Other Patterns and Bridge –Abstract Factor can create and configure a particular Bridge –The Adapter and Bridge patterns are similar, but usually the Adapter pattern is used after the classes are created where as the Bridge pattern is used from in the ground-up design