Submitted by Martyn Butterworth on Wed, 12/17/2014 - 17:08
The factory method pattern is used when a class needs to instantiate a derivation of another class, but does not know which one. The factory method allows a derived class to make this decision.
Product is the interface for the type of object that the factory creates.Creator is the interface that defines the Factory Method. Clients will need to subclass Creator to make a particular ConcreteProduct. The abstract method FactoryMethod() is implemented in the concrete class and it knows the rules to enable it to create and return the appropriate concrete product.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:58
The bridge pattern is similar to the strategy pattern, where you define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. The bridge pattern decouples an abstraction from its implementation so that the two can vary independently.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:48
This is a common pattern that can be used by many other patterns. The GoF states that the intention of the adapter pattern is to:
Convert the interface of a class into another interface that the clients expect. Adapter lets classes work together that could not otherwise because of incompatible interfaces.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:46
The Façade pattern enables us to use a complex system more easily, either to use just a subset of the system or to use the system in a particular way.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:44
These are some of the more important design principles and strategies to consider during your OOP software design and development activities.
Objects are things with well defined responsibilities
At a conceptual level an object is a set of responsibilities (at a specification level it is a set of methods, at an implementation level an object is code and data). The responsibilities define the behaviour of the object. This focuses on what objects are supposed to do and its public interface, rather than the actual implementation.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:35
The decorator pattern is used to attach additional responsibilities to an object dynamically. The object provides the basic functionality, but you need a variety of additional functionality to be added at run-time. For example you want to add a header and or footer to an invoice print, and the header or footer can also vary. The power of the Decorator pattern is that the instantiation of the chain of objects is completely decoupled from the client objects that use the decorated ConcreteComponent.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 16:28
A lot of patterns work together very well to form compound patterns. Shown is a UML class diagram that implements various design patterns to form a compound pattern. Here are some notes describing how and why this design was arrived at.
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 14:59
So how exactly do composition and inheritance compare? Here are several points of comparison:
Submitted by Martyn Butterworth on Wed, 12/17/2014 - 14:07
A principle of good software design is to separate things that change from those that do not. Commonality variability analysis is a way of achieving this.
Commonality variability analysis helps us to focus on interfaces and stop us from looking at implementation too soon. It leads us to hide the implementation by focussing on the abstractions first. It encourages us to look at the high and low level aspects of design, but separately. It helps us to design by contract, thus creating an architecture that is more testable.
Submitted by Martyn Butterworth on Tue, 12/16/2014 - 15:31
The fragile base class problem is caused by the use of implementation inheritance. It occurs when a derived class extends a base class, using some of the methods or attributes in the base class.