I'm working on a project(web application) where I have a DataManager(IDALContract dalImplementation) class that does some stuff with the data after retrieving it from the database or before saving it in the database.

My question: Is there any reason why the IDALContract object I'm passing in to the constructor should/should not be a singleton?

  1. FooManager is a smell. Managers invariably suffer problems because a "Manager" is a catchall that pushes it towards having multiple responsibilities. I strongly encourage you to not go down that road towards God objects.
  2. Singletons are anti-patterns. Always. They force you to only ever have one object of a type, and no such thing exists. You're going to tell me that you will never, ever have more than one data access layer? You'll never need to access say, your database, a cache, or some NoSQL store at the same time? Are you really sure you want to limit your design that strongly?
  • Also, especialy bad for a web application where each request will be simultaniuously using the same DAL object – Ewan Jun 27 '15 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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