Fundamentals 9 min read

Master Software Design Patterns: Creational, Structural & Behavioral Basics

This article introduces the core concepts of software design patterns, explaining the three main categories—creational, structural, and behavioral—through concise definitions, real‑world analogies, and code examples to help developers build more reusable and robust systems.

System Architect Go
System Architect Go
System Architect Go
Master Software Design Patterns: Creational, Structural & Behavioral Basics

Overview

Design patterns capture proven solutions to recurring software‑design problems. Although they originated in object‑oriented languages such as Java, the concepts are language‑agnostic and help developers write reusable, maintainable code and construct robust system architectures.

Creational Patterns

These patterns abstract the process of object creation, allowing a system to be independent of how its objects are instantiated, composed, and represented.

Singleton – Guarantees a class has exactly one instance and provides a global access point. Typical implementation involves a private constructor and a static accessor method.

Factory – Defines an interface for creating an object but lets subclasses decide which class to instantiate. Variants include:

Simple/Static Factory – a single function that returns different concrete types.

Factory Method – subclasses override a method to create objects.

Abstract Factory – provides an interface for creating families of related objects without specifying concrete classes.

Builder – Separates the construction of a complex object from its representation, allowing the same construction process to create different representations. Example in JavaScript‑like syntax:

new KFC('套餐')
  .add('主食')
  .add('小吃')
  .add('饮料')
  .build();

Prototype – Creates new objects by cloning an existing prototype instance, useful when object creation is expensive.

Creational patterns illustration
Creational patterns illustration

Structural Patterns

Structural patterns describe how classes and objects can be combined to form larger structures while keeping the system flexible.

Adapter – Converts the interface of a class into another interface clients expect, enabling incompatible components to work together without modifying their source code.

Bridge – Decouples an abstraction from its implementation so that the two can vary independently. Typically expressed as separate class hierarchies for abstraction and implementation linked by a composition relationship.

Composite – Treats individual objects and compositions of objects uniformly. Useful for representing part‑whole hierarchies such as file systems or UI component trees.

Decorator – Adds responsibilities to objects dynamically by wrapping them in decorator classes, preserving the original object's interface.

Facade – Provides a simplified interface to a complex subsystem, reducing coupling between client code and internal components.

Flyweight – Shares common intrinsic state among many objects to reduce memory consumption, while extrinsic state is supplied by the client.

Proxy – Supplies a surrogate or placeholder object that controls access to a real subject, enabling lazy loading, access control, or remote invocation.

Structural patterns illustration
Structural patterns illustration

Behavioral Patterns

Behavioral patterns focus on communication between objects, defining how responsibilities are assigned and how algorithms vary.

Chain of Responsibility – Passes a request along a chain of handlers until one handles it, avoiding coupling the sender to a specific receiver.

Command – Encapsulates a request as an object, separating the invoker from the executor and allowing operations such as undo/redo and queuing.

Iterator – Provides a uniform way to traverse elements of a collection without exposing its underlying representation.

Mediator – Centralizes complex communications between related objects in a mediator object, reducing direct dependencies.

Memento – Captures an object's internal state without violating encapsulation, enabling later restoration (e.g., undo functionality).

Observer – Implements a publish‑subscribe mechanism where observers are automatically notified of subject state changes.

Visitor – Allows adding new operations to existing object structures without modifying the structures themselves.

Strategy – Defines a family of interchangeable algorithms, encapsulating each one so that the client can select the appropriate strategy at runtime.

State – Enables an object to alter its behavior when its internal state changes, effectively turning state‑dependent logic into separate state classes.

Template Method – Defines the skeleton of an algorithm in a base class while allowing subclasses to override specific steps.

Behavioral patterns illustration
Behavioral patterns illustration

References

https://github.com/kamranahmedse/design-patterns-for-humans

https://juejin.im/post/5cb534386fb9a0685727e1eb

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Design PatternsSoftware ArchitectureBehavioralCreationalStructuralObject-Oriented
System Architect Go
Written by

System Architect Go

Programming, architecture, application development, message queues, middleware, databases, containerization, big data, image processing, machine learning, AI, personal growth.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.