CS FundamentalsHardProduct-company placement

A service reuses expensive database connections from a pool instead of opening one per request. One request leaves a connection inside an open transaction with a session variable set. Which pattern is involved, and what rule does this break?

  1. A. Flyweight; flyweights must never hold any intrinsic state of their own
  2. B. Object Pool; objects must be reset to a clean state when returned
  3. C. Singleton; the application may only ever hold one connection at a time
  4. D. Prototype; each connection must be cloned from a template before use

Correct answer: B. Object Pool; objects must be reset to a clean state when returned

An object pool hands out reusable instances, so leftover state (open transactions, session settings) leaks to the next borrower. Pools must reset or validate objects on return or checkout, and close broken ones.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic