   I have kind of a random idea
  One of the things that always comes up in game development is management of different types of objects, right? So I was whipping up a small little framework for an Asteroids-clone game (based on the Enginuity series), and found myself writing a bunch of duplicate code for managing sets of objects. So what I came up with was this:#ifndef LISTED_H#define LISTED_H#include <set>template<class _Derived>class Listed /* Crappy name, I know */{public:typedef std::set<_Derived*> ObjectList;typedef typename ObjectList::iterator iterator;Listed(){AddToList();}~Listed(){RemoveFromList();}void AddToList(){objects.insert(DerivedPtr());}void RemoveFromList(){objects.erase(DerivedPtr());}iterator begin(){return objects.begin();}iterator end(){return objects.end();}size_t size(){return objects.size();}private:static ObjectList objects;};template<class _Derived>typename Listed<_Derived>::ObjectList Listed<_Derived>::objects;#endif//LISTED_HKind of naive looking, right off the bat, I know, but it allowed me to do a bunch of cool stuff when combined with Interfaces. Like, the rendering task basically just called begin() and end() on the Listed<IRenderable> class, and then called Render() on each pointer returned.So far, it's been darn useful. What I want is for you guys to pick it apart, tell me why it's a horrible idea (which I have an uneasy feeling it is).   
  I know it seems like a good idea. Unfortunately, it conflates two concepts--existence and membership--which usually should not be conflated. The fact that a Foo exists does not necessarily mean that it has anything in common with all the other Foos that exist, or that something you want to do to MOST Foos you would always want to do to ALL Foos. A good example of existence without membership is the Prototype Pattern; basically, you may want to have an object which does nothing except get cloned into other objects, so that those other objects can have stuff done to them. Another good example is simple encapsulation; for now you can assume that when you want to open all the doors in your world, you can just iterate through your Doors list and open 'em, right? except: what happens when, three months down the line, you decide you want to support multiple worlds, and that doors in different worlds are independent of each other? Then you have to painstakingly unstitch all the operations that operate on All Doors. Worse yet, you have to figure out some way of getting a list of Doors in the World, something that will likely be quite painful given that you didn't do it in the first place.Bottom line: bad idea, which seems like a good idea at the time.   