These are some BIG questions in a very small package. A Factory Method is described in the GoF (Gang of Four) book. The method takes some parameters and returns an interface (or abstract class). The idea is that depending on the data that is passed in, objects of different class types are returned, although they must all implement the interface (or inherit the abstract class). Light Weight Components: AWT is an example of heavy weight components - each AWT component is reliant on the underlying operating system for implementation. Swing is an example of lightweight components - each Swing component is made out of basic paint routines and events within Java and does not depend on the underlying operating system to specifically implement this component. A Decorator Class (GoF) will provide the same interface as the class that is being decorated, but it will usually add some enhancement. A decorator class usually does not inherit what it decorates, rather, it contains what it decorates. Functor is new to me, but I found a reference in the GoF book. Something about "objects that are functions". Apparently some guy named "Coplien" thought it up.
Joined: Dec 17, 1998
I have not heard of the use of functors in the Java arena. I had heard of it in the C++ arena, primarily for dispatching a callback to a member function. Typically, C++ callbacks require a static member function to be used as the static binding mechanism is required. You can of course dispatch a callback to a member function, a non-static member function, but this requires you write some tricky code which is your functor implementation. I conceptually view a functor as a function pointer that allows the developer the ability to dispatch a callback to a non-static member function. A functor is not a function pointer in reality though.
Joined: Jan 07, 1999
"Coplien" is Jim Coplien (http://student.vub.ac.be/~jcoplien/) From Http://www.astray.com/dabot/ (a clever and useful source of info). I asked it "What is a Functor", it replied: In category theory, a functor F is an operator on types. F is also considered to be a polymorphic operator on functions with the type F : (a -> b) -> (F a -> F b). Functors are a generalisation of the function "map". The type operator in this case takes a type T and returns type "list of T". The map function takes a function and applies it to each element of a list. (07 Feb 1995) Does this help?