Podcast
Questions and Answers
Which design pattern allows the selection of interchangeable algorithms at runtime?
Which design pattern allows the selection of interchangeable algorithms at runtime?
- State
- Strategy (correct)
- Memento
- Mediator
What is the primary purpose of the Observer pattern in design?
What is the primary purpose of the Observer pattern in design?
- To manage direct dependencies between objects
- To encapsulate a request as an object
- To notify one object about changes in another object (correct)
- To capture an object's state for restoration
Which pattern helps to create families of related objects without specifying their concrete classes?
Which pattern helps to create families of related objects without specifying their concrete classes?
- Prototype
- Singleton
- Builder
- Abstract Factory (correct)
Which design pattern allows objects to be composed into tree structures for representing part-whole hierarchies?
Which design pattern allows objects to be composed into tree structures for representing part-whole hierarchies?
What functionality does the Mediator pattern provide in software design?
What functionality does the Mediator pattern provide in software design?
Which pattern captures an object’s state without violating encapsulation for later restoration?
Which pattern captures an object’s state without violating encapsulation for later restoration?
What does the Singleton pattern ensure in software design?
What does the Singleton pattern ensure in software design?
Which pattern dynamically adds responsibilities to an object?
Which pattern dynamically adds responsibilities to an object?
What is the primary purpose of the Proxy design pattern?
What is the primary purpose of the Proxy design pattern?
Which design pattern provides a way to alter an object's behavior based on its internal state?
Which design pattern provides a way to alter an object's behavior based on its internal state?
Which of the following best describes abstraction in object-oriented programming?
Which of the following best describes abstraction in object-oriented programming?
What does the Adapter design pattern do?
What does the Adapter design pattern do?
What is the primary purpose of encapsulation in software engineering?
What is the primary purpose of encapsulation in software engineering?
Which design pattern allows for the creation of families of related objects without specifying their concrete classes?
Which design pattern allows for the creation of families of related objects without specifying their concrete classes?
How does inheritance promote clarity in code organization?
How does inheritance promote clarity in code organization?
What does the Chain of Responsibility pattern accomplish?
What does the Chain of Responsibility pattern accomplish?
What does polymorphism allow objects to do?
What does polymorphism allow objects to do?
Which design pattern is responsible for notifying observers of changes in state?
Which design pattern is responsible for notifying observers of changes in state?
Which principle emphasizes the importance of loosely coupled modules?
Which principle emphasizes the importance of loosely coupled modules?
What is the function of the Command design pattern?
What is the function of the Command design pattern?
What is dynamic binding in the context of object-oriented programming?
What is dynamic binding in the context of object-oriented programming?
Which description fits the Flyweight design pattern?
Which description fits the Flyweight design pattern?
What does the term ‘composition’ refer to within hierarchy in object-oriented design?
What does the term ‘composition’ refer to within hierarchy in object-oriented design?
In the context of robot movement simulation, what role do movement chips play?
In the context of robot movement simulation, what role do movement chips play?
What design pattern is used to encapsulate a request as an object, enabling parameterization and queuing?
What design pattern is used to encapsulate a request as an object, enabling parameterization and queuing?
Which design pattern allows an object to alter its behavior when its internal state changes?
Which design pattern allows an object to alter its behavior when its internal state changes?
Which design pattern centralizes control over how objects interact, thus reducing direct dependencies?
Which design pattern centralizes control over how objects interact, thus reducing direct dependencies?
What is the primary function of the Memento pattern?
What is the primary function of the Memento pattern?
Which design pattern allows for the dynamic addition of responsibilities to an object?
Which design pattern allows for the dynamic addition of responsibilities to an object?
What does the Strategy pattern encapsulate?
What does the Strategy pattern encapsulate?
Which pattern defines a unified interface to a set of interfaces in a subsystem?
Which pattern defines a unified interface to a set of interfaces in a subsystem?
What does the Observer pattern establish between objects?
What does the Observer pattern establish between objects?
What does the Command pattern enable with regards to requests?
What does the Command pattern enable with regards to requests?
Which pattern provides a placeholder or surrogate to control access to another object?
Which pattern provides a placeholder or surrogate to control access to another object?
How does the Strategy pattern function in terms of algorithm selection?
How does the Strategy pattern function in terms of algorithm selection?
What is the primary role of the Facade pattern?
What is the primary role of the Facade pattern?
What does the Mediator pattern do to improve object interactions?
What does the Mediator pattern do to improve object interactions?
The Flyweight pattern is primarily used to:
The Flyweight pattern is primarily used to:
What is the main function of the Visitor pattern?
What is the main function of the Visitor pattern?
The Composite pattern is used primarily to:
The Composite pattern is used primarily to:
What is the main purpose of the Singleton pattern?
What is the main purpose of the Singleton pattern?
Which design pattern captures and restores an object's state without violating encapsulation?
Which design pattern captures and restores an object's state without violating encapsulation?
In which scenario is the Iterator pattern most useful?
In which scenario is the Iterator pattern most useful?
What is a key characteristic of the Observer pattern?
What is a key characteristic of the Observer pattern?
Which design pattern enables adding new operations without modifying existing classes?
Which design pattern enables adding new operations without modifying existing classes?
What does the Template Method pattern achieve?
What does the Template Method pattern achieve?
Which of the following is NOT a typical use case for a Singleton pattern?
Which of the following is NOT a typical use case for a Singleton pattern?
What is the consequence of using the Mediator pattern for object communication?
What is the consequence of using the Mediator pattern for object communication?
Flashcards
Façade
Façade
Provides a unified interface to a set of interfaces in a subsystem.
Flyweight
Flyweight
Shares data to reduce memory costs of creating many similar objects.
Proxy
Proxy
Provides a placeholder or surrogate to control access to another object.
Chain of Responsibility
Chain of Responsibility
Signup and view all the flashcards
Command
Command
Signup and view all the flashcards
Interpreter
Interpreter
Signup and view all the flashcards
Iterator
Iterator
Signup and view all the flashcards
Mediator
Mediator
Signup and view all the flashcards
Interpreter Pattern
Interpreter Pattern
Signup and view all the flashcards
Facade Pattern
Facade Pattern
Signup and view all the flashcards
Prototype Pattern
Prototype Pattern
Signup and view all the flashcards
Flyweight Pattern
Flyweight Pattern
Signup and view all the flashcards
Strategy Pattern
Strategy Pattern
Signup and view all the flashcards
State Pattern
State Pattern
Signup and view all the flashcards
Proxy Pattern
Proxy Pattern
Signup and view all the flashcards
Object-Oriented Programming
Object-Oriented Programming
Signup and view all the flashcards
Decorator Pattern
Decorator Pattern
Signup and view all the flashcards
Encapsulation
Encapsulation
Signup and view all the flashcards
Hierarchy
Hierarchy
Signup and view all the flashcards
Polymorphism
Polymorphism
Signup and view all the flashcards
Modularity
Modularity
Signup and view all the flashcards
Reusability
Reusability
Signup and view all the flashcards
Dynamic Binding
Dynamic Binding
Signup and view all the flashcards
Abstraction
Abstraction
Signup and view all the flashcards
Prototype
Prototype
Signup and view all the flashcards
Singleton
Singleton
Signup and view all the flashcards
Adapter
Adapter
Signup and view all the flashcards
Builder
Builder
Signup and view all the flashcards
Bridge
Bridge
Signup and view all the flashcards
Composite
Composite
Signup and view all the flashcards
Decorator
Decorator
Signup and view all the flashcards
Singleton Pattern
Singleton Pattern
Signup and view all the flashcards
getInstance()
getInstance()
Signup and view all the flashcards
Deleting copy and assignment operators
Deleting copy and assignment operators
Signup and view all the flashcards
RandomEngine class (Singleton Pattern)
RandomEngine class (Singleton Pattern)
Signup and view all the flashcards
GameSettings class (Singleton Pattern)
GameSettings class (Singleton Pattern)
Signup and view all the flashcards
Private Constructor
Private Constructor
Signup and view all the flashcards
Lazy Initialization
Lazy Initialization
Signup and view all the flashcards
Singleton Pattern Usage
Singleton Pattern Usage
Signup and view all the flashcards
Memento
Memento
Signup and view all the flashcards
Observer
Observer
Signup and view all the flashcards
State
State
Signup and view all the flashcards
Strategy
Strategy
Signup and view all the flashcards
Template Method
Template Method
Signup and view all the flashcards
Visitor
Visitor
Signup and view all the flashcards
Abstract Factory
Abstract Factory
Signup and view all the flashcards
Study Notes
Introduction to Games Engineering
- A practical guide to games engineering, focusing on good practice rather than deep theory
- Aims to make coding easier and improve overall intuition
- Will not delve into complex theoretical backgrounds
Overview
- Object-Oriented Programming (OOP) principles
- Problem-solving strategies
- Design patterns
- Software Engineering (SE) principles
OOP Overview
- Object-Oriented Design with Applications (Grady Booch, 1991)
- Object-Oriented Programming (OOP): Abstraction, Encapsulation, Hierarchy, Polymorphism
Abstraction
- Defining aspects of the computation as objects (e.g. graphical components)
- Booch defines abstraction as the characteristics of an object distinguishing it from others and crisply defining conceptual boundaries relative to the perspective of the view
Encapsulation
- Binding data and operations together within each class
- Includes interface and implementation
- Information hiding: Enforcing modularity and reducing coupling
- Liskov emphasizes encapsulation for abstractions to function effectively
Hierarchy
- Organizing relationships through inheritance and composition
- Simplifies code, promotes clarity and reflects real-world relationships
Polymorphism
- "Many shapes" Objects respond to operations based on their type
- Extending with new behaviors without modifying existing behaviors
Other Principles
- Modularity: Architecting loosely coupled, reusable modules
- Reusability: Encouraging component reuse
- Dynamic Binding: Determining method calls at runtime
Random Walk Problem
- Simulating a robot's movement in a Cartesian grid
- Different movement chip types (e.g., compass directions, diagonal movements) and field types (e.g., uniform, diagonal warp space, slanting)
- Movement varies depending on field configurations (e.g., uniform, diagonal shifts, etc.). These details are explained in a) to i) on slide 10.
Coding (Implementation details)
- Utilizing location.h for position tracking
- Separating the concerns into distinct classes (e.g., location, movement, robot, field, simulation)
- Promoting a clear modular design
Abstraction (Implementation)
-
Classes abstract functionality across the system's classes: (e.g., Location, Movement, Robot, Field, Simulation).
-
Interacting with these components without knowing implementation details.
Encapsulation (Implementation)
- Classes protect data; allowing controlled access (e.g. Robot access to location)
- Internal implementation details are not visible or manipulated directly.
Hierarchy (Implementation)
- Inheritance for movement and field implementation
- Composition in the robot and simulation components to represent a cohesive system
Polymorphism (Implementation)
- Use virtual functions (movement::move(), field::moveInField()) to support varied movement modes with ease.
Design Patterns
- Principles stemming from Booch's OOP
- Design Patterns (Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, 1994) address recurring problems in software development
- Abstract Factory: Handles families of related objects without specifying concrete classes.
- Builder: Separates object construction from its representation.
- Factory Method: Creates objects by copying an existing object.
- Prototype: Creates new objects by cloning existing ones (important for avoiding redundant instantiation).
- Singleton: Creates a single instance of a class and provides a global access point.
- Adapter: Converts an existing interface into another interface clients expect.
- Bridge: Decouples abstraction from implementation to allow independent variation.
Singleton Pattern
- Ensures only one instance of a class exists globally
- Provides a controlled access point often used for managing global resources such as loggers, configuration managers, database connections, etc or as a pattern for getting the one single instance of a class (eg. a random engine).
Factory Method Pattern
- Encapsulates object creation logic as an interface, allowing flexibility
- Client code then relies on the factory to produce the correct object instance, without knowing specific classes.
- Solves the problem of adding many different types of objects that vary in a multitude of ways/conditions/strategies.
Strategy Pattern
- Encapsulates interchangeable algorithms and allows runtime selection of those specific algorithms. This facilitates swapping out different movement/field types.
Template Method Pattern
- Base classes define algorithms and derived class override specific steps
- Enforces a consistent structure for handling a set of operations (eg. rendering pipeline) in a consistent way across subclasses.
Mediator Pattern
- Simplifying interaction between objects; reduces the code necessary for implementation in multiple places. The mediator handles the interaction between objects without requiring them to know of each other's existence.
Applications of Mediator Pattern
- Networking: Communicating with remote components without involving other components directly.
- Entity Component Systems (ECS): Managing interactions between components (eg. attack and health systems) without needing to alter the core entities.
- Combat calculators: Handling calculations between different entities (characters) without requiring them to know of each other's existence.
Iterator Pattern
- Iterating through objects, particularly for container structures.
- This promotes code reusability, making it easy to implement iterative traversals in consistent ways.
Prototype Pattern
- Creating unique instances for objects (eg. robots, fields).
- Cloning previously instantiated objects (using clone) rather than instantiation helps in avoiding redundant instantiation. This is helpful in ECS.
Observer Pattern
-
Establishing a relationship for listening to updates and informing multiple other elements in the system of changes.
-
Useful in circumstances requiring a multiple observer system, or a system requiring awareness to changes in state.
State Pattern
- Enables flexible changes in object behavior based on its internal state.
- Useful when object behavior depends on its various states (eg. traffic light).
Software Engineering Principles
- Broad guidelines for efficient, high-quality, reliable systems.
- Covers design, implementation, testing and maintenance.
Modularity, Abstraction, Encapsulation, Separation of Concerns, Single Responsibility Principle, Open/Closed Principle, DRY, KISS, YAGNI, High Cohesion and Low Coupling, Scalability, Maintainability, Testability, Reusability
- Principles used to define and construct consistent and reliable programming.
Composition vs. Inheritance
- Composition over Inheritance: Emphasizes how to use relationships and composition to build dynamic systems that are easily changeable and maintainable.
Multiple Inheritance Diamond Problem
- Detailed overview, including the difficulties of multiple inheritance and how to avoid them
Entity Component System (ECS)
- Detailed overview of architecture, including component structure, operations and game entity management.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of essential design patterns in software engineering. This quiz covers various patterns, including the Singleton, Observer, and Adapter, and their roles in creating efficient software architectures. Perfect for software designers and developers looking to deepen their understanding of design principles.