0% found this document useful (0 votes)
28 views

Class-Creation Patterns: Object-Creational Patterns

Creational patterns are design patterns that deal with object creation mechanisms. There are two main categories: class-creation patterns that use inheritance for object creation, and object-creation patterns that use delegation. Some specific creational patterns are the abstract factory, builder, factory method, object pool, prototype, and singleton patterns. The abstract factory creates families of related objects, builder separates construction from representation, factory method creates derived object instances, object pool avoids expensive resource acquisition/release, prototype provides a fully initialized instance to copy, and singleton restricts instantiation to one object.

Uploaded by

Esha Maryam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Class-Creation Patterns: Object-Creational Patterns

Creational patterns are design patterns that deal with object creation mechanisms. There are two main categories: class-creation patterns that use inheritance for object creation, and object-creation patterns that use delegation. Some specific creational patterns are the abstract factory, builder, factory method, object pool, prototype, and singleton patterns. The abstract factory creates families of related objects, builder separates construction from representation, factory method creates derived object instances, object pool avoids expensive resource acquisition/release, prototype provides a fully initialized instance to copy, and singleton restricts instantiation to one object.

Uploaded by

Esha Maryam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Creational patterns:

These design patterns are about class instantiation. Creational ordered


into two parts
 Class-creation patterns:
They are use inheritance effectively in the instantiation process.
 Object-creational patterns:
They are use delegation effectively to get the job done.
Creational patterns are:
 Abstract Factory
Creates an instance of several families of classes:
Example :
If there is a pharmacist.and you’re a customer.you ask the pharmacist
about the medicine of fever. Depend on the requirement it will try to
select the “Normal fever” factory and “High fever” factory. In this
situation the “Normal fever” factory return the appropriate medicine.
 Builder
Separates object construction from its representation
Example:
Two person decided to eat burger. One orders for a cheese burger but
second person not want eat cheese burger. Also there are many different
people present in the outlet who are ordering different types of burgers.
There they notice that burger making involves different processes, like
toasting the bread, creating patty for burger, making sauces and then
everything is put together. In case of programming this is where the
Builder pattern comes into picture.
 Factory Method
Creates an instance of several derived classes
Example:
Gourmet products Company. gourmet prompted the a number of product .it
making the country the biggest exporter of soft drink . As we know gourmet
produces various types of products but here we talk about ice cream
production. A client orders huge quantity of Ice Cream of various flavors from
Ice Cream factory. Ice Cream factory first produces Ice Cream in regular flavour
then it adds various flavors such as strawberry, pineapple, orange, mango,
chocolate, etc. to the Ice cream as per client order.According to the Factory
Method design pattern the functionality of making Ice cream is same for
different types of Ice creams but the ingredients and flavors are different.

 Object Pool:
Avoid expensive acquisition and release of resources by recycling
objects that are no longer in use
Example:
You have a test for job For the preparation of test you need books. You
will borrow books from the library, and after the test you will return those
books to the library.Library uses those books to serve other people. Here,
the books are the objects. The books are getting reused. Instead of
buying the books we are trying to get books from the library. After the
books are returned, the library representative will reuse those books. The
library representative will serve many people.
 Prototype
A fully initialized instance to be copied or cloned.
Example:
Company creates a new product. Later they decided to create a new
product pro. It is a good idea to build everything from scratch or just
reiterate the existing design of product and reuse it? As you see by reuse
existing objects we are saving resources and time.he Prototype Design
Pattern is the same approach in software engineering.
 Singleton
A class of which only a single instance can exist
Example:
A head of a school,he is one incharge. He is responsible for important
decisions and requests are directed to him because of responsibility.

You might also like