SlideShare a Scribd company logo
Game Architecture :
wanna play a good game ?
[ Wijanarko Sukma . Department of Informatics ]
Taken from the Presentation slide of :
Jeff Ward
Associate Programmer
Bethesda Game Studios
[ Wijanarko Sukma . Department of Informatics ]
How can architecture help us :
Concurrency
Maintainability
Code Ownership
Usability
Performance
Stability
Architecture
[ Wijanarko Sukma . Department of Informatics ]
Bad architecture creates problems
Produces side effects
Hard to follow
Hard to debug
Hard to reuse
Spend more time finding a way around the
architecture than fixing the problem
OMG HAX!
Bad Architecture
[ Wijanarko Sukma . Department of Informatics ]
Stability
Reusability
Cohesion
Orthogonally
Why do Architect
(Design)
[ Wijanarko Sukma . Department of Informatics ]
A well architected system is easy to
understand, change, debug, and reuse.
[ Wijanarko Sukma . Department of Informatics ]
Principles of OOP (Object Oriented Programming)
Design Patterns
Best Practices
Know this first
[ Wijanarko Sukma . Department of Informatics ]
Example Engine
[ Wijanarko Sukma . Department of Informatics ]
Logic
State
Data File Loader
Output Input
Basics
Encapsulation
Inheritance
Polymorphism
Principles of good design
Reduced coupling
Increased reliability
Increased reusability
orthogonality
OOP Principles
[ Wijanarko Sukma . Department of Informatics ]
“Encapsulation is a programming mechanism that
binds together code and the data it manipulates, and
that keeps both safe from outside interference and
misuse.” – Schildt
Encapsulation is not just data hiding!
Implies each object should be a cohesive whole
Encapsulation
[ Wijanarko Sukma . Department of Informatics ]
Accessing elements between instances
It’s a convenience feature, not a good idea
“Always Design for Concurrency” – Tip 41 in The
Pragmatic Programmer
Even if you don’t need it, a cleaner architecture results.
Instance Encapsulation
[ Wijanarko Sukma . Department of Informatics ]
Creature Creature
Key overused concept of OOP
“ Inherit not to reuse, but to be reused.”
“Is a” vs. “has a” vs. “needs to used as a”
Degrades performance
Prefer components over inheritance
Cleaner architecture
Faster execution time and overhead
More flexibility
More encapsulated
Inheritance
[ Wijanarko Sukma . Department of Informatics ]
Important as it relates to inheritance…
Just realize that polymorphism goes two ways
Readable
Unreadable
Polymorphism
[ Wijanarko Sukma . Department of Informatics ]
Book Design Patterns by “The Gang of Four” (Gamma
Helm Johnson Vlissides)
The same problems keep coming up in CS
We keep solving them in the same (or similar) ways.
Is there a pattern here?
Intro to Design Patterns
[ Wijanarko Sukma . Department of Informatics ]
Creational pattern
Only one instance of the object exists
Private constructor with public accessor (usually
Class::Instance())
Really nice name for a global
Often overused, and often not a real solution
Singletons translate well to factories
Singleton
Or “Patterns Don’t Solve all Problems”
[ Wijanarko Sukma . Department of Informatics ]
Singletons (or factories) welcome…
Renderers
Resource managers
Memory managers
Message queues
Singleton Example
[ Wijanarko Sukma . Department of Informatics ]
Behavioral pattern
Inform multiple dependant objects of changes
Usually implemented as Subject and IListener objects
Listeners add themselves to subjects
When a subject changes, all listeners are notified.
Great for message queues
Observer / Listener
[ Wijanarko Sukma . Department of Informatics ]
Architectural pattern
Keeps data and representation separate
Model = data, view = representation
Controller is what sends messages to the model and
view.
Advantages
One data, multiple views
Data manipulates data, and doesn’t care if its being viewed
Change renderers without changing anything else
MVC
Model View Controller
[ Wijanarko Sukma . Department of Informatics ]
Separate view from everything else
MVC Example
[ Wijanarko Sukma . Department of Informatics ]
Renderer
3DObj
Creature
Vs.
Creature Model
CreatureView
Renderer
3DObj
CreatureRadarView
Complete decoupling of logic from display
Easier to test, since you can watch just the logic
Easier to change (both the display and the logic)
Can run the view without the logic
Can run the logic without the view
Can distribute the logic
So long as instances are encapsulated
Advantages of MVC
[ Wijanarko Sukma . Department of Informatics ]
Command
An object that represents stuff that should be done, as
an object
Only needs to understand “Execute” and “Undo”
Great for input handlers, macros, and undoable
operations
Façade
Encapsulate an entire system by providing a single
coherent interface
Proxy
A stand in for a concrete object.
Other Quick Patterns
[ Wijanarko Sukma . Department of Informatics ]
Management idea
That there is a technique that is more effective than
any other technique at delivering positive results.
Something you don’t have to do, but it’s a good idea.
They’re like design patterns on a small scale.
Best Practices
[ Wijanarko Sukma . Department of Informatics ]
Management Best Practices
Use version control
Do automated testing
Have automated builds
Coding Best Practices
Prefer compile / link time errors to run time errors
Give one entity one cohesive responsibility
Prefer composition to inheritance
Always code for concurrency (in terms of architecture)
Examples of Best
Practices
[ Wijanarko Sukma . Department of Informatics ]
Best Practices
Are key to your survival as a coder…
… and key to your code’s survival
[ Wijanarko Sukma . Department of Informatics ]
Know what you’re doing and why.
Know that one approach to inheritance is better and know
why.
Know when you’re coupling systems inadvertently
Know when you’re coupling instances
Know when to test
Know how to test
Know when to automate
Some Advices
[ Wijanarko Sukma . Department of Informatics ]
Know when to refactor
Know when to rearchitect
Know that both are going to break everything
Final Words
[ Wijanarko Sukma . Department of Informatics ]
Game Dev lecturers team
By Wijanarko Sukma (5105100173)
[ Wijanarko Sukma . Department of Informatics ]

