Using Design Patterns in Java Application Development

Similar documents
Applying the Observer Design Pattern

Applying the Decorator Design Pattern

Applying the Factory Method Design Pattern

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

SDC Design patterns GoF

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Design Patterns. An introduction

Object-Oriented Design

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

The Strategy Pattern Design Principle: Design Principle: Design Principle:

DESIGN PATTERN - INTERVIEW QUESTIONS

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Object-Oriented Oriented Programming

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Object-oriented Software Design Patterns

Object-Oriented Design

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Design patterns. Jef De Smedt Beta VZW

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Tuesday, October 4. Announcements

Topics in Object-Oriented Design Patterns

Design Patterns. Gunnar Gotshalks A4-1

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Object Oriented Paradigm

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

What is Design Patterns?

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Software Design COSC 4353/6353 D R. R A J S I N G H

Brief Note on Design Pattern

Design Patterns. CSC207 Fall 2017

Introduction to Software Engineering: Object Design I Reuse & Patterns

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Application Architectures, Design Patterns

1 Software Architecture

Review Software Engineering October, 7, Adrian Iftene

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

The GoF Design Patterns Reference

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design Patterns. CSC207 Winter 2017

UNIT I Introduction to Design Patterns

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

3 Product Management Anti-Patterns by Thomas Schranz

CS251 Software Engineering Lectures 18: Intro to DP

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Design Patterns: Structural and Behavioural

SOLID DESIGN PATTERNS FOR MERE MORTALS

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Patterns. CSC207 Fall 2017

A Reconnaissance on Design Patterns

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

UNIT I Introduction to Design Patterns

Applying Design Patterns to SCA Implementations

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

Recognizing And Understanding AntiPatterns In Java Application Development

An Introduction to Patterns

CS/CE 2336 Computer Science II

2.1 Design Patterns and Architecture (continued)

2.1 Design Patterns and Architecture (continued)

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Design patterns. OOD Lecture 6

What is Design Patterns?

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

Introduction and History

A Metric for Measuring the Abstraction Level of Design Patterns

DESIGN PATTERNS FOR MERE MORTALS

A Rapid Overview of UML

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

An Introduction to Patterns

Overview of Patterns: Introduction

Design Patterns. GoF design patterns catalog

be 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

Information systems modelling UML and service description languages

A Metric of the Relative Abstraction Level of Software Patterns

A Primer on Design Patterns

Summary of the course lectures

SOFTWARE PATTERNS. Joseph Bonello

Composite Pattern. IV.4 Structural Pattern

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Foundations of Software Engineering Design Patterns -- Introduction

Analysis of Design Patterns in Java with Rational Rhapsody as the New Building Blocks of Software Engineering

Design Pa*erns. + Anima/on Undo/Redo Graphics and Hints

What is Design Patterns?

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Nat. Thomas Software Engineering Telephonics Inc. Long Island IEEE Lecture Series

An Expert System for Design Patterns Recognition

Software Engineering I (02161)

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

Transcription:

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. in Computer Science Rutgers University (go Scarlet Knights!) ExxonMobil Research & Engineering Senior Research Technician (1988-1998, 2004-present) Systems Analyst (1998-2002) Ai-Logix, Inc. Technical Support Engineer (2003-2004) ACGNJ Java Users Group Leader Publications James: The Java Apache Mail Enterprise Server + co-authored with Barry Burd + Java Boutique 1

Gang of Four (GoF) Erich Gamma Richard Helm Ralph Johnson John Vlissides Design Patterns Elements of Reusable Object-Oriented Software Erich Gamma, et. al ISBN 0-201-63361-2 1995 2

What are Design Patterns? Recurring solutions to software design problems that are repeatedly found in real-world application development All about the design and interaction of objects Four essential elements: The pattern name The problem The solution The consequences 3

How Design Patterns Solve Design Problems Find appropriate objects Helps identify less obvious abstractions Program to an interface, not an implementation Clients should only know about abstract classes that define an interface Reduces implementation dependencies Design for change Avoid creating objects directly Avoid dependencies on specific operations Avoid algorithmic dependencies Avoid tight coupling 4

