However, there are some classes that should have only one instance.

Sometimes they are factories, which you can use to create the other objects in the system.

If more than one factory exist, clerical control over the created objects may be compromised.

From : Agile software development : PPP

What clerical control Uncle Bob talks about, that would be compromised?

  • 2
    Eg, your created objects need to have unique and monotonically increasing Id numbers. This is pretty simple to do with a single factory instance but a PITA with multiple instances.
    – MetaFight
    Jan 13, 2016 at 2:40
  • 1
    This is an odd comment from "Uncle Bob". He is a near-rabid advocate of TDD, and there is no greater impediment to TDD than singletons. Seems odd that he's in anyway arguing for their use, therefore.
    – David Arno
    Jan 13, 2016 at 10:24
  • What's "clerical control"? Jan 13, 2016 at 13:34

1 Answer 1


Whatever kind of "clerical control" your application needs. If you don't know what that means, chances are high your application won't need such control ;-)

For example, this could mean to keep account on the whole set of objects of a certain type which were created during the lifetime of your application, for the purpose of reiterating over them at a later point in time, or for searching for an existing object. Morevover, this could be used to create something like an "object cache" for objects where the creation is costly, like objects from a database. So the accounting will allow you to check if an object must really be newly created, or if you can reuse a former instance from the cache.

Other possible scenarios are the example of MetaFight's comment, easier ID number generation, or just counting the number of created objects of a certain type for statistical purposes.

I guess once you got the idea, you can extend that list easily by yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.