Inheritance, Composition, & Data Effic

12 flashcardsby Nijelous
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Inheritance
Paradigm of OOP, the traditional way this is extended.
Children and Parents
2
Problems with Inheritance
Diamond of Death: Two subclasses of a main class, and an object that could take from either.

Difficult to change classes after multiple levels of inheritance

Can have wasted data if we completely ignore a layer of a subclass
3
Composition
Extending objects by adding extra classes onto the objects they're attached to.

Provided via components in Unity, where the update method for all of these is fired together.

Each component can access their parent object easily.
4
Problems with Composition
Two components could be far apart in memory, even on different lines, causing cache misses
5
ECS
Entity Component System
Allows us to organise data so it's in cache when we want it, leading to further efficiency.
6
True ECS
Entities are integers, and the software has a series of containers holding components.

Accessing n element of the container is a component for the nth entity.

Components are stored as data, functions are separated

Components are placed in contiguous order, in an order that makes sense for how they'll be accessed, using different data types to store some components
7
Freelist
A list of deactivated objects that can be reused so new objects don't need to be made, leading to a faster runtime.

If we need an object of a type, check the freelist. If it's there, take it from the list and set the details accordingly, otherwise allocate a new object.
8
Singleton
Ensure a class only has one instance, and provide a global point of access to it
9
Prototype
A type of extension which gives an object a clone method, making an identical copy in a very quick way.

E.g. Prefabs
10
Factory
Hides as much of the cloning process as possible, helping make instantiation simple.

Gives an object that matches a set of given parameters.
11
Service classes
Classes that can queue up requests, and work through them a fixed amount per frame.
12
Toolbox
A class/struct that holds a lot of different services that many objects use. Aka Handlers.
Study all 12 cards for free