Thursday 3 May 2007

Anti-Patterns

In layman term, anti-patterns are pitfalls. Solutions which are needed to be created again and again to overcome a problem.

I would be going into detail of anti-patterns in my course work as to how anti-patterns have evolved and how they have benefited the software industry.


Goodday.

Decorator Design Pattern

A decorator pattern allows additional responsibilities added to the object without subclassing. Subclassing means a class that inherits some properties from the superclass and decorator pattern is alternative to subclassing.[1]

Why is decorator design pattern alternative to subclassing or inheritance?
  1. Because subclassing adds behaviour during compilation and decorator pattern adds new responsibility or behaviour during run time.
  2. It's done without modifying the interface of the original object.
  3. Decorator pattern allows to add or remove functionality as and when required. [2]

Advantages of using Decorator Design Pattern over Subclassing are:

  1. Because adding functionalities are done during run time therefore it gives more flexibility than just straight inheritance.
  2. It saves time and simplifies coding because you need not write coding from the start and just code the behaviour into the object.
  3. Unnessary functionalites need not be added. It can be done upon request.
  4. In any case when you do not have access to the source code but you need to add the functionalities to the product, then you can wrap this object into the decorator object to provide the missing or new functionalities.[3]

---------------------------------------------------------------------------------------------------

REFERENCE

[1], [2] & [3] http://en.wikipedia.org/wiki/Decorator_pattern

Strategy Design Pattern

I missed this lecture as I was attending hospital appoinment. Information which I have gathered from lecturer's notes and a bit of self stuyding did however allow me to outline my understanding as below:-

Strategy Pattern is basically used to achieve different behaviours. In simple terms, an object and its behaviour are separated into two different classes. Each behaviour encapsulated into its own class and it's called Strategy.[1]

What is the advantage of using Strategy Pattern?

  1. It is much simpler to keep track of different behaviours required from an object as separate classes will be created.
  2. Any amendements need to be made on the behaviour of an object can be achieved quickly as you will keep track of those classes.
  3. In some cases, you will come across of several objects that are similar but different in behaviour. Therefore, using Strategy Pattern becomes very useful.
  4. It is much easier to make an extension on the object with new behaviours without recoding the application.
  5. Using this patterns also means eliminating the need of many conditional statements.

Besides the advantages, I think one must know also know the different strategies available in order to reduce creating of unnessary startegies. If the knowledge is lacking than one might end up creating too many classes which can create problems of maintaining them.

Is Strategy Design Pattern the best to be used?

Well, I think that every pattern has it own uniqueness and is designed to address a specific issue.

---------------------------------------------------------------------------------------------------

Reference - Web Link

[1] http://www.exciton.cs.rice.edu/JavaResources/DesignPatterns/StrategyPattern.htm

Tuesday 3 April 2007

Lecture 06.03.07 Part B - Critiquing Course Work

There are 5 tasks given in the course work and only 4 tasks are to be completed. Each Task is woth 25%. Those task are as follows:

Task 1 - Designing with Patterns
Task 2 - Coding with Patterns
Task 3 - Patterns and Software Development
Task 4 - Critiquing Patterns
Task 5 - Patterns Blog

We are suppose to critize each Task.

TASK 1
In order to complete this task, we have to know UML diagrams. This task imposes force to have good understanding of the fundamental concepts used in object-oriented programming, mainly class diagrams, use case diagrams and sequence diagrams. The 25% marks are allocated according to the understanding and evaluating those patterns.

TASK 2
In this section we are to explore a particular programming language and coding. In order to achieve a working prototype a good knowledge of object oriented programmng language is essiential.

TASK 3
In this task we are exposed to incomplete Pattern designed by someone else and its an oppurtunity toinvestigate and provide a solution to the problem. In order to be in a position to give a solution it is essiential to have suffiecient understanding of the 23 design pattern by GOF.

TASK 4
By critiquing, we are actually given a platform to understand the rationale of a particular topic in more depth, which gives us a chance to explore further and contribute a easier way of putting forward an idea or concept.

TASK 5
In this task we asked to post at least 12 blogs and the 8 best blogs will be choosen for marking pupose. All this blogs created are related to the subject we are learning. Why are we asked do so? Simply, because creating blogs gives an oppurtunity to confidently post their understanding and bring out doubts. Therefore, this learning curve gives one to have an open mind to new ideas and accepting the rejections positively. This is essiential for any evolving area.

The course work is designed for one to understand in overall. Having basic knowledge of object oriented programming language and to further understand the design patterns one will have to further understand the principles of each every pattern as they all have uniqueness of its own. Besides that, confidence, critizing and evaluation is the essential bit of the course work.



Monday 2 April 2007

Lecture 06.03.07 - Definition of Abstract Factory

Definition of Abstract Factory Pattern

A software design pattern, the Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. In normal usage, the client software would create a concrete implementation of the abstract factory and then use the generic interfaces to create the concrete objects that are part of the theme. The client does not know (nor care) about which concrete objects it gets from each of these internal factories since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from its general usage.[1]

