I generally post a message in my blog after I’ve already done it, but this time I’m trying something a bit different and posting the idea as a mechanism to draw it out.
In my jCommon project I have Object Pooling support already, but it’s explicitly limited to the pooling itself. While developing Galaxies Beyond I’m finding there are some things that would be useful to support in the pooling that would simplify usability in application. Currently you simply get() for an object from the pool and it will create the object if it doesn’t exist and hasn’t reached the maximum number of objects allowed for that pool or return an object that is in the pool. This works fine in most scenarios, but for more advanced pooling I need to cleanup after an item has been returned to the pool and perhaps re-init certain things when they are actually pulled from the pool.
…okay, after I got done typing all that it dawned on me that I might have already written this before. Sure enough, ObjectPool in jCommon already has support for all of this. Perhaps this should be changed to “How sad is it when you write so much code you end up re-inventing the same ideas over and over again?”, but what’s particularly sad is I’ve done this on various occasions. In fact, I wrote similar functionality for ObjectPooling in jME before I remembered that I had already created the object pooling support in jCommon. What makes it even worse is that the code I wrote was better the first time.
I’m 28 years old and if my memory is this bad now, I can’t imagine what I’ll be like at 80. In my defense I will state that I write thousands of lines of code a week, so there is a LOT that can be forgotten. 🙂