Template Method Quickly

I have always wondered a very easy bare minimum way of remembering and explaining design patterns. For someone who has ever written a test case using XUnit or has ever worked with servlets, it is so easy to explain about Template Method pattern. Let us quickly go through the checkllist of template method pattern

1. Define a new abstract base class to host the skeleton of an algorithm.
2. Move the definition of all standard steps to this new base class.
3. Define a placeholder or “hook” method in the base class for each step that requires many different implementations.
4. Invoke the hook method(s) from the template method.
5. Each of the existing classes declares an “is-a” relationship to the new abstract base class.
6. The only details that is in the sub classes will be the implementation details peculiar to each derived class.

This is exactly what happens when we extend a TestCase to create XUnit test cases as there is a common set of steps to be followed setup stuff for the test case, run the test case and then cleanup, so the template method will look something like this

public void execute() {
setUp();
runTest();
tearDown();
}

My Article on AgileAlliance

Please visit the link below to read about my article on how agile practices makes a distributed team get closer to the onsite team and how it encourages one team feeling

http://www.agilealliance.org/show/1924

It’s time for your database to perform

The number one reason for applications not performing the way they can is the database misuse. May be the following few simple steps can go a long way making our J2EE applications perform and scale well

1. Use databases for only that data which you need to persist and not for everything.

2. Model and design your database to third normal form in general but do the de-normalization of the database to cater to specific functional needs

3. Create indexes where necessary but lets not overdo it as it has its own impact while inserting stuff as database might take up lot of time updating them.

4. Learn about the specific datatypes our database offers and use them to maximum as some might perform better then the others
Read the rest of this entry »