0% found this document useful (0 votes)
61 views10 pages

Object Pool Design Pattern

The object pool pattern is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand. A client of the pool will request an object from the pool and perform operations on the returned object.

Uploaded by

Talha Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views10 pages

Object Pool Design Pattern

The object pool pattern is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand. A client of the pool will request an object from the pool and perform operations on the returned object.

Uploaded by

Talha Ashraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

OBJECT POOL

DESIGN
PATTERN PRESENTED TO
Prof. Dr. Shazia Arshad

PRESENTED BY
Muhammad Naeem 2019-CS-232
Talha Ashraf 2019-CS-239
Definition
Object pool pattern is a software creational
design pattern that is used in situations where the
cost of initializing a class instance is very high.
Basically, an Object pool is a container that
contains some amount of objects. So, when an
object is taken from the pool, it is not available in
the pool until it is put back.
Principle to whom it satisfies?
The Object Pool Design Pattern satisfies the
Single Responsibility Principle (SRP) of SOLID.
The SRP states that a class should have only one reason
to change. In the context of the Object Pool pattern,
the pool class is responsible for managing a collection
of objects and providing them to clients when
requested. The pool class has the responsibility of
creating and destroying objects, managing the state of
the pool, and handling concurrency issues.
When to use?
When we have work to allocate or deallocate many
objects
Also, when we know that we have a limited number
of objects that will be in memory at the same time.
Layman
Example
UML Diagram
Client: This is the class that uses an object of the
PooledObject type.
ReuseablePool: The PooledObject class is the type that
is expensive or slow to instantiate, or that has limited
availability, so is to be held in the object pool.
ObjectPool: The Pool class is the most important class
in the object pool design pattern. ObjectPool maintains
a list of available objects and a collection of objects
that have already been requested from the pool.
Code
Example
Advantages
It offers a significant performance boost.
It manages the connections and provides a way
to reuse and share them.
Object pool pattern is used when the rate of
initializing an instance of the class is high.
Thanks :)

You might also like