Monday 12 March 2007

Design Patterns and Gang of Four (GOF)

LECTURE 3 (20-01-2007) - BLOGG 3

DESIGN PATTERNS


I now have an introductory knowledge of design patterns. In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design.

GOF defined design patterns as “a design pattern names, abstracts and identifies the key aspects of a common design structure that make it useful for creating a reusable objects design. The design pattern identifies the participating classes and instances, there role and collaborations, and the distribution of responsibilities.” [GOF]


TASK 1: (20-10-2007)

Select ONE of GOF Design Patterns out of the 23 design patterns and criticize all its elements

Creational Pattern – Builder Pattern

One of the reason why I chose this pattern for criticism is the fact that this pattern explains that the constructor of a class is outside the class, whiles in java, the constructor is written within the same class. I find it rather a disturbing and conflicting statement.

After careful evaluation of this Pattern from the GOF: Design patterns- elements of reusable object oriented software. I am moved to appreciate the pattern concept.

The builder pattern separates the construction of a complex object from its representation so that the same construction process can create different representations. [GOF]

[GOF] Design patterns- elements of reusable object oriented software, GOF, (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides

If you are to a create a complex object independent of the parts that make up the object then, the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled and also the construction process must allow different representations for the object that is constructed.

The good consequences of builder pattern concepts are that it lets you vary a product's internal representation and also isolates code for construction and representation.

There is a need to catalogue each pattern created so it can be referred to and re-used. GOF created thirteen (13) elements of patterns under which each of the 23 GOF design patterns created is catalogue under.

Elements of patterns

Pattern name and classification
o Builder Pattern; this name uniquely identifies this pattern, this pattern is classified under creational patterns.

Intent
o The intention of this pattern is when complex objects are created, it seperates it’s construction from its representation so that the same construction process can be used to create more different representations.

o In my view I think Intent is a vital element and is necessary at all times when preserving patterns as it tells a user the intentions of the preserved pattern in the catalogue.

Also known as
o Just like humans can have other names, so patterns too.

o I critically think this element is not so necessary. There might be cases when a pattern will not have other known names.

Motivation
o This element presents a problem and the usefulness of the pattern to solve it in a given context.
o I critically think this element is important and must be documented whenever a pattern is been preserved.

Applicability
o This element highlights scenarios (context) areas in which the pattern might be applied to.
o I critically think this element is very important as it deals with the context area from which a problem is coming from.

Structure
o This element shows a pictorial image of the pattern suing class diagrams.
o I critically think this element in very important as a brings forward a comprehensive pictorial view of the pattern.

Participants
o This element shows all assembly parts. i.e. classes and objects used in the pattern.
o I critically think that this element is very vital as it shows all classes and objects and there functions and relationships.

Collaborations
o This element shows basically interaction of classes.
o I critically think that this element is vital as it will help developers to use the patten irrespective of there programming background.

Ø Consequences
o This element shows the resulting effects both positive and negative when this pattern is applied in system design.
o I critically think that this element is very vital as
§ It lets u vary a products internal representation
§ It isolates code for construction and representation
§ It gives you finer control over the construction process.


Implementation
o This element explains how the pattern is implemented, In builder pattern it states that its constructs it products in step by step fashion.
o I critically think that this element is very vital as it aids greatly in implementing the pattern.

Sample code
o In some cases it is not necessary to put a sample code. Can only be necessary to programmers who are working iwith same language in which the code is written.
o I critically think that this can be omitted if necessary, but in cases were there are multiply versions of the same code written in different languages, it will become useful.

Known uses
o Thie element is like a reference, for users to check out areas where the pattern have been implemented before.
o I critically think this element must be included as it shows confirmation that the pattern is actually a proven tested on.

Related Patterns
o This element shows other patterns that are directly linked, or have some relationship to the pattern
o I critically think it not necessary to include this element only in extreme cases were there are close ties between a pattern and the pattern under review.

No comments: