Skip to content

massimilianogaio/DesignPatterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repository aims to be a practical Unity3D application of the concepts expressed in the book "Design Patterns: Elements of Reusable Object-Oriented Software". The repository is an open to improvements exercise and is not intended to be exhaustive. Further patterns will be implemented in the future. Each pattern is implemented in a different Unity scene with a demo example.

Patterns implemented

  • Abstract Factory Pattern (Creational);
  • Factory Method Pattern (Creational);
  • Singleton Pattern (Creational);
  • Command Pattern (Behavioral);
  • Observer Pattern (Behavioral);
  • State Pattern (Behavioral);
  • Strategy Pattern (Behavioral)

Other Implementations

  • Composition over inheritance.

Abstract Factory Pattern

Pattern Goal

Provide an interface for creating families of related or dependent objects without their concrete classes.

Structure

abstractFactoryUML drawio

Demo Scene

AbstractFactoryDemo.mp4

Factory Method Pattern

Pattern Goal

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Structure

See Composition over Inheritance Structure section.

Singleton

Pattern Goal

Ensure a class only has one instance, and provide a global point of access to it.

Structure

See Command Pattern Structure section.

Command Pattern

Pattern Goal

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

Structure

command drawio

Demo Scene

CommandDemo.mp4

Observer Pattern

Pattern Goal

Define a one-to-many dependency between objects so that when one object state, all its dependents are notified and updated automatically.

Structure

obs drawio

Demo Scene

ObserverDemo.mp4

State Pattern

Pattern Goal

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.

Structure

state drawio

Demo Scene

StateDemo.mp4

Strategy Pattern

Pattern Goal

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Structure

strat

Demo Scene

StrategyDemo.mp4

Composition over Inheritance

Pattern Goal

Building flexible and maintainable software by favoring the assembly of smaller, specialized components over rigidly inheriting behavior from complex parent classes.

Structure

oc (1) drawio

Demo Scene

ObjectCompositionDemo.mp4

Third-party assets

About

Experiment with the use of Design Patterns in Unity3d.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages