Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Singletons

  • 15-06-2007 5:19pm
    #1
    Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭


    So I've been reading up a bit on people's criticisms of the use of Singletons in C++, and how it breaks the object oriented paradigm due to being just a fancy wrapper for global variables, which is fair enough. The other complaints also make sense such as a lack of clear ownership, introducing dependencies in the code that use them, and no way of handling dangling Singleton pointers.

    However in all the rants I've read about Singletons, nobody suggests a viable alternative. We use them fairly extensively here for being a central point to manage various features and resources, and they work pretty well for what they do. Granted, if we ever wanted to remove Singletons and change to some other pattern, refactoring would be a nightmare given the amount of code in our codebase that is dependent on them - although I'd imagine this would be a problem no matter what patterns we used. But otherwise, their use is clearly defined and they are constructed and destructed in known places and nowhere else.

    There are bound to be some "singletons are the spawn of the devil" people lurking here; I'd be interested in hearing exactly why they feel that way and what alternatives they suggest.


Comments

  • Registered Users, Registered Users 2 Posts: 995 ✭✭✭cousin_borat


    Interesting post. Generally with Java I stick to Design Patterns that avoid the use of Singleton variables.

    However when programming in PL/SQL it is very difficult to avoid using them. I'll get around sometime to looking for sources which don't. However the much of the internal Oracle internal code uses singletons.


Advertisement