Use of design patterns for mobile game development - Ilja Astahovs, 2012
1
1 Introduction
1.1 Design patterns: historical review
The notion of a design pattern (DP) as a well documented approach to solving some common
problem occurring in software development was first popularized by a book “Design Patterns:
Elements of Reusable Object-Oriented Software” by a group of authors
1
also known as “Gang of
Four”. Originally, the patterns were grouped into three categories: structural, creational and
behavioral [GoF]. Other classifications include architectural patterns and concurrency patterns
[18].
Evolution of programming languages and introduction of different design patterns is all about
controlling complexity of software systems. The emerging use of DPs was the next logical step
after invention of object-oriented programming (OOP) [Flynt], which emphasized component-
centered development inside a framework. Applying DPs for solving recurring problems
improves the object-oriented approach and makes it possible to deal with ever-growing
complexity of applications. Understanding the problems solved by certain DPs helps to describe
the purpose of different software components [Flynt, Core]. Instruments such as software
development kits (SDKs) and frameworks used in software development evolve, and it
encourages the programmer to reuse not only some basic components (e.g., reuse of components
belonging to STL, Standard Template Library, in C++) but also complete modules (e.g., parts of
game engines: game state managers, event systems etc.).
1.2 Design patterns nowadays: do we need them?
Even though the design pattern themselves were a product of refactoring [Flynt], one can argue
how well design pattern-driven development fits into iterative and incremental design, which is
what modern game-development process tends to be nowadays. In the modern era of agile
software development, initial ideas quickly turn into prototypes, which in turn can rapidly
transform into actual code blocks. Growing competition inside the industry, tough budgets and
deadlines simply does not leave any resources available for perfectly thought-out design.
Moreover, even though the OOP strove for re-usability (especially on framework-level, where
most of the code in the final products is the code which belongs to the framework components)
[Flynt], the re-usability of the custom code is significantly lower. Writing a re-usable code can
cost three times more than writing a single-use code [19, 20], and integrating design patterns
into the development process requires a lot of effort [Schmidt], so why would one bother paying
extra attention producing a “nicer” design?
DPs can also be grouped into universal patterns and situational patterns. The former, as the
name suggests, does not depend on language or technology, and often describe project's overall
structure, meaning that one can apply it to any project, only with minor changes. Because the
purpose of this thesis is to give a more general insight into what is the role played by the design
patterns in the modern game development and the choice of the technology is a much minor
issue, this thesis will focus on the universal patterns.
1.3 Design patterns and game development
Using the DPs has proved to be useful for the design of general application software, especially
web applications where many of DPs fit naturally into client-server model. But what about game
applications, is there something specific about them? The specifics of game applications
(similarly to other simulation software) are as follows: even small games require dozens of well
organized classes, thus code modularization is required. Compared to web and business
applications, games are more dynamic. The gameworld is subject to constant changes, which
requires fast communication between game objects, as well as keeping visual representation
1
Eric Gamma, Richard Helm, Ralph Johnson and John Vlissides