Design Pattern Categories Creational Abstracts the instantiation process Dynamically create objects so that they don t have to be instantiated directly Structural Composes groups of objects into larger structures Behavioral Defines communication among objects in a given system Provides better control of flow in a complex application 5

Creational Patterns Abstract Factory Provides an interface for creating related objects without specifying their concrete classes Builder Reuses the construction process of a complex object Factory Method Lets subclasses decide which class to instantiate from a defined interface Prototype Creates new objects by copying a prototype Singleton Ensures a class has only one instance with a global point of access to it 6

Structural Patterns Adapter Converts the interface of one class to an interface of another Bridge Decouples an abstraction from its implementation Composite Composes objects into tree structures to represent hierarchies Decorator Attaches responsibilities to an object dynamically Façade Provides a unified interface to a set of interfaces 7

Structural Patters (continued) Flyweight Supports large numbers of fine-grained objects by sharing Proxy Provides a surrogate for another object to control access to it 8

Behavioral Patterns Chain of Responsibility Passes a request along a chain of objects until the appropriate one handles it Command Encapsulates a request as an object Interpreter Defines a representation and an interpreter for a language grammar Iterator Provides a way to access elements of an object sequentially without exposing its implementation Mediator Defines an object that encapsulates how a set of objects interact 9

Behavioral Patterns (continued) Memento Captures an object s internal state so that it can be later restored to that state if necessary Observer Defines a one-to-many dependency among objects State Allows an object to alter its behavior when its internal state changes Strategy Encapsulates a set of algorithms individually and makes them interchangeable Template Method Lets subclasses redefine certain steps of an algortithm Visitor Defines a new operation without changing the classes on which it operates 10

Factory Method Intent Defines an interface for creating an object, but lets subclasses decide which class to instantiate Lets a class defer instantiation to subclasses Also known as Virtual Constructor Motivation To solve the problem of one class knowing when to create a class of another type, but not knowing what kind of class to create Design Principle Depend upon abstractions; do not depend upon concrete classes 11

Factory Method Use this pattern when: A class can t anticipate the class of objects is must create A class would prefer for its subclasses to specify the objects it creates There is a need for a class to localize one of several helper classes that can be delegated a responsibility 12

Factory Method 13

Decorator Intent Attaches additional responsibilities to an object dynamically Provides a flexible alternative to subclassing for extending functionality Also known as Wrapper Motivation Allows classes to be easily extended to incorporate new behavior without modifying existing code Design Principle Classes should be open for extension, but closed for modification 14

Decorator Use this pattern: To add responsibilities to individual objects dynamically and transparently without affecting other objects For responsibilities that can be withdrawn When extension by subclassing is impractical 15

Decorator 16

Mediator Intent Defines simplified communication among classes Defines an object that encapsulates how a set of objects interact Promotes loose coupling by keeping objects from referring to each other explicitly, and allow the developer to vary their interaction independently Motivation To avoid the many interconnections among objects that can lead to a maintenance headache 17

Mediator Use this pattern when: A set of objects communicate in well-defined but complex ways Reusing an object is difficult because it refers to and communicates with many other objects A behavior that is distributed among several classes should be customizable without a lot of subclassing 18

Mediator 19

Observer Intent Defines a one-to-many dependency among objects so that when one object changes state, all its dependents are notified and updated automatically A way of notifying change to a number of classes Also known as Dependents Publish-Subscribe Motivation To avoid making classes tightly coupled that would reduce their reusability Design Principle Strive for loosely coupled designs among objects that interact 20

Observer Use this pattern when: A change to one object requires changing others, and the number of objects to be changed is unknown An object should be able to notify other objects without making assumptions about who these objects are + Avoids having these objects tightly coupled 21

Observer 22

Resources Design Patterns Elements of Reusable Object-Oriented Software Erich Gamma, et. al ISBN 0-201-63361-2 Java Design Patterns James W. Cooper ISBN 0-201-48539-7 UML Distilled Martin Fowler (with Kendall Scott) ISBN 0-201-32563-2 Head First Design Patterns Eric & Elisabeth Freeman (with Kathy Sierra & Bert Bates) ISBN 0-596-00712-4 Data & Object Factory http://www.dofactory.com/ 23