Design Patterns: Effective Software Development

Introduction

Standards are an effective way to reuse project. Patterns are solutions to specific problems that occur recurrently in a given context that were identified from the collective experience of software developers. The main advantage of using standards is because it describes software abstractions, including:

  • Common vocabulary
  • Effective communication of complex principles, helps to document the software architecture
  • Capture the essential parts of a compact design

Design Patterns

However, the use of Design Patterns does not present an exact solution, and still do not solve all design problems. Importantly, Design Patterns is not exclusive to design object-oriented. With the reuse of something already done, we have the false idea that a standard is the solution complete a problem when, in fact, is a proposed solution, implemented in a specific scenario tested. Such a scenario is not always coincides with that which is building the solution. Thus, some caution is necessary: The use of standards in an uncontrolled manner can cause projects overloaded. Developers need time to understand the catalogs of relevant standards and need easy access to relevant books and need to be trained in the use of two standards.

Observer Design Pattern

The Observer pattern allows objects to dynamically register its dependencies other objects. A special object notifies all dependent objects when the objects that depend undergo state change. Allows you to upgrade a set of objects when a certain object undergoing change.

Observer Design Pattern Example

The Observer pattern has the following tasks: Allows objects to dynamically register its dependencies other objects. A special object notifies all dependent objects when the objects that depend undergo state change. Allows you to upgrade a set of objects when a certain object undergoing change.

Observer Design Pattern UML

The solution structure of classes is:

Observer Design Pattern Examples

Some examples of the Observer:

Design Patterns Standards

A brief description (Objective, uses and implementation UML) of the following design standards:

  • Proxy: In GoF:”Provide a surrogate or point through which an object can control access to each other” Client uses an intermediate class instead of the real subject, The Intermediate class supports the same interface as the real subject; Intermediate contains a reference to the real subject and passes calls, possibly adding information or data in the filtering process. The Proxy pattern is often used in distributed objects.
  • Flyweight: Gof said:”Using sharing to support large amounts of refined objects efficiently. Should be used” When the size of the set of objects is significantly lower that the amount of time they are used in the application; When the objects can be used in different contexts at the same time (always acting as an independent object) Where not to use: When the state of objects is not immutable (it takes pass the parameter as mutable state and this may be impractical if the state consists of multiple objects)When it is necessary to devise a complicated algorithm or something to separate the mutable immutable
  • Bridge: According to GoF:”Decouple an abstraction from its implementation so that the two can vary independently” Use as needed to avoid a permanent connection between the interface and implementation; When changes in implementation can not affect customers; When both abstractions such implementations need to be able to support extension through inheritance implementations when unknown objects are shared between the client
  • Factory Method: Allows a generic class (written to be reused) instantiate other classes without being dependent on those classes, that is, without explicit mention to do that. The generic class remains independent of the classes that instantiate by delegating to another object of the choice of which class to instantiate and only refers to the object thus created through a common interface. Allows you to create the desired objects using methods that return objects.

Builder Pattern Example

An application must construct objects Person and Company. For this, you need to read data from a database for each product. (Use Builder): To build a person’s need to obtain the name and identity. Only if both the person being read can be created to build a business you need to read the name and identity of the person and then build the controller. Show how an application could be implemented to undertake the above tasks.