More Related Content

Similar to GD - 4th - Game Architecture

Ten years of [Puppet] installations. What now?
Ten years of [Puppet] installations. What now?Ten years of [Puppet] installations. What now?
Ten years of [Puppet] installations. What now?
Alessandro Franceschi
 
Prototyping Axure
Prototyping AxurePrototyping Axure
Prototyping Axure
kkostuch
 
Prototyping with Axure
Prototyping with AxurePrototyping with Axure
Prototyping with Axure
STC Atlanta Chapter
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
wiradikusuma
 
Designing Powerful Web Applications - Monterey
Designing Powerful Web Applications - MontereyDesigning Powerful Web Applications - Monterey
Designing Powerful Web Applications - Monterey
Dave Malouf
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
sukumarraju6
 
Agile
AgileAgile
Agile
Komal2525
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAs
Dave Malouf
 
CQRS recepies
CQRS recepiesCQRS recepies
CQRS recepies
Francesco Garavaglia
 
2013 Lecture 5: AR Tools and Interaction
2013 Lecture 5: AR Tools and Interaction 2013 Lecture 5: AR Tools and Interaction
2013 Lecture 5: AR Tools and Interaction
Mark Billinghurst
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC Applications
Gunnar Peipman
 
Marionette - TorontoJS
Marionette - TorontoJSMarionette - TorontoJS
Marionette - TorontoJS
matt-briggs
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
Thoughtworks
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
ThoughtWorks Studios
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
Christian Gaetano
 
Innoslate 101 webinar steve (1) (1)
Innoslate 101 webinar steve (1) (1)Innoslate 101 webinar steve (1) (1)
Innoslate 101 webinar steve (1) (1)
Elizabeth Steiner
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseKenan Sevindik
 
Basics of Software Architecture for .NET Developers
Basics of Software Architecture for .NET DevelopersBasics of Software Architecture for .NET Developers
Basics of Software Architecture for .NET Developers
Dan Douglas
 
Software Engineering: Models
Software Engineering: ModelsSoftware Engineering: Models
Software Engineering: Models
David Millard
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!
melbats
 

Similar to GD - 4th - Game Architecture (20)

Ten years of [Puppet] installations. What now?
Ten years of [Puppet] installations. What now?Ten years of [Puppet] installations. What now?
Ten years of [Puppet] installations. What now?
 
