Showing posts with label Design. Show all posts
Showing posts with label Design. Show all posts

Tuesday, 15 May 2007

Self Evaluation: Design pattern.....

Well it’s been an epic journey; it was whole new world to me. Exploring Design pattern and AntiPatterns were a best part of my educational life.

This blog is aimed to express my experience during this particular module.

I have learnt quite a number of things through out this module. I have outlined them into different titles and expanded it accordingly.

Design patterns

Throughout this module we have been introduced to design pattern. It was a new subject to me. I was familiar with java prior to design pattern. Upon the introduction to different design patterns my perception towards java programming has changed completely.

I have to mention about the GOF books and their ground breaking work on design pattern. The realization of the design pattern and its applicability on modern software development is indeed very much appreciated.

Apart from it, knowing about Adapter, strategy and decorator pattern were a blessing. Now I think twice before programming. I think about applying design pattern in programming rather then jumping on to code.

So it helped me a lot in terms of getting good program done with ease.

AntiPatterns

Fairly new term in the world of computing but without AntiPatterns the design is not completed. It is the natural counterpart of design pattern. AntiPatterns are getting popular because of its usability.

Blogging

To be honest I have very much liked blogging. Since the beginning of the classes I have been doing my blogging on regular basis. I have also liked the interactions between fellow class mates. Overall, I enjoyed the freedom of expressing my thoughts and opinions of learning design pattern.

Now in near future I would like to study design pattern further and explore the secret of all these patterns .

Tuesday, 13 March 2007

Explanation and Criticism of GoF's Patterns. Exploring patterns in C++ !!


Today we have looked deep in to design patterns. We have been introduced to famous GOF design patterns.

In a nutshell we have discussed about

Design patter in general
Importance and uses of design patterns
Types of design patterns
The famous GOF pattern and its preserving techniques


In my blog, I will be looking at two major tasks as we have been asked to by Dr. SRI.

1. Explain GoF (Gang of four) patterns in general and criticism of GoF pattern preserving technique.

2. Identify a design pattern example other than the ones listed in handouts

Let’s look at the GoF design pattern in general.

The GoF design patterns are in the middle of these levels of abstraction

“A design pattern names, abstracts, and identifies key aspects of a common design structure that makes it useful for creating a reusable object-oriented design.” [1]

The GoF design patterns are “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.”

Riehle and Zullighoven in “Understanding and Using Patterns in Software Development” mentions three types of software patterns

Conceptual Pattern

Pattern whose form is described by means of terms and concepts from the application domain

Design Pattern


Pattern whose form is described by means of software design constructs, such as objects, classes, inheritance and aggregation

Programming Pattern (Programming Idiom)

Pattern whose form is described by means of programming language constructs

According to task no 1 I have gone through Abstract factory and understood the concept of preserving technique. I have identified all the elements below and included criticism of GoF pattern at the end.


Pattern Name and Classification


A good, concise name for the pattern and the pattern's type

Intent
Short statement about what the pattern does

Also Known As
Other names for the pattern

Motivation
A scenario that illustrates where the pattern would be useful

Applicability
Situations where the pattern can be used

Structure
A graphical representation of the pattern

Participants
The classes and objects participating in the pattern

Collaborations
How to do the participants interact to carry out their

Consequences
What are the pros and cons of using the pattern?

Implementation
Hints and techniques for implementing the pattern

Criticism
There are criticisms about the whole concept of pattern. There are both pessimistic and optimistic view on GoF’s preserving techniques some of the issues I have noticed are listed below which are collected from Salingaros’ paper

· Criticism of GOF Design Patterns catalogue-feel and lack of connective rules applies equally well to Alexander's architecture patterns books.


· Design is tremendously hard work, and patterns do not provide an algorithm or make the hard work go away.

· Alexander sorts his patterns in order of decreasing scale, since decisions on the largest scale have to be made first; does GOF do this?

Identify a design pattern example other than the ones listed in handouts

For task number two I have gone through lots of research papers and came across lots of interesting patterns. One of the pattern which I would like know further is a patterns which have been developed for C++ program. According to the paper the abstract of this pattern is as follows

“Sequential control flow forms the backbone of any procedural program. Just as common function, data, and structure in a C++ program can be factored out using functions, classes, and templates, common control flow schemas can also be named and abstracted. One such recurring schema, or programming cliché, is the embracing or bracketing of a sequence by a pair of actions, such as resource acquisition and release operations executed around the actual resource usage code.” [2]

Name
EXECUTE-AROUND OBJECT

Problem
How do you abstract the execution of a pair of actions that surround a sequence of statements, or a single action that follows a sequence?

Solution
Provide a helper class for declaring a local object before the sequence. Its constructor is provided with any arguments necessary to perform the before action, and any that must be remembered for the destructor to perform the after action.

Name
EXECUTE-AROUND PROXY

Problem
How can you apply EXECUTE-AROUND OBJECT conveniently for individual calls on an object?

Solution
Provide a PROXY that forwards function calls to the target object, with each call wrapped by an EXECUTE-AROUNDOBJECT.



Name
EXECUTE-AROUND POINTER

Problem

How do you define an EXECUTE-AROUND PROXY when the actions performed on a target object are the same for all functions?

Solution
Define a SMART POINTER whose operator-> returns a temporary SMART POINTER. The temporary's operator-> performs the before action and its destructor performs the after action.

Name
EXECUTE-AROUND FUNCTION

Problem

How do you safely group and execute a sequence of statements that must be enclosed by a pair of actions, or followed by a single action?

Solution
Provide a function or object that holds the sequence of statements and pass it to another function for execution. The called function also executes the before and after actions as necessary.

References:




[1]Design Patterns: Elements of Reusable Object-Oriented Software By Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides




[2]http://www.two-sdg.demon.co.uk/curbralan/papers/europlop/ExecutingAroundSequences.pdf