0% found this document useful (0 votes)
12 views

1 Introduction

Uploaded by

mirabeymi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

1 Introduction

Uploaded by

mirabeymi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

SENG 454

Game Design Patterns

Assoc.Prof.Dr. Tansel Dökeroğlu


Books

2
Books

3
Syllabus of the lecture

4
Definition of a design pattern

• A general, reusable solution to a commonly occurring


problem within a given context in software design.

• A description or template for how to solve a problem that


can be used in many different situations.

• Formalized best practices that the programmer can use to


solve common problems when designing an application or
system.

5
Definition of a design pattern

• Not a finished design that can be transformed directly into


source or machine code.

• Design patterns show relationships and interactions between


classes or objects, without specifying the final application
classes or objects that are involved.

• Only suitable for object-oriented languages.

6
Applications of design patterns

• Speed up the development process by providing tested,


proven development paradigms.
• Improves code readability for coders and architects familiar
with the patterns.
• Design patterns provide general solutions, not specific to
some problems.
• Allows developers to communicate using well-known, well
understood names for software interactions.

7
Good for solving software structural problems

• Abstraction
• Encapsulation
• Information hiding
• Separation of concerns
• Coupling and cohesion
• Separation of interface and implementation
• Single point of reference
• Divide and conquer

8
Solving non-functional software problems

• Changeability
• Interoperability
• Efficiency
• Reliability
• Testability
• Reusability
• Maintenance
• Flexibility
Patterns, Architectures & Frameworks

Frameworks are partially completed software systems that


may be targeted at a particular type of application.
These are tailored by completing the unfinished components.

Architectures model software structure at the highest


possible level, and give the overall system view.
An architecture can use many different patterns in different
components

Software Design Patterns are more like small-scale or local


architectures for architectural components or sub-components
10
Categorization of Classical Design Patterns

• Creational: Creating an object in a flexible way.


Separate creation from operation/use.

• Structural: Compose objects to obtain new functionality.

• Behavioral: Related with communication between


objects.

11
Creational Design Patterns

Factory : providing an interface for creating objects in a superclass,


but allows subclasses to alter the type of objects that will be
created.

Builder: constructing complex objects step by step.


The pattern allows you to produce different types and
representations of an object using the same construction code.

12
Creational Design Patterns

Prototype: copying existing objects without making your code


dependent on their classes. Some of the object’s fields may be
private and not visible from outside of the object itself.

Singleton: Ensuring that a class has only one instance, while


providing a global access point to this instance. some of the object’s
fields may be private and not visible from outside of the object itself.

13
Structural Design Patterns

Adapter: allows objects with incompatible interfaces to collaborate.

Bridge: splitting a large class or a set of closely related classes into


two separate hierarchies—abstraction and implementation—which
can be developed independently of each other.

14
Structural Design Patterns

Decorator: attaching new behaviors to objects by placing these


objects inside special wrapper objects that contain the behaviors.

Facade: providing a simplified interface to a library, a framework, or


any other complex set of classes.

Flyweight: fitting more objects into the available amount of RAM by


sharing common parts of state between multiple objects instead of
keeping all of the data in each object.

15
Behavioral Design Patterns

Command: turning a request into a stand-alone object that contains


all information about the request. This transformation lets you
parameterize methods with different requests, delay or queue a
request’s execution, and support undoable operations.

16
Behavioral Design Patterns

Iterator: traversing elements of a collection without exposing its


underlying representation (list, stack, tree, etc.).

Mediator: reducing chaotic dependencies between objects.


The pattern restricts direct communications between the objects
and forces them to collaborate only via a mediator object.

17
Behavioral Design Patterns

Observer: defining a subscription mechanism to notify multiple


objects about any events that happen to the object
they’re observing.

Template: defining the skeleton of an algorithm in the superclass


but lets subclasses override specific steps of the algorithm without
changing its structure.

Visitor: separating algorithms from the objects on which


they operate.
18
Behavioral Design Patterns

State: letting an object alter its behavior when its internal state
changes. It appears as if the object changed its class. This pattern can
be observed in a vending machine. Vending machines have states
based on the inventory, amount of currency deposited, the ability to
make change, the item selected, etc.

Strategy: defining a family of algorithms, put each of them into a


separate class, and make their objects interchangeable.

19
Game Design Patterns
• Sequencing Patterns: time — the artificial world lives and
breathes at its own rthyme. We must invent time and craft the
gears that drive our clock of the game.

• Behavioral (game): quickly define and refine a large quantity of


maintainable behavior.

• Decoupling Patterns : we mean a change in one usually doesn’t


require a change in the other. When you change some feature in
your game, the fewer places in code you have to touch, the easier
it is.

• Optimization Patterns: Optimizing for performance is a deep art


that touches all aspects of software.
20
Sequencing Patterns
• Double Buffer
• Game Loop
• Update Method

Behavioral Patterns
• Bytecode
• Subclass Sandbox
• Type Object

Decoupling Patterns
• Component
• Event Queue
• Service Locator

Optimization Patterns
• Data Locality
• Dirty Flag
• Object Pool
• Spatial Partition

You might also like