Prototyping Axure
Prototyping AxurePrototyping Axure
Prototyping Axure
 
Prototyping with Axure
Prototyping with AxurePrototyping with Axure
Prototyping with Axure
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Designing Powerful Web Applications - Monterey
Designing Powerful Web Applications - MontereyDesigning Powerful Web Applications - Monterey
Designing Powerful Web Applications - Monterey
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
Agile
AgileAgile
Agile
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAs
 
CQRS recepies
CQRS recepiesCQRS recepies
CQRS recepies
 
2013 Lecture 5: AR Tools and Interaction
2013 Lecture 5: AR Tools and Interaction 2013 Lecture 5: AR Tools and Interaction
2013 Lecture 5: AR Tools and Interaction
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC Applications
 
Marionette - TorontoJS
Marionette - TorontoJSMarionette - TorontoJS
Marionette - TorontoJS
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
 
Innoslate 101 webinar steve (1) (1)
Innoslate 101 webinar steve (1) (1)Innoslate 101 webinar steve (1) (1)
Innoslate 101 webinar steve (1) (1)
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With Enterprise
 
Basics of Software Architecture for .NET Developers
Basics of Software Architecture for .NET DevelopersBasics of Software Architecture for .NET Developers
Basics of Software Architecture for .NET Developers
 
Software Engineering: Models
Software Engineering: ModelsSoftware Engineering: Models
Software Engineering: Models
 
EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!EclipseCon Eu 2015 - Breathe life into your Designer!
EclipseCon Eu 2015 - Breathe life into your Designer!
 

More from Hadziq Fabroyir

An Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceAn Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld Device
Hadziq Fabroyir
 
在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發
Hadziq Fabroyir
 
NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)
Hadziq Fabroyir
 
律法保護的五件事
律法保護的五件事律法保護的五件事
律法保護的五件事
Hadziq Fabroyir
 
Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話
Hadziq Fabroyir
 
Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西
Hadziq Fabroyir
 
Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳
Hadziq Fabroyir
 
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Hadziq Fabroyir
 
Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for DummiesHadziq Fabroyir
 
How to Select Course at NTUST
How to Select Course at NTUSTHow to Select Course at NTUST
How to Select Course at NTUST
Hadziq Fabroyir
 
NTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationNTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students Orientation
Hadziq Fabroyir
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How toHadziq Fabroyir
 
Brain Battle Online
Brain Battle OnlineBrain Battle Online
Brain Battle Online
Hadziq Fabroyir
 
Manajemen Waktu
Manajemen WaktuManajemen Waktu
Manajemen Waktu
Hadziq Fabroyir
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - TemplateHadziq Fabroyir
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop InheritanceHadziq Fabroyir
 
#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class DiagramHadziq Fabroyir
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator OverloadingHadziq Fabroyir
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting StartedHadziq Fabroyir
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class StructureHadziq Fabroyir
 

More from Hadziq Fabroyir (20)

An Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceAn Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld Device
 
在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發
 
NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)
 
律法保護的五件事
律法保護的五件事律法保護的五件事
律法保護的五件事
 
Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話
 
Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西
 
Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳
 
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
 
Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for Dummies
 
How to Select Course at NTUST
How to Select Course at NTUSTHow to Select Course at NTUST
How to Select Course at NTUST
 
NTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationNTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students Orientation
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How to
 
Brain Battle Online
Brain Battle OnlineBrain Battle Online
Brain Battle Online
 
Manajemen Waktu
Manajemen WaktuManajemen Waktu
Manajemen Waktu
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
 

Recently uploaded

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 

Recently uploaded (20)

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 

