15
PATTERN HATCHING: CH. 5 GOF: FAÇADE PATTERN Josh Mason 6/29/2009

P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

Embed Size (px)

Citation preview

Page 1: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

PATTERN HATCHING: CH. 5GOF: FAÇADE PATTERNJosh Mason

6/29/2009

Page 2: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

7 HABITS OF EFFECTIVE PATTERN WRITERS

1. Taking Time to Reflect2. Adhering to a Structure3. Being Concrete Early and Often4. Keeping Patterns Distinct and

Complementary5. Presenting Effectively6. Iterating Tirelessly7. Collecting and Incorporating Feedback

Page 3: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

1. TAKING TIME TO REFLECT

Reflect on prior experience Record experience incrementally

Write down problem Write down approach to problem Write down failed approaches

Look at other systems and their solutions Not enough time? Read about them. Look at what patterns were used Analyze if a pattern is a variation of another well

known pattern Found a new pattern?

Ensure there are two example of problem Go to step 2

Page 4: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

2. ADHERING TO A STRUCTURE

Write-up should include at least Name Problem description Context and justification of solution Solution to problem

Pick a structure and stick to it

Page 5: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

3. BEING CONCRETE EARLY AND OFTEN

Concrete ideas easier to understand then abstract ones

Consider having a motivation section first Have a concrete example Refer to example when discussing solution

abstractly Tell the “whole truth”

Include shortcomings Pitfalls etc.

Page 6: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

4. KEEPING PATTERNS DISTINCT AND COMPLEMENTARY

Ask, “How is pattern X different form Y?” Make it clear to reader the distinction Let intent of pattern be your guide

Don’t let class structure guide you Only so many class hierarchies

Make sure patterns are orthogonal Merge related patterns

Compare your pattern with other patterns

Page 7: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

5. PRESENTING EFFECTIVELY

Quality determined by effective presentation Use the best software tools Be good at typesetting Make liberal use of drawings to illustrate key

ideas Have a good writing style

Down to earth Don’t be pretentious Write conversationally Read a book on writing style

Page 8: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

6. ITERATING TIRELESSLY

Realize, you’ll likely never get the pattern completely right

Expect to rewrite your pattern many times Don’t try to perfect a single pattern before

attempting another Patterns don’t exist in isolation A change to one could impact another

Page 9: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

7. COLLECTING AND INCORPORATING FEEDBACK

“No pattern can be trusted until it is used by someone other than its author”

Patterns are obvious to writer, not necessarily readers

Get feedback from colleagues Look for opportunities to use your pattern Disseminate your pattern as wide as possible Be prepared for feedback

Take the good with the bad Give reviewers the benefit of the doubt

Page 10: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE PATTERN

Makes a subsystem easier to use Defines a higher-level interface to make life

easier

Page 11: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE - MOTIVATION

Reduce complexity Minimize dependencies Shield subsystem classes from client

Page 12: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE – APPLICABILITY

Use Façade Pattern when Want to provide a simple interface to a complex

subsystem Want to decouple a subsystem from the clients Want to layer your subsystems

Use façade to define entry point at each subsystem level

Mutually dependent subsystem communicate through their facades

Page 13: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE – PARTICIPANTS

Façade Everyone else

Subsystem classes

Page 14: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE – CONSEQUENCES

Benefits Shields client from subsystem components Promotes weak coupling between subsystem and

clients Can easily swap one subsystem with another Reduces compilation dependencies

Client classes can still use subsystem classes directly if needed

Disadvantages May lose functionality in subsystem

Page 15: P ATTERN H ATCHING : C H. 5 G O F: F AÇADE P ATTERN Josh Mason 6/29/2009

FAÇADE – RELATED PATTERNS

Abstract Factory Provide an interface for creating subsystem

objects in a subsystem-independent way Mediator

Colleagues communicate through mediator Mediator centralizes communication and

sometimes functionality Façade simply abstracts an interface for an

entire subsystem Singleton

Typically only one façade is required