Today i read wikipedia articles about visitor pattern and factory pattern...
Factory pattern is useful when u don't know the type of object that you are invoking..
You separate the logic of identifying the object type and invoking the desired method on that object type in factory class.
Basically term factory method means any method that creates objects. Whenever u wish to invoke the object, u create the factory class object and pass the information to this class which figures out and invoke appropriate object.
Visitor pattern:
Suppose there are four components in the system and all of them have common method like print or run or act... so instead of doing a implementation of common method in each of the subclass, a new interface is defined which declare common method for each component. A new class which extend to this interface implements the component specific functionality in class code. This way we separate the code of common method from sub classes.
Aspect oriented programming:
The piece of code on wiki gives a wonderful insight into this. Suppose u have bank transaction code. Here a method transfer money from one account to another. For sake of security and system services like logging and database transaction, a lot of checks will be introduced in the code. This is bad because in future if logging functionality changes or security changes then transaction code will have to be changed. This leads to cross cutting concerns. cross cutting means the logging module is cutting across other module so it creates problems. To avoid this aspectJ should be used. In this all the cross cutting code is specified in a separate file as aspect. This file defined the join point and point cuts which helps in separating code.
Spring framework:
Powerful framework with lot of features. Yet to understand it's role in j2ee applications fully.
SJ
very fine..
ReplyDelete