SOLID Design Patterns

5 min. read

S.O.L.I.D. is an acronym for five principles of software design that aim to create maintainable, scalable, and flexible code.

What is S.O.L.I.D

S.O.L.I.D Principles are a set of guidelines for software design, which stands for the following principles:

  1. Single Responsibility Principle (SRP)
  2. Open/Closed Principle (OCP)
  3. Liskov Substitution Principle (LSP)
  4. Interface Segregation Principle (ISP)
  5. Dependency Inversion Principle (DIP)

These principles can help improve the design of video game systems, from a software engineering point of view, making them more maintainable, scalable, and flexible.

Single Responsibility Principle (SRP)

Each class or component in a game should have a single, well-defined purpose and should not be responsible for multiple unrelated tasks.

For example, a class that handles player movement should not also be responsible for managing the game’s inventory system.

Open/Closed Principle (OCP)

A class or component should be open for extension but closed for modification.

This means that the class or component should be designed in a way that allows it to be easily extended or modified without needing to change its existing code.

For example, a game engine could be designed to be easily extended with new features, such as new graphics or audio capabilities, without needing to modify the core engine code.

Liskov Substitution Principle (LSP)

Objects in a game should be able to be replaced with instances of their subtypes without breaking the game.

This means that subclasses should be able to be used interchangeably with their parent classes without causing errors or unintended behavior.

For example, a game could have different types of enemies that all inherit from a base enemy class, and these enemies could be used interchangeably without causing any issues.

Interface Segregation Principle (ISP)

A game should use many small, specific interfaces rather than a few large, general interfaces.

Each interface should be designed to provide a specific set of functionality, rather than trying to provide everything a class may need.

For example, a game could have separate interfaces for rendering graphics, playing audio, and handling input, rather than trying to combine all of these functions into one interface.

Dependency Inversion Principle (DIP)

This principle states that high-level modules (such as game mechanics or AI systems) should not depend on low-level modules (such as input or rendering), but rather both should depend on abstractions.

This means that the game design should be modular and loosely-coupled, allowing for easier maintenance and flexibility.

For example, the game mechanics should not depend on the specific input method (such as keyboard or controller), but rather should be abstracted so that it can be used with any input method. This allows for easier maintenance and the ability to change or update the input method without affecting the game mechanics.

References

SOLID Principles for Programming and Software Design

S.O.L.I.D Design Patterns - Unity - Single Responsibility Principle

S.O.L.I.D Design Patterns - Unity - Single Responsibility Principle

Becoming a better developer by using the SOLID design principles by Katerina Trajchevska

[Design Patterns(https://www.youtube.com/watch?v=vNHpsC5ng_E&list=PLF206E906175C7E07)

Book - Head First Design Patterns

Command Pattern

State Machine

https://www.youtube.com/watch?v=gWDIBNnMufM

https://www.youtube.com/watch?v=Zc9VBoLekRU&list=PLMFsNLMNG6hH93u_VtMRi2ZbnJLRHOlbd

https://www.youtube.com/watch?v=8f_3x79PEZQ&list=PLLVN-JIMb0-bLWv1SjVAE4FkCFhivoh0t

Switch Statements

https://www.youtube.com/watch?v=Uix9D-J2vQQ

Design Patterns by Jason Weimann:
https://www.youtube.com/watch?v=Yy7Dt2usGy0&list=PLB5_EOMkLx_VOmnIytx37lFMiajPHppmj

https://www.youtube.com/watch?v=jLLAtxPNaC0

https://www.youtube.com/watch?v=MGEx35FjBuo

https://www.youtube.com/watch?v=UoNumkMTx-U&t=10s

https://www.youtube.com/watch?v=voz6S7ryWC0&t=965s

https://www.youtube.com/watch?v=E0Al0-sOO_c

https://www.youtube.com/watch?v=N12L5D78MAA

https://www.youtube.com/watch?v=Yy7Dt2usGy0&t=11s

https://www.youtube.com/watch?v=Yy7Dt2usGy0&list=PLB5_EOMkLx_VOmnIytx37lFMiajPHppmj

https://www.youtube.com/watch?v=MmYT8Zp6hbQ

https://www.youtube.com/watch?v=aRr-3Oqcs6w

https://www.youtube.com/watch?v=FGVkio4bnPQ

https://www.youtube.com/watch?v=Eyr7_l5NMds&list=PLB5_EOMkLx_WjcjrsGUXq9wpTib3NCuqg

https://www.youtube.com/watch?v=aklWUpJB1uQ

https://www.youtube.com/watch?v=F9ZSVmBJ4Kw

https://www.youtube.com/watch?v=fGshe3ILKnA&t=2s