Monday 14 May 2007

Anti Patterns (blog 10)

Anti patterns! Different kinds of questions come in to our mind when we hear this word.
It was very interesting to hear the lecture on Anti patterns. I learnt a lot from patterns and anti patterns through out this unit. I was just looking on IBM and some other websites, trying to get more and more knowledge about anti patterns.
Our coursework Task4 in which we have to write about anti patterns will allow us to write in detail about anti patterns. I am going to write few lines on Anti patterns and want to express briefly what I understood about anti patterns.
An anti pattern I would is a pattern in which we produce a bad solution to solve a problem. When the wrong solution is produced at that time we don’t know that whether it is the right or wrong solution but when it is actually implemented than we realize that it was a wrong solution to solve that occurring problem. I think it is good in a way because it will allow us to learn from our mistakes so that we don’t do the same mistake in future.[1]
Anti patterns are not used only in software development it happens more often in our real life as well. I am going to explain more about it in my Task4 of the course work.

Reference:
[1]Anti patterns, learned from
http://c2.com/cgi/wiki?AntiPattern

Monday 7 May 2007

Strategy Pattern (blog 9)

I found this pattern very interesting as it gives the client to choose their requirment. Strategy pattern helps us in defining family of algorithms and of them can be encapsulated so that they can be interchangeable.
The aim behind the strategy pattern is to make things easier for the implementation and maintenance of methods. It is also possible to use strategy pattern in software design. S
Strategy pattern should be used when
1. you require different versions of algorithms
2. Suppose you have many different classes which are related to each other but they differ from each other in terms of their behaviour. In this case, strategy pattern helps you in configuring a class with one of serveral different behaviours..
Strategy pattern can help us in avoiding the usage of difficult data structures. [1]
Reference:
Raghvendra Singh, accessed 7th May, 2007

Sunday 6 May 2007

Decorator Pattern (blog 8)

The next pattern which i am going to discuss briefly is Decorator Pattern. Its a pattern which allows an elegant OOP technique to add some extra responsibilities or you can say functionalities to a specific object of a class. You can add functionalities to all the objects or even a single object of a entire class.
Decorator pattern is also know as Wrapper, is an object which has a interface similar to an object that it consist.
Decorator changes the way an object appears that is totally different from subclassing.
Drawback
The component which is enclosed with decorator is not the same. Tests of object types may fail in this case. And there is another point about this pattern which is not impressive is by using this pattern ! lots of small objects are created which is severe stress to the programmer when it comes to debugging some error.[1]
Reference:
C# Design Patterns: The Decorator Pattern

Tuesday 3 April 2007

Adapter Pattern (blog 7)

We had an interesting class regarding Adapter pattern. I found this pattern very interesting because it allows us to make classes work together with the help of their interfaces, the interface of the classes will make classes work together which are incompatible to interact with each other. Adapter patterns are also known as Wrapper.
This pattern should be used in solving issues such as when you want to replace a class but the interface doesn’t match OR without knowing the interfaces of the classes when we want to create a class that could be used with some other classes.


Adapter Pattern has two types.

1.Object Adapter Pattern
This type of pattern has a technique in order to adapt an interface to another which I think I have never seen in any other pattern. According to the client requirement the adapter inherits the interface. Object adapters authorize the client and the adaptee to be completely decoupled from each other. Just the adapter knows concerning both of them.
2.Class Adapters
Multiple inheritance is used by class adapter to accomplish their goals. Class adapters are useful in situations like where there are some existing class provides services and doesn’t require to use the interface.

Tuesday 27 March 2007

Research on new pattern: Datetime Design Pattern (blog 6)

Dr.Sri asked us to do some research on more patterns apart from the one we are studying in our unit. I was looking on the internet trying to find some new pattern and came across DateTime Design pattern
Datetime Design Pattern
Why
This design pattern is used to make human readable datetimes to be also formally read by the machine. The needs arises as a result of solving the practical need for human readable dates for hCalender (hCalendar is a simple, open, distributed calendaring, based on the Calendar standard).
Where & How it is used
Datetime design pattern is used in hCalendar is something like this:
Date Time
where foo is the name of the class which is being applied to this date/time, the title of the is an ISO 8601 date/time and "Date Time" is a friendly representation of the same date/time. [1]
Reference:
[1] Where Datetime deisng pattern is used
http://microformats.org/wiki/datetime-design-pattern

Thursday 22 March 2007

Comment on the Coursework (blog 5)

Well finally we got the coursework and thanks to Jane chandler who came to our college and gave us very valuable information about the coursework.
When I first looked at the coursework when it was handed to me and to all classmates I was scared that how I am going to do it because I have other course work to do as well, anyway when I came to know the submission date for this course work I was a bit relaxed after that.
The course work seems to be alright, doesn’t look very easy neither very hard but It is lengthy.

TASK1 (UML Designing)

If we talk about the task 1 which is based on UML designing in terms of Strategy, Decorator and Adaptor patterns. First of all what I think that it is not possible for anyone to complete this task unless you understand how UML diagrams are designed. If you know how to design UML diagrams than this Task is easy to attempt because we just have to come up with four UML diagrams and of course we need to design them by adapting the above three mentioned design patterns and apply them to the prototype of customer records.

TASK2 (Coding) & TASK3( Patterns and Software Development)

I am making my mind to do task 2 (coding) but still confused I might attempt task 3 which is a bit theoretical. Although there is much possibility of doing the coding task because I have been programming since more than two years but I haven’t done programming using patterns. Task 3 is not tough as well but I am thinking what tasks should I attempt.

TASK4 (Essay writing)

I think this is most difficult question in this course work in which we have to write an essay about anti patterns and write our point of view on anti patterns. This task could have been easy if there was no specific scenario given. Writing an essay of 600 words reminds me of my school days when I use to write essays on different topics but never got a chance to write an essay related to computing and it is really hard to get good marks when you are writing an essay. I am looking forward to do my level best to take this task as my 3rd task.

TASK5 (Blog)

I love blog because we just have to write whatever we understood from the lecture given in the class so there is not as such research involved in it. So I am happy to do the blog task. Basically in this task we just have to write what we learnt from our lecturer on each class. So we didn’t understand the lecture very well the other way we can do a bit research online about the topic which was taught in the class and then write it in our own words or do referencing.

Overall,Coding and the essay writing are the tasks in which we have to be very careful how are we using patterns and what are we writing about patterns, rest I think its straight forward.
Please give your comments

Wednesday 14 March 2007

Abstract Factory (Blog 4)

The next blog on which we were asked to understand and do research is Abstract factory. I have looked in to many websites, tried to get as much knowledge as I can and now I am going to write what I understood about Abstract factory..!
The Factory Pattern known as Abstract Factory is used to facilitate class instantiation. In the Abstract Factory pattern, a special class, called a factory, is created whose main aim is to create instances of a class.
The factory method pattern is like defining an agreement for the creation of a given type of classes
  • An abstract factory is an object creator.
  • It can produce different types of objects.
  • Each object that it produces is recognized by receiver of the object which is created only by the interface of that object, not by the object's real implementation.
  • Objects which are produced by abstract factory are related to each other or you can say they belong to a common family

Benefits

Abstract factory eliminates the need of classes to bind in to the code. The code deals with the interfaces, therefore it is possible that I can work with any class that implements an interface.
It also allows the subclasses to give an extended edition of an object because it is hard to create an object within the class but It is more easy to create an object in the client directly

Thursday 8 March 2007

Criticism on one the Patterns (Blog 3)

Singleton

Going through briefly on 23 patterns the one I liked and would like to share is Singleton pattern. The reason of choosing this pattern is that it is easy to understand and more explainable. After doing research on internet about this pattern according to my understanding the definition of single pattern is:

“The singleton design pattern is designed to limit instantiation of a class to one object”.

Singleton is most likely the most commonly used design pattern. The main aim of singleton pattern is to provide one instance for each class and a gateway where everyone can access in to it. There are many situations in which a singleton object is necessary: a GUI application must have a single mouse click, an active modem needs one and only one telephone line, an operating system can only have one window manager, and a PC is connected to a single keyboard.

CRITICISM

Intent
The main intention of a Singleton is to make sure to have only one instance of this class with a global point of access to it, thus avoiding the use of global variables and conflicts among them.

Motivation
Sometimes! Some classes should only have one instance, and be available from everywhere; here singleton pattern can be applied. So the instance which is created by a class will have global access and the constructor of the class blocks more than one instance to be produced.

Applicability
Singleton pattern can be used in this case when:

There should be only one instance of a class and can be accessed by many clients from a well known point. If some global object is a client of another one, the latter may not be destroyed until the former terminates. No distinction between individual and composed objects.

