Mind Mind Mind Point to Share Knowlege  
 
   
  Add New Map Add New Map About us About us Help Help Contact us Contact us  

Software design patterns

please flag with care:
best of
error
spam
 
2007-11-06No history Add My version 
download mind map 106273685.mm (mindmap file created by  FreeMind)

  
This is a sample from FreeMind Mind Map Gallery. http://freemind.sourceforge.net/wiki/index.php/Mind_Map_Gallery#Maps_in_English 
 
outline 
Software design patterns
clasification on usage
+ - Creational Patterns
Abstract Factory
Provide an interface for creating families of related or dependent objects
without specifying their concrete classes.
Builder
Separate the construction of a complex object from its representation so that
the same construction process can create different representations.
creation of an aggregate's elements
Factory Method
Define an interface for creating an object, but let subclasses decide which
class to instantiate. Factory Method lets a class defer instantiation to
subclasses.
virtual creation through inheritance
Descriptive names- avoid overloading
Example: javax.xml.parsers.DocumentBuilderFactory
limitations: extensibility -> inheritance
Prototype
Specify the kinds of objects to create using a prototypical instance, and create
new objects by copying this prototype.
clone()
Singleton
Ensure a class only has one instance, and provide a global point of access to
it.
public static Singleton getInstance()
~>Initialization on demand holder idiom
class initialization phase is guaranteed by the JLS to be serial
+ - Structural Patterns
Adapter
Convert the interface of a class into another interface clients expect. Adapter
lets classes work together that couldn't otherwise because of incompatible
interfaces.
wrap a legacy component
Bridge
Decouple an abstraction from its implementation so that the two can vary
independently.
decouple interface and implementation
Composite
Compose objects into tree structures to represent part-whole hierarchies.
Composite lets clients treat individual objects and compositions of objects
uniformly.
recursive composition
Example: javax.management.CompositeData
Decorator
Composite Compose objects into tree structures to represent part-whole
hierarchies. Composite lets clients treat individual objects and compositions of
objects uniformly.
scrollbar is the "decoration" to the webpage
Facade
Provide a unified interface to a set of interfaces in a subsystem. Facade
defines a higher-level interface that makes the subsystem easier to use.
simple front-end to a complicated subsystem
Flyweight
Use sharing to support large numbers of fine-grained objects efficiently.
use sharing to optimize lots of "little" objects
use hashmap (week) to cache, override equals, hashcode
Proxy
Provide a surrogate or placeholder for another object to control access to it.
Behavioral Patterns
Chain of Responsibility
Avoid coupling the sender of a request to its receiver by giving more than one
object a chance to handle the request. Chain the receiving objects and pass the
request along the chain until an object handles it.
single processing pipe, many possible handlers
+ - Command
Encapsulate a request as an object, thereby letting you parameterize clients
with different requests, queue or log requests, and support undoable operations.
Analogy: meal order at a restaurant
encapsulate a request as an object
~>uml
thread pool class works with an internal queue of tasks waiting to be done.
Tasks are Command objects.
Parallel Processing
Strategy
Define a family of algorithms, encapsulate each one, and make them
interchangeable. Strategy lets the algorithm vary independently from clients
that use it.
plug-compatible algorithms;
algorithms can be selected on-the-fly at runtime;
uses composition instead of inheritance.
Example - Routing Strategies: Static, Dinamic
Observer
Define a one-to-many dependency between objects so that when one object changes
state, all its dependents are notified and updated automatically.
Analogy: news subsscription
Listener
State
Allow an object to alter its behavior when its internal state changes. The
object will appear to change its class.
object's behavior morphs as its state changes
State is more dynamic than strategy
Memento
Without violating encapsulation, capture and externalize an object's internal
state so that the object can be restored to this state later.
checkpoint/rollback an object's internal state
Iterator
Provide a way to access the elements of an aggregate object sequentially without
exposing its underlying representation.
Analogy: secr accessing her file system
decouple traversal of an aggregate object
Interpreter
Given a language, define a represention for its grammar along with an
interpreter that uses the representation to interpret sentences in the language.
Analogy: musician reading music
Visitor
Represent an operation to be performed on the elements of an object structure.
Visitor lets you define a new operation without changing the classes of the
elements on which it operates.
decouple operations on an aggregate object
ability to add new operations to existing object structures without modifying
those structures
~>The Visitor Design Pattern
Template Method
Define the skeleton of an algorithm in an operation, deferring some steps to
subclasses. Template Method lets subclasses redefine certain steps of an
algorithm without changing the algorithm's structure.
constant algorithm, replaceable steps
Mediator
Define an object that encapsulates how a set of objects interact. Mediator
promotes loose coupling by keeping objects from referring to each other
explicitly, and it lets you vary their interaction independently.
Analogy: airport control tower
+ - Concurrency patterns
Thread pool pattern
Double-checked locking
will work with volatile in >= j2se5.0
The "Double-Checked Locking is Broken" Declaration
Just define the singleton as a static field in a separate class.
It will work for 32-bit primitive values
Read/write lock pattern
Thread-local storage
ThreadLocal local = new ThreadLocal();
Monitor (synchronization)
lock.acquire(); lock.release();
Hoare vs. Mesa semantics
Reactor pattern
Active Object
Balking pattern
IllegalStateException
Guarded suspension
Leaders/followers pattern
history
Design Patterns (GOF)
Anti Patern
a pattern that tells how to go from a problem to a bad solution.
~>Catalog
~>+ - Spaghettiness
spaghetti code often is all code that is not our own because it was generated by
minds that think differently than us.
+ - Organizational
~>Untested But Finished
~>+ - Give Me Estimates Now
estimate how much time and extra info is need to produce the desired estimate
boss doesn't buy it. Lower accuracy is suggested instead. Funny thing is however
inaccurate the estimate is said to be, it turns into a deadline.
~>If It Is Working Dont Change
~>Design For The Sake Of Design
+ - Over Use Of Patterns
Developers, having seen the light regarding the usefulness of patterns, try to
use them wherever they can, regardless of whether the pattern is appropriate.
The resulting code tends to be full of factories that only ever return a single
thing, that thing being a proxy to a delegate that wraps a class that has a
method that has the three lines of code you actually want to execute.
+ - tools
~>argouml
eclipse plug-ins
~>pattern box
includes 16 design patterns of the Gang of Four (GoF).
~>Design Pattern Toolkit
create patterns and generates applications from patterns
resources
http://en.wikipedia.org/wiki/Pattern_theory
~>go4expert.com > Forums > Showthread ? ...
~>Design Patterns http://www.vincehuston.org/dp/
~>Design Patterns (exciton)
~>Design Class Diagrams
~>Unlike components, does not provide reuse