Explore tens of thousands of sets crafted by our community.
Common Programming Patterns
20
Flashcards
0/20
Chain of Responsibility Pattern
Passes a request along a chain of handlers. Upon receiving a request, each handler decides either to process the request or pass it to the next handler in the chain. Useful for event handling or AI decision-making.
Flyweight Pattern
Uses sharing to support a large number of objects that have part of their internal state in common where the differences are few, to save memory. Ideal for game objects like bullets, trees, or particles.
Facade Pattern
Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. Commonly used for hiding complex systems like physics or rendering.
Iterator Pattern
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Used in game development for iterating over game objects, inventory items, etc.
Builder Pattern
Separates the construction of a complex object from its representation, allowing the same construction process to create various representations. Used for constructing complex game objects or levels.
Memento Pattern
Without violating encapsulation, captures and externalizes an object's internal state so that the object can be restored to this state later. Often used for saving and loading game progress or states.
Factory Pattern
Defines an interface for creating an object, letting subclasses decide which class to instantiate. It's used to manage and centralize object creation when the type of objects can vary.
Visitor Pattern
Lets you define a new operation without changing the classes of the elements you operate on. Handy for adding functions to classes without altering them, such as save functions that apply to various game elements.
Strategy Pattern
Defines a family of algorithms, encapsulates each one, and makes them interchangeable within that family. Strategy lets the algorithm vary independently from clients that use it, such as different AI behaviors.
Observer Pattern
Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Useful for UI updates, game event systems, etc.
Adapter Pattern
Allows incompatible interfaces to work together by converting the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
Proxy Pattern
Provides a surrogate or placeholder for another object to control access to it, potentially deferring the full cost of its creation and initialization until we actually need to use it. Used for network management and lazy-loaded textures.
Singleton Pattern
Restricts the instantiation of a class to a single instance and provides global access to it. Often used for managing game managers, factories, and cross-script communications.
Component Pattern
Allows for flexibility in game objects by composing them of interchangeable components rather than inheriting from a base class. Utilized for building complex entities from simple, reusable pieces.
Prototype Pattern
Creates new objects by copying an existing object, known as the prototype. This pattern is used in games for easy cloning of complex or costly objects to instantiate.
State Pattern
Allows an object to alter its behavior when its internal state changes. The object will appear to change its class. It's often used for character states, AI states, and game phase transitions.
Command Pattern
Encapsulates a request as an object, thereby allowing for parameterization of clients with queues, requests, and operations. Often used for implementing undo/redo features, AI queues, or input handling.
Composite Pattern
Allows you to compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. Used for scene graphs or UI components.
Mediator Pattern
Defines an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly. Useful for chat systems or UI interactions.
Decorator Pattern
Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality, such as adding power-ups or statuses to game characters.
© Hypatia.Tech. 2024 All rights reserved.