Structure
Structure of Singleton Pattern is in the form of a diagram in which the structure is described of how the class can be limited to one instance.

Collaboration
The thing I like about singleton is that and would like to share is that Clients get the right to access a Singleton instance only through the operation which is performed by Singleton's Instance.
Consequences
The Singleton pattern has several benefits:
1-Each instance is controlled properly in such a way that it limits the clients control on it depending how and when they try to access it.

2-Limits the size of name space. As we all know now that singleton pattern creates only one instance of a class therefore it also provides perfection over global variables.. It avoids polluting the name space with simultaneous access. There is a possibility that there could be a subclass of a Singleton class and It is very easy to configure a program with the help of an instance of the extended class.

Implementation
To implement a Singleton patter, class is created with a method which creates a new instance of the object if the object is not there. If an instance is already there it simply returns a reference to that object. To prevent the object to be instantiated in any other way, a private or protected constructor should be created.
Sample Code
Here is a sample of how singleton is used in programming.

public class Singleton
{
private static Singleton NEWINSTANCE = new Singleton();
private Singleton() {}
public static final Singleton getInstance()
{
return NEWINSTANCE;
}}


Known-Uses
In this section, the known uses of this pattern can be understood with the help looking in to examples.
Suppose if we are authorized to have only one license of a particular database, Singleton takes care that only one connection has been to the database to access records and suppose if we had more connections to the database then singleton can also adjust more than one connections. [1]

Related Patterns
Singleton pattern is mostly used with Abstract Factory, Builder, and Prototype. The Singleton is a bit similar to a Cache manager, but with one object.
Reference:
[1]Example of Singleton

Thursday 22 February 2007

FAQs on Software Patterns (Blog 2)

1- Software patterns! Never heared of it, What are these?

Ans: Solution of the problems that occur during the development life cycle of any software with in the context is called Software Patterns.

2- Do patterns support software engineering?

Ans: In terms of reusing the solution of a particular problem of software architecture is supported by patterns which help in the development of the software.

3- What is the use of patterns in software engineering?

Ans: Patters are solutions to a problem in a context. In order to make the software work efficiently in terms of performance and making the software in such a way that can be reused, it is therefore useful to use patterns while developing the software.


4- Is it worth using Patterns during software development?

Ans: Using patterns during the software development could in a very good result. The solution of problems is dealt in an efficient way so that time is not wasted! Getting experience from the problems faced earlier can help in reoccurring problems.

5- How patterns benefit the developers?

Ans: Generally if we talk about patterns even in real life pattern plays a vital role in any kind of problem which is occurring. It allows us to apply proper phenomena to solve the problem which we are facing while doing anything.

6-Is there any way that patterns give more than one solution to a problem?

I don’t think so that giving alternatives solution to the problem would be a good option. Its better not to mention more than one solution to the problem. Each solution should be linked to the situation in which it best applies accordingly.
Thanks for reading,Please comment.

Patterns (Blog 1)

After doing research on Patterns,I have come to the point that Patters are solutions to a problem in a context. In order to make the software work efficiently in terms of performance and making the software in such a way that can be reused, it is therefore useful to use patterns while developing the software.

The main aim of patterns within the software linked people is to build a body to help software developers to solve the problems which are occurring concurrently during the software development. Patterns help us in creating a gateway which can communicate insight and get experience from the problems and their solution
In more simple words I would say the pattern is a thing which occurs in the world and tells us the rule how to create that thing and where there is a need to create it.
I found a very good quote by Albert Einstein which is a single line only but explains every thing about patterns. I would like to share it with every one

"Example isn't another way to teach; it's the only way"

Example:

One of the simplest understandable real world examples of Pattern is a student who is giving an exam in college. The duration of the exam is one hour in which he/she has to attempt two questions out of three. Student knew the answer of the questions which were asked in the question paper but due to slow handwriting and understanding the questions couldn’t able to complete the two questions and wasted time. Therefore, he/she did attempt the exam but couldn’t finish it on time.
Problem: How to answer the questions on time?


Solution: Practice of writing fast before the exam should be done so that all the questions can be answered.
Understanding the questions instead of getting confused.

Context: Attempting exams properly within the time allocated in future so that the same problem doesn’t appear again.
Thanks for reading,Please comment.
Reference
Quote by Albert Einstein taken from URL