OR

In short it is defined as, providing an interface for creating families of related or dpendent objects without specifying their concrete classes. [2]


Below, I am going to illustrate an example which was used by my lecturer:-

In the STUDENT class, there is data and methods. The data is student names which comprises methods such as enrolment, add, create, edit, delete and print.
Its the same with the class named COURSE, there is data and methods. The data will be types of courses available and the methods will be registration, add, create , edit, delete and print.

Now, abstract class will create a common interface which will perform all the functions such as add, create, edit, delete and print in new abstract class named may be FUNCTION class. This proves that the concrete class is isolated and its easy as the concrete class produces different product family configuration.

---------------------------------------------------------------------------------------------------
Reference Link

[1] http://en.wikipedia.org/wiki/Abstract_factory

[2] http://www.c-sharpcorner.com/uploadfile/mosessaur/abstractfactoryadonet202152006053643am/abstractfactoryadonet2.aspx?articleid=4468e7cc-57cl-4738-8e83-a8db48fd1d9f



Lecture 27.02.07 (B) - Critiquing one of the GOF Design Pattern, Adapter Pattern

In this lecture we all were introduced to the 23 GoF Catalogue Patterns. Brief knowledge was obtained and I am taking the ADAPTER PATTERN a little futher by critizing the 11 elements in this catalog pattern.

Name
Adapter pattern makes one interface match to another. It acts as a plug in.

Intent
Converts the interface of a class into another interface a cliets expects.

Also Known Uses
Its also known as Wrapper.

Motivation
This section elaborates about how existing and unrelated classes come into one application and from there on how there are made compatiable to work on a same interface. It also emphasises on a problematic area and from there on it vastly builds into addressing those issues by introducing different approaches. Besides that, having a diagrammatic viw in adapter pattern illusrates the fullfilling of responsibility of each class.

Applicability
In this section it clearly states where and when it should be used to adopt the interface.

Structure
This element overlaps with the MOTIVATION element because this class adapter uses multiple inheritance concept to adpt one interface to another and this information can be incorporated into MOTIVATION element as mentioned in the begining.

Participants
The advantage here ist that it clearly devides the domain interface use by the client, works together with objects conforming the target interface, defines the interface need ofadpating, and adapting the target interface. In short it can briefly demontrates and identify the obtainability of relationship.

Collaborations
In this section, the association here emphasises on the UML diagrams.

Consequenses
Information such as the do's and don'ts, characteristics of the adapter pattern, rules of the adapter pattern. In short, this element provides all the principles of adapter pattern when come to implementing them.

Implementation
Here the implementation is applied on C++ to display hierarchical structure. Three(3) types of implementation approach is used and they are abstract approach, usage of delegate objects and parameterized adapters. All this three approaches are used together which is much easier to be introduced rather than implementing them separately using TREE display.

Sample Code
In my opinion, sample code element need not be given great emphasise as it can be illustrated in any language. Creating the source code can be time consuming and lenghty process.

Known Uses
This pattern has been used on the following systems: InterViews 2.6 defines an Interactor abstract class and a Graphic abstract class. Both have graphical appearances but they have different interfaces and implementations (they share no common parent) [1]

----------------------------------------------------------------------------------------------------------------
Reference Link:http://www.vico.org/pages/PatronsDisseny/Pattern%20Adapter%20Object/index.html [1]









Thursday 15 March 2007

Lecture - 27.02.07 Research of a New Pattern

Just a quick re-cap to What is Pattern?
Basically, Pattern is a solution to problems which keeps occuring over and over again within a particular context.

I am enclosing one of the PATTERNS released by YAHOO and this Pattern is used by Web Designers, find the details of the Pattern below:

NAME : EXPAND TRANSITION

INVENTED BY : YAHOO

KNOWN USES : YAHOO BETA MAPS


PROBLEM
Designer needs to show the detail of an object in its context or reveal a previously collapsed object.

IT IS USED WHEN:

- This pattern is used to manage large contents and modules.
- Shrink feature to create a way to manage real estate on the screen.
- As part of rollover system (with Shrink) to emphasize the currently hovered on object.( e.g; photos in a photo album).
- Need to see more detail (Y! Local maps).
- The need to interact with the content that was previously represented in a thumbnail version.
- Wanting to see the detail of an item in a list (e.g., movie details in a movie list).
- Making content available for editing.

SOLUTION

It increase the size of an object while animating the in-between sizes (tweening). This communicates similar meaning, as does the brighten transition and good rule of thumb is complete an expand in less than 0.5 seconds.

RATIONALE
There are 2 logics behind this pattern designed and those are:

- To expand visually more eye-catching than a brighten, especially when combined with the move transition.

- Be careful to not overuse expand. For example, in a photo application, if you provide a rollover to expand photos from thumbnail to a larger size the transitions will become annoying as the user will see them back-to-back. Either remove the transition altogether or make it extremely fast.

REFERENCE LINK
http://developer.yahoo.com/ypatterns/pattern.php?pattern=expand