In a software project where you need to ensure that only one instance of a database connection manager is used throughout the application, which design pattern would you employ?

  • Decorator
  • Factory Method
  • Observer
  • Singleton
The correct design pattern for ensuring a single instance of a class is the Singleton pattern. This pattern restricts the instantiation of a class to one object and provides a global point of access to that instance. It's commonly used for scenarios like managing database connections to maintain consistency across the application.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *