Quote:Original post by BrianL
I totally agree with jpetrie. It is all about invariants and encapsulation.
Design patterns have very specific meanings. If something is called a factory, I would assume it always returns a newly created object. If something is called a pool, I assume is a resource optimization, etc.
Managers seem like a specialization of the facade pattern. They are 'glue' that presents a unified interface to other more complex systems. For example, a TextureManager may internally use a Pool and a Factory to create textures. It may support methods for making queries about the number of textures in memory, the amount of memory space they take, etc.
Yes, these could be done by iterating over all of the textures manually everywhere to calculate this info, but the manager could cache it (as an invariant) when textures and created/destroyed. This would be more efficient as well as more encapsulated.
You make an intersting claim however lets point a few things out:
1) Factory
a. Definition: Well defined while still abstract - A Factory is an object which encapsulates the details needed to create certain concrete objects. This may be realized through the Abstract Factory which only returns abstract pointers, or the Factory Method who's returned object is decided by the set parameters.
b. Scope: Has a limited scope in which it may be applied - If it does not return newly created objects then it is not a factory.
c. Application: Not all objects are Factories.
2) Pool
a. Definition: Well defined while still abstract - A variation of the Factory pattern that optimizes the allocation of memory by pooling resources for memory resuse inplace of constant allocation and deallocation of RAM.
b. Scope: Has a limited scope in which it may be applied - If it does not optimize the use or memory by restricting the occurance of memory allocation and deallocation then it is not a pool.
c. Application: Not all objects are Pools.
3) Facade
a. Definition: Well defined while still abstract and leaves out a lot of impelementation details in favor of a focus on the interface - An object that provides a simplified interface to a larger body of code.
b. Scope: Has a limited scope in which it may be applied - If it does not produce an interface which simplifies the complexity of a greater system, then it is not a facade.
c. Application: Not all objects are Facades
4) Manager
a. Definition: The epitome of ambiguity - Something which stores data and performs actions on it.
b. Scope: Anything and everything in software fits under the definition of manager.
c. Application: All objects are managers, all programs are managers.
The term manager is generally used under the following conditions:
1) The programmer does not fully understand their problem space
2) The programmer seeks an easy out to true design by lumping all Foo related things into one giant FooManager.
3) Do to the lack of a true design step, the programmer is unaware of other possible means for organizing data, methods, and responsibilities in a more thoroughly contrived manner.
4) Since everything is a manager, you might as well call it a manager.