Object-Oriented Design

5 min. read

Object-Oriented Design

What are objects

Each has:
Identity (identify the object)
Attributes (width, height, full, empty, etc…)
Behaviours (things they can do, move, jump, etc…)

When to create an object?
Can you put the word “The” in-front of the object?
The mug
The person
The bank

Classes describe what an object with be. Classes are the blueprints, like a house plan, it is not a house, but can be used to create a house.
The class comes first.

Classes has:
Name - the name of the class
Attributes - properties/members
Behaviours - methods/functions

Creating objects from classes is called instantiation

4 fundamental ideas in OOP (4 Pillars)

A - Abstraction
P - Polymorphism
I - Inheritance
E - Encapsulation

Have an idea but dont need an instance.

Surrounding something
Information Hiding
Should only make information visible that other classes require
Black boxing
Make functions public, not attributes
Reducing dependencies between classes

Create a new class from an existing class
Eg: person class and then a customer class… same as person class, but has customerNumber. CustomClass Inherits from PersonClass
Parent class - SuperClass
Child class - Subclass
C++ can do multiple inheritance
Saves time

Means “many forms”
Overrides the base methods

Analysis, Design and Development
Gather requirements
What does the app need to do?
What problems are we trying to solve?
Needs to be defined to clearly state: what the app could do versus what the app is going to do
Describe application
Describe how people will use the app
Use Cases and User Stories
Create mockup or prototype of the user interface, sometimes essential and other times it’s just a distractaction
Identify most important objects
Start of actual classes
Most important ideas, concepts, things and discard what’s irrelevant
Describe the interaction between those objects
Describe interaction between the classes, spaceship needs to explode when it hits a rocket.
The behaviours they have
When they interact with each other
What they do
And what order they do it in
Create a sequence diagram
Create Class diagram
Visual representation of the classes
This is not done once, but rather continually revisited


Defining Requirements
Core requirements (functional requirements)
What are the features and capabilities of the app
What does it need to do

Non-functional requirements
Help - What help or documentation needs to be provided?
Legal - Are there legal requirements?
Performance - Performance requirements Responsiveness? Who many people does the app need to support at the same time?
Support - Support requirements
Security -

So not the hundred different things it might do or could do, but at leastinitially what the app must do. Now requirements can be phrased very simply. You’ll often see requirements begin with the phrase system must or application must or program must, depending on which term you prefer.

Core Requirements
App MUST ….
Game MUST….

Should be able to search matches
Provide support

F - Functional Requirements
U - Usability Requirements
R - Reliability requirements
P - Performance requirements
S - Supportability requirements
Design - Eg: must be an iphone app
Implementation - Language, Design Patterns, Methodology
Interface - 3rd Party systems
Physical - Eg: PC requirements

UML (Unified Modeling Language)

Use Cases
Title - What is the goal?
Actor - who desires it?
Scenario - how is it accomplished?

Best Title:
Should have a verb
Register new member
Transfer funds

Actor: Anything with behaviour and has a goal they want to achieve with the app
Any entity thats acts on our system
Write as steps
Normal expected flow?

Extensions: Problems

Preconditions: what must be true before this use case

How long? One or 2 days for requirements and use cases?
Dont use ‘use case diagrams’

User Stories

DRY - Dont Repeat yourself
YAGNI - You Ain’t goin need it
Single Responsibility

Expert/Information Expert
Low Coupling or High Cohesion

MVC - Model, View and Controller

MVC in Unity
Model - Data
View - 3D and GUI - Display data modules
Controller - Updates the data modules

Applying these principles to Unity.
Create Components.
Data modules
App Controller