GD - 4th - Game Architecture

  • 1. Game Architecture : wanna play a good game ? [ Wijanarko Sukma . Department of Informatics ]
  • 2. Taken from the Presentation slide of : Jeff Ward Associate Programmer Bethesda Game Studios [ Wijanarko Sukma . Department of Informatics ]
  • 3. How can architecture help us : Concurrency Maintainability Code Ownership Usability Performance Stability Architecture [ Wijanarko Sukma . Department of Informatics ]
  • 4. Bad architecture creates problems Produces side effects Hard to follow Hard to debug Hard to reuse Spend more time finding a way around the architecture than fixing the problem OMG HAX! Bad Architecture [ Wijanarko Sukma . Department of Informatics ]
  • 5. Stability Reusability Cohesion Orthogonally Why do Architect (Design) [ Wijanarko Sukma . Department of Informatics ]
  • 6. A well architected system is easy to understand, change, debug, and reuse. [ Wijanarko Sukma . Department of Informatics ]
  • 7. Principles of OOP (Object Oriented Programming) Design Patterns Best Practices Know this first [ Wijanarko Sukma . Department of Informatics ]
  • 8. Example Engine [ Wijanarko Sukma . Department of Informatics ] Logic State Data File Loader Output Input
  • 9. Basics Encapsulation Inheritance Polymorphism Principles of good design Reduced coupling Increased reliability Increased reusability orthogonality OOP Principles [ Wijanarko Sukma . Department of Informatics ]
  • 10. “Encapsulation is a programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.” – Schildt Encapsulation is not just data hiding! Implies each object should be a cohesive whole Encapsulation [ Wijanarko Sukma . Department of Informatics ]
  • 11. Accessing elements between instances It’s a convenience feature, not a good idea “Always Design for Concurrency” – Tip 41 in The Pragmatic Programmer Even if you don’t need it, a cleaner architecture results. Instance Encapsulation [ Wijanarko Sukma . Department of Informatics ] Creature Creature
  • 12. Key overused concept of OOP “ Inherit not to reuse, but to be reused.” “Is a” vs. “has a” vs. “needs to used as a” Degrades performance Prefer components over inheritance Cleaner architecture Faster execution time and overhead More flexibility More encapsulated Inheritance [ Wijanarko Sukma . Department of Informatics ]
  • 13. Important as it relates to inheritance… Just realize that polymorphism goes two ways Readable Unreadable Polymorphism [ Wijanarko Sukma . Department of Informatics ]
  • 14. Book Design Patterns by “The Gang of Four” (Gamma Helm Johnson Vlissides) The same problems keep coming up in CS We keep solving them in the same (or similar) ways. Is there a pattern here? Intro to Design Patterns [ Wijanarko Sukma . Department of Informatics ]
  • 15. Creational pattern Only one instance of the object exists Private constructor with public accessor (usually Class::Instance()) Really nice name for a global Often overused, and often not a real solution Singletons translate well to factories Singleton Or “Patterns Don’t Solve all Problems” [ Wijanarko Sukma . Department of Informatics ]
  • 16. Singletons (or factories) welcome… Renderers Resource managers Memory managers Message queues Singleton Example [ Wijanarko Sukma . Department of Informatics ]
  • 17. Behavioral pattern Inform multiple dependant objects of changes Usually implemented as Subject and IListener objects Listeners add themselves to subjects When a subject changes, all listeners are notified. Great for message queues Observer / Listener [ Wijanarko Sukma . Department of Informatics ]
  • 18. Architectural pattern Keeps data and representation separate Model = data, view = representation Controller is what sends messages to the model and view. Advantages One data, multiple views Data manipulates data, and doesn’t care if its being viewed Change renderers without changing anything else MVC Model View Controller [ Wijanarko Sukma . Department of Informatics ]
  • 19. Separate view from everything else MVC Example [ Wijanarko Sukma . Department of Informatics ] Renderer 3DObj Creature Vs. Creature Model CreatureView Renderer 3DObj CreatureRadarView
  • 20. Complete decoupling of logic from display Easier to test, since you can watch just the logic Easier to change (both the display and the logic) Can run the view without the logic Can run the logic without the view Can distribute the logic So long as instances are encapsulated Advantages of MVC [ Wijanarko Sukma . Department of Informatics ]
  • 21. Command An object that represents stuff that should be done, as an object Only needs to understand “Execute” and “Undo” Great for input handlers, macros, and undoable operations Façade Encapsulate an entire system by providing a single coherent interface Proxy A stand in for a concrete object. Other Quick Patterns [ Wijanarko Sukma . Department of Informatics ]
  • 22. Management idea That there is a technique that is more effective than any other technique at delivering positive results. Something you don’t have to do, but it’s a good idea. They’re like design patterns on a small scale. Best Practices [ Wijanarko Sukma . Department of Informatics ]
  • 23. Management Best Practices Use version control Do automated testing Have automated builds Coding Best Practices Prefer compile / link time errors to run time errors Give one entity one cohesive responsibility Prefer composition to inheritance Always code for concurrency (in terms of architecture) Examples of Best Practices [ Wijanarko Sukma . Department of Informatics ]
  • 24. Best Practices Are key to your survival as a coder… … and key to your code’s survival [ Wijanarko Sukma . Department of Informatics ]
  • 25. Know what you’re doing and why. Know that one approach to inheritance is better and know why. Know when you’re coupling systems inadvertently Know when you’re coupling instances Know when to test Know how to test Know when to automate Some Advices [ Wijanarko Sukma . Department of Informatics ]
  • 26. Know when to refactor Know when to rearchitect Know that both are going to break everything Final Words [ Wijanarko Sukma . Department of Informatics ]
  • 27. Game Dev lecturers team By Wijanarko Sukma (5105100173) [ Wijanarko Sukma . Department of Informatics ]

