Software design patterns – GOF

Classification of 23 design patterns (design pattern) of software, second “GOF” (Gang of Four).

In practice

The idea here is to show what they are and how to qualify the design patterns, This in itself can be very useful to solve most issues of public tender, see all:

To change the State of a class, the developer hopes that one or more classes of graphical interface to be modified. However, the developer does not do you think it would be interesting to create a tight coupling between these classes. What behavioral design pattern is best suited to resolve this situation?
( ) Composite
( ) Adapter
( ) Observer
( ) Abstract Factory
( ) Decorator

Maybe the question seems to require deeper knowledge, but note that if you only knew the classification, I could hit it with all conviction. The detail is in the section that asks for the “behavioral design pattern”, and there is only one alternative that fits, the Observer pattern. Issue resolved, easily!

In theory

The rhythm method is this:



Note that the default Adapter is only applied for both classes as for objects, reason why the table presents 24 ratings (and not 23).

Rote learning

Decorate may not be the best way to learn, but with so much to study, This tip can save you time “H”. An easy way to decorate these patterns is through mnemonics. On the blog of Rogério Araújo have a creative way, When you decorate just two sentences and you can make a good rank, Like this:

Creational Patterns (5)

A factory Abstract Constructs a prototype only!

Translation: A factory (Factory Method) Abstract (Abstract Factory) Constructs (Builder) a prototype (Prototype) only (Singleton).

Structural Patterns (7)

The bridge adapted Right composed of decorations on facade for weight fly If "aproxymar"!

Translation: The bridge (Bridge) adapted (Adapter) is composed (Composite) decors (Decorator) on the façade (Façade) for the flyweight (Flyweight) If "aproxymar" (Proxy).

Behavioral Patterns (11)

Learning who are the patterns of creation and the structural, the remainder are standards behavioral.

Concepts

(going beyond)

1

Adapter

(Structural)

Convert the interface of a class into another interface, expected by customers, allowing classes with incompatible interfaces work together, What, otherwise, It would be impossible.

2

Façade

(Structural)

Offer a single interface to higher level for a set of interfaces in a subsystem. IE, introduces an interface for various features of an API (collection classes) simple and easy to use.

3

Composite

(Structural)

Allow the treatment of individual objects and compositions of these objects evenly.

4

Bridge

(Structural)

Disengage (separate) an abstraction of your implementation so that both can vary independently.

5

Singleton

(Creation)

Ensure a class only has one instance and provide a global point of access to it.

6

Observer

(Behavioral)

Define a one-to-many dependency between objects so that when an object change of State, its dependents are notified and updated automatically.

7

Mediator

(Behavioral)

Define an object that encapsulates how a set of objects interact.

8

Proxy

(Structural)

Provide a replacement or point through which an object can control access to other. It is also known as surrogate.

9

Chain of Responsibility

(Behavioral)

Compose objects to, through her, delegate a request to an object to serve. This avoids the coupling between the sender of a request and your recipient, giving opportunity for more than one object handle the request.

10

Flyweight

(Structural)

Use sharing to support efficiently large volumes of complex objects (fine granularity).

11

Builder

(Creation)

Separate the construction of a complex object of your representation so that the same construction process can create different representations.

12

Factory Method

(Creation)

Define an interface for creating an object, but let subclasses decide which class to instantiate. Lets defer instantiation to subclasses.

13

Abstract Factory

(Creation)

Provide interface for creating families of related or dependent objects without specifying their concrete classes.

14

Prototype

(Creation)

Specify the types to create using an instance as prototype and create new objects by copying this prototype.

15

Memento

(Behavioral)

Store the internal state of an object so it can be restored later state your (Undo).

16

Template Method

(Behavioral)

Define the skeleton of an algorithm in an operation, leaving some steps be filled by subclasses. Allows its subclasses redefine certain steps of an algorithm without changing your structure.

17

State

(Behavioral)

Allow an object change your behavior as your internal state change.

18

Strategy

(Behavioral)

Define a family of algorithms, wrap each and make them interchangeable.

19

Command

(Behavioral)

Wrap request as object, for customers to parameterize different requests.

20

Interpreter, New

(Behavioral)

Given a language, define a representation for your grammar by means of an interpreter.

21

Decorator

(Structural)

Attach additional responsibilities to an object dynamically.

22

Iterator, New

(Behavioral)

Provide a way to access elements of an aggregate object sequentially without exposing its internal representation.

23

Visitor, New Time,

(Behavioral)

Represent an operation to perform on the elements of an object structure. Allows you to define a new operation without changing the classes of the elements in which you operate.

 

Source

Rogério Araújo – Life, IT and Contests

Total hits: 4782

Leave a reply

The your email address will not be published. Required fields are marked with *