Content deleted Content added
Tidy up my language a little |
m →Pitfalls: add missing period |
||
Line 13:
== Pitfalls ==
When writing an object pool, the programmer has to be careful to make sure the state of the objects returned to the pool is reset back to a sensible state for the next use of the object. Often if this is not observed, the object will be in some state that was unexpected by the client program and that will cause the client program to fail. Usually, the pool is responsible for resetting the objects, not the clients. Object pools full of objects with dangerously stale state are sometimes called object [[cesspit|cesspools]].
The presence of stale state is not always an issue; it becomes dangerous when the presence of stale state causes the object to behave differently. For example, an object that represents authentication details may break if the "successfully authenticated" flag is not reset before it is passed out, since it will indicate that a user is correctly authenticated (possibly as someone else) when they haven't yet attempted to authenticate. However, it will work just fine if you fail to reset the identity of the last authentication server used, since this is only used for debugging.
|