Friday, January 8, 2010

How To Make A Friendship Anklet



Each time you start developing a new application as software engineers we turn to face the same or similar problems have been addressed in previous developments. Not only that, we are facing in many cases the same problems others have had to solve.

Making all prior knowledge is useful and saves time in the design and development of new applications. This is something well known and therefore the patterns have emerged design, and guidelines to follow under certain conditions supported by prior knowledge.

In construction, the architect Christopher Alexander proposed the learning and use of a series of patterns for the construction of buildings higher quality. In his words, "each pattern describes a problem that occurs many times in our environment, as well as the solution to it, so that we can use this solution a million times later without having to think of it another time. "

The patterns Christopher Alexander and his colleagues identified are an attempt to formalize and capture a practical way generations of architectural knowledge. The patterns are not abstract principles that require their rediscovery for a successful implementation, nor are specific to a particular situation or cultural, are somewhere in between. A pattern defines a possible solution to correct a design problem within a given context, describing the invariant qualities of all solutions.

Taking the idea of \u200b\u200bpattern the computer world, a design pattern is a solution to a design problem that should possess the following characteristics:
  • must be checked its effectiveness solving similar problems in the past.
  • should be reusable, which means that it is applicable to different design problems in different circumstances. The

design patterns were a great success from the book Design Patterns written by the group Gang of Four (GoF, which were collected 23 common design patterns. These defined patterns by the GoF are divided into 3 groups creational patterns, structural and behavioral .

creational patterns: They try to solve the problems that can arise in the creation of objects.
  • Factory Abstract: Provides an interface for creating families of objects or dependent on each other, without specifying their concrete classes.
  • Factory Method: Define an interface for creating an object, but let subclasses decide which class to instantiate. Allows a class to its subclasses delegate object creation.
  • Builder: Separate the construction of a complex object from its representation so that the same construction process can create different representations. Prototype
  • : Specifies the types of objects to create using a prototypical instance, and create new objects by copying this prototype.
  • Singleton: Ensure a class has only one instance and provides a global point of access to it.

structural patterns: They try to facilitate the design identifying simple ways to establish relationships between entities.
  • Adapter: Convert the interface of a class into another which is what customers expect. Allow cooperating classes that otherwise could not to have incompatible interfaces.
  • Bridge: Decouple an abstraction from its implementation so that the two can vary independently. Composite
  • : Combine objects in tree structures to represent part-whole hierarchies. Allows customers to uniformly treat the individual objects and compounds. Decorator
  • : Dynamically adds new responsibilities to an object, providing a flexible alternative to inheritance to extend the functionality.
  • Facade: Provides a unified interface for a set of interfaces in a subsystem. Defines a high-level interface that makes the subsystem easier to use.
  • Flyweight: Use sharing to allow a large number of fine-grained objects efficiently.
  • Proxy: Provide a surrogate or representative of another object to control access to it.

Behavioral Patterns: Identify common communication patterns between objects and try to increase the flexibility of this communication.
  • Chain of Responsibility: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to respond to the petition. Create a string with the receiving objects and passes the request through the chain until it is treated by an object.
  • Command: Encapsulate a request on an object, allowing you parameterize clients with different requests, queue or keep track of requests and to undo the operations.
  • Interpreter: Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. Iterator
  • : Provides a way to sequentially access the elements of an aggregate object without exposing its internal representation.
  • Mediator: Define an object that encapsulates how they interact a set of objects. Promotes loose coupling by keeping objects from referring to each other explicitly, and lets you vary their interaction independently. Memento
  • : Represents and externalize an object's internal state without violating encapsulation, so that it can return to that status later.
  • Observer: Define a dependency on one-to-many relationship between objects, so that when an object changes state is notified and updated automatically every object.
  • State: Allow an object to alter its behavior when its internal state changes. Appear to change the object's class.
  • Strategy: Define a family of algorithms, encapsulate each one of them and make them interchangeable. Lets the algorithm vary independently from clients that use it.
  • Template Method: Define an operation in the skeleton of an algorithm, deferring some of its subclasses steps. Lets subclasses redefine certain steps of the algorithm without changing its structure.
  • Visitor: Represent an operation on elements of an object structure. Allows you to define a new operation without changing the classes of the elements on which it operates.

Over time, have arisen new patterns, especially in the field of enterprise Java development . Some of them are:
  • Front Controller Model View Controller (MVC) ended
  • View
  • Session Facade - Facade Session
  • Locator Service -
  • Object Locator Service value - Value Object object
  • Data Transfer - Data Transfer Object (DTO)
  • Officer of Company - Bussiness Delegate
  • Data Access Object - Data Access Object (DAO)
  • Dependency Injection (DI) - Inversion of Control (IoC)
  • Open Session In View (osiva)
  • ThreadLocal Session

In this article we have tried to give an introduction to design patterns . In future articles I will try to develop some of the patterns herein analyzed its usefulness, strengths and weaknesses.

References:
Design Patterns (Erich Gamma, Richard Helm, Ralph Johnson, Vlissides Hohn)
Professional Java Server Programming J2EE, 1.3 Edition (Subrahmanyam Allamaraju, Cedric Beust, Marc Wilcox, Sameer Tyagi Rod Johnson, Gary Watson, Alan Williamson, John Davies, Ramesh Nagappa, Andy Longshaw, PG Sarang, Tyler Jewell, Alex Toussaint)
Design Patterns in Wikipedia
Introduction to design patterns by Manuel Lagos Torres
ingenierosoftware.com Design Patterns in

0 comments:

Post a Comment