ArticleslgStudy

computer science

Creational pattern

Creational pattern is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Creational pattern rather than just read about it. In short: A creational pattern is a software design pattern for creating objects in a manner suitable to a particular situation. As object creation that is otherwise available (i.e. via the programming language) can sometimes result in design limitations, a custom mechanism for creation can provide for better design.

Creational pattern — main illustration
Creational pattern — illustration

Key takeaways

  • Creational pattern belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Creational pattern to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Creational pattern from memory before moving on to harder problems.

Reference excerpt

A creational pattern is a software design pattern for creating objects in a manner suitable to a particular situation. As object creation that is otherwise available (i.e. via the programming language) can sometimes result in design limitations, a custom mechanism for creation can provide for better design. A creational pattern aims to separate a system from how its objects are created, composed, and represented. They increase the system's flexibility in terms of the what, who, how, and when of object creation. A creational pattern encapsulates two main aspects. One is encapsulating knowledge about which concrete classes the system uses. Another is hiding how instances of these concrete classes are created and combined. Creational design patterns are categorized into object-creational patterns and class-creational patterns. Object-creational patterns defer part of its object creation to another object, while class-creational patterns defer its object creation to subclasses.

Usage As modern software engineering depends more on object composition than class inheritance, emphasis shifts away from hard-coding behaviors toward defining a smaller set of basic behaviors that can be composed into more complex ones. Hard-coding behaviors are inflexible because they require overriding or re-implementing the whole thing in order to change parts of the design. Additionally, hard-coding does not promote reuse and makes it difficult to keep track of errors. For these reasons, creational patterns are more useful than hard-coding behaviors. Creational patterns make design become more flexible. They provide different ways to remove explicit references in the concrete classes from the code that needs to instantiate them. In other words, they create independency for objects and classes. Consider applying creational patterns when:

A system should be independent of how its objects and products are created. A set of related objects is designed to be used together. Hiding the implementations of a class library or product, revealing only their interfaces. Constructing different representation of independent complex objects. A class wants its subclass to implement the object it creates. The class instantiations are specified at run-time. There must be a single instance and client can access this instance at all times. Instance should be extensible without being modified.

Structure

Below is a simple class diagram that most creational patterns have in common. Note that different creational patterns require additional and different participated classes. Participants:

Creator: Declares object interface. Returns object. ConcreteCreator: Implements object's interface.

Examples Some examples of creational design patterns include:

Abstract factory pattern a class requests the objects it requires from a factory object instead of creating the objects directly. Factory method pattern centralize creation of an object of a specific type choosing one of several implementations. Builder pattern separate the construction of a complex object from its representation so that the same construction process can create different representations. Dependency injection pattern a class accepts the objects it requires from an injector instead of creating the objects directly Lazy initialization pattern tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed. Object pool pattern avoid expensive acquisition and release of resources by recycling objects that are no longer in use. Prototype pattern used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Singleton pattern restrict instantiation of a class to one object.

See also Constructor Behavioral pattern Concurrency pattern Structural pattern

References

Worked examples

Example 1 — a first encounter with Creational pattern

Start with the simplest possible case. Write down what Creational pattern claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Creational pattern before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Creational pattern ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Creational pattern

In research
Creational pattern appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Creational pattern in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Creational pattern is common in secondary-school and first-year university syllabi. It links to neighbouring topics Software design patterns, so understanding it makes those chapters shorter.
In everyday life
Look for Creational pattern outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Creational pattern” →

How to study Creational pattern in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Creational pattern means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Creational pattern out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Creational pattern in simple terms?

A creational pattern is a software design pattern for creating objects in a manner suitable to a particular situation. As object creation that is otherwise available (i.e. via the programming language) can sometimes result in design limitations, a custom mechanism for creation can provide for bette…

Why does Creational pattern matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Creational pattern?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Creational pattern.

Tags

  • Software design patterns

Keep exploring