Show Menu

SOLID for Unity Cheat Sheet by

A bunch of notes taken from Unite Austin 2017 - S.O.L.I.D. Unity
programming     solid     unity     unity3d     game-development

SOLID Principles

(S) SRP
Single Respon­sab­ility Principle
(O) OCP
Open Closed Principle
(L) LSP
Liskov's Substi­tution Principle
(I) ISP
Interface Segreg­ation Principle
(D) DIP
Dependency Inversion Principle

Intere­sting quotes

Keep everything (non­-pr­ogr­ammers) designer friendly when needed.
If your code is too tough to test, it probably means that's not SOLID.
 

1. Dependency Inversion Principle

Using classes with shared logic but different featur­es...
Use poly­mor­phism instead of hard refere­nces, through interfaces or abstract classes.
In Unity Editor
Use Abstract classes or Scriptable Objects if you want something in the inspector (since interfaces aren't suppor­ted).

2. Interface Segreg­ation Principle

Large interfaces are time expens­ive
Break them into small, focused ones. Use only one member or member purpose per interface.
Keep in mind that one class can implement many interf­aces.
In Unity Editor
The Inspector doesn't support interf­aces, but you can use them for internal methods or third party logic.
 

3. Single Respon­sab­ility Principle

That 1% error prone classes with 99% of the total game logic...
Split the game logic into small classes with simple code.
One class does only one thing and has only one reason to failur­e.
In Unity
Prefer tiny compon­ents.

4. Open/C­losed Principle

New features broke old ones
Classes open for extension, but close for modifi­cat­ion.
Use abstracts to extends features and define how it'll works.

5. Liskov's Substu­tition Principle

Exte­nding the classes broke them
If two different types have the same base type, they should both works for all members that use the base type.
Trust the type as the base type.

Download the SOLID for Unity Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/gekko_solid-for-unity.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Regular Expressions Cheat Sheet
          Script Inspector 3 - Windows Keyboard Shortcuts
          Script Inspector 3 - OS X Keyboard Shortcuts