Editor's Notes

  1. Bad architectures create problems, and often you will end up solving the wrong problem in order to work around the architecture. Why is this? Bad architecture can produce a lot of side affects. Code that affects lots of systems synchronously can sometimes do really weird things you weren’t expecting, causing hard to trace bugs. Bad architectures are hard to follow, especially when you’re not stepping through the code because you don’t necessarily know what will call what, or what side effects will occur based on a single function call. As a result, bad architectures are hard to debug. There’s lots of things to step into and trace before you can find the root of the problem. Bad architectures are also very hard to reuse, since ripping out any one given system to use somewhere else (or replace in the current game) can cause a very large number of side effects Generally, near the end of projects you will spend more time debugging and trying to find a way around the architecture in order to fix an issue than you will actually fixing the issue. And even then your fix may not actually solve the problem, or may create more. Known as the OMG HAX syndrome.
  2. Fortunately, following the principles of OOP will improve the mess We’re going to spend a bit of time talking about some of the principles of OOP you probably take for granted Though not principles of OOP, principles of good design will also help us create a well architected engine. Coupling is the degree to which modules rely on each other The $10 word here is ortogonality, which isn’t actually a word “is a system design property which facilitates the making of complex designs feasible and compact “ - Wikipedia
  3. Encapsulation is a principle we take for granted Remember that encapsulation is not just data hiding, though they are closely related. It means that data, and the processes to edit that data are kept together. Encapsulation implies that an object should be a cohesive whole Which also means that it should do one thing and ONLY one thing. Any modification from classes outside itself increases coupling, and introduces side effects It also implies that instances of the same class should not edit each others
  4. Encapsulation should also be applied between instances By editing the state of an object outside it’s own scope, you can introduce a layer of hidden coupling, not necessarily between systems but between objects in the same systems, and between instances of the same object This may not sound bad, but it can produce some seriously mean side effects as you move forward with developing your engine. It also makes concurrency harder, since editing instances of the same objects means they can’t be parallelized. You always want to design for concurrency. Which means objects should always be in a valid state before and after a function call. Instances should always edit each other through function calls, or better, message passing, which we’ll get to.
  5. Inheritance is frequently overused. It tightly couples the child to the parent, and all things that use the child to the parent. It’s often an invisible form of coupling you don’t want. It is usually used to reuse code, a place where it is usually not welcome. Inheriting to reuse code usually means you’re actually looking at a containment relationship. A “has a” relationship if you will. But it is important to understand inheritance should only be used not where you want to reuse code, but where an object needs to be reused under difference circumstances. Interfaces are probably the best example of this Frequently told inheritance is an “is a” relationship. That if something “is” something else, than you’re looking at inheritance. This is not necessarily true. If something “is” something else, but will never be used like that something else, there is no reason to inherit. So we run into the “is a” vs. “has a” vs. “needs to be used as a” relationship. Know which one you’re working with. Anthoer way to think of it is “Extends the functionality of…” But remember, you may not need all of the functionality of the base class, so make sure you’re using it under the right circumstances. Remember, large inheritance degrades performance silently, and other architectures can do similar things with less overhead, and more flexibility Components are my personal favorite. Flexibility is offered in that you can always add random components (at compile time or at run time) to any class you want. In the last point, we can protect and control the data of a single component far easier than we can on a class with an inheritance tree. Changes can be made at any point in the tree, which makes things difficult Although components are my personal favorite, you’ll find they don’t solve all problems. Remember, there are no magic bullets. This is a best practice (which we’ll get to) not a steadfast rule. Use the rules where you think they’re needed, just be careful you’re not overusing anything.
  6. Polymorphism probably doesn’t deserve it’s own slide. It’s an important concept to OOP, especially as it relates to inheritance, but not hugely important to this architecture talk, which is more about relationships between classes. There are two ways polymorphism can go. Readable. For example math operations on matricides that can take integers, floats, and other matricies. Unreadable. For example Damage functions on your creatures that can take both Creatures and Bullets. (well if the player shot the bullet, which one do I use again?)
  7. How many people have heard of design patterns? How many people can name a few? Singleton, Factory, Façade, Proxy, Model / View / Controller, Iterator, Command, Observer / Listener, Chain of Responsibility Singleton is a favorite, and it’s where we’ll start
  8. Creational pattern (meaning it describes how an object gets created) Usually Instance() will create the object if it doesn’t exist, and holds onto it via a static member pointer A singleton is usually being used as a global, and globals wreak havoc on encapsulation and concurrency But if you’re working with a single instance of something that isn’t easily contained in another class, a singleton is better than a global for various reasons, including their portability into factories 1 instance per thread constructions Swapping constructions (get an instance that is currently viable) Control whether instances can be allocated Always avoid the “static class” a class where all members are static. These are just bad ideas, since they’re so hard to change
  9. Behavioral pattern means it changes the way things behave (other examples are Command and Chain of Responsibility) Already you can see reduced coupling because the subject doesn’t need to know what the subjects are, or where they are, or even if they exist at all. Furthermore, listeners don’t need to even know what subject they’re listening to, just that they’ll be informed if they need to change.
  10. Not in Design Patterns Probably my favorite pattern, since it illustrates a key point in design: Data and representation of that data are separate. Examples CSS in web development Code behinds in ASP.NET and XAML
  11. The idea here is to completely separate the visual identity of the creature from its thought process (It has an image problem) Also, you make sure the view is only asking the model for data, not the other way around. The model shouldn’t care what is happening in renderer land The second may look more complicated, but it has advantages. We can add more views of the same model, which is an easy way to do radar systems and maps. We can completely remove the view and have a completely working AI system, which can think either off screen, or even on a separate computer, without ever being rendered.
  12. For more information, read Design Patterns Command is probably the one I use most of these three. Allows you to easily support macros (see the composite pattern) as well as undo opperations They’re great for input handlers (bind keys to command creation functions via a map) as well as for any undoable operation. The others are included just because you might want to sound smart one day.
  13. Best practices are a management idea (but we won’t hold that against it) It’s the idea that there is a way of doing things that will produce the results you want faster and more efficiently than other methods of doing the same thing. For programmers, it’s something that’s not standardized (or written in the coding standards of your company) but following it tends to lead to good code, well architected systems, and things that are easy to change without side effects. Basically, you don’t have to do these, but they tend to be good ideas. They’re like design patterns in that, people found that certain practices led to bad results, and that doing things in a certain way would keep these things from happening. I recommend two books on the subject These are my personal favorites, but there are others including Effective C++, Effective C#, Effective STL, etc.
  14. Know when to refactor. Refactoring is a general term for taking the same functionality and making it better. This includes redesigns and simple changes to pull out common code into funciton calls. If functions or classes are becoming monolithic, it’s time to think about where things may be split up. Refactoring doesn’t necessarily change the external interface, but the internal workings Know when to rearchitect Rearchitecting is technically refactoring, but in my mind, it’s going back to the drawing board because things just aren’t working right If you can, rearchitecting should be done in stages, so you’re always left with working code. Both refactoring and rearchitecting are there to improve your engine, but they’ll break lots of things along the way. They will ALWAYS break things along the way. Get into the habit of the TDD cycle (even if you’re not doing TDD). Always make sure your previous functionality is still working before moving on.