A Framework For Integrating Software Design Patter
A Framework For Integrating Software Design Patter
net/publication/333740637
CITATIONS READS
5 309
1 author:
SEE PROFILE
All content following this page was uploaded by Nahla hosny Barakat on 21 April 2020.
47
One drawback is that; due to the expanding markets, and will save the program multiple, unnecessary initializations, which
competition between companies, the time to market has been can be error prone.
shortened, which has lead to a faster development lifecycle. As a
result, and due to the advancement of games’ technicalities and
2.1.2 The Observer design pattern
intelligence; the first versions released for games would possibly This pattern outlines one-to-many dependency between objects,
have some bugs[7] .To upgrade those versions and to facilitate where if an object changes its state, all its dependent objects states
efficient fixing of possible bugs; efficient, well structured are updated automatically. According to GoF, the observer
development methodologies became an urgent and mandatory pattern allows programmers to reuse the subjects independent
need. Therefore, different frameworks for games’ design and of their observers and vice versa[10]. The observer DP can be
development have been introduced[8, 9], which define different used in UI, health bar that must be notified and updated at run-
aspects that should be considered when developing a game. time.
Integrating these frameworks with GoF design patterns would be 2.1.3 The Strategy pattern
really helpful for the purpose of reuse and maintainability [7], The strategy DP, defines a family of algorithms, which are
considering the special, dynamic nature of video games, and the executed interchangeably during the runtime. This can be useful
increasing demand for solving recurrent problems in game in different game contexts, where it can be used to alter artificial
software [7]. However, this integration should take into intelligence behaviors of players, or the weapons they use.
consideration the specialized development methodologies, which
are different from the traditional software development, as well as
2.1.4 The State pattern
the diversity of games components, which need to be handled The state pattern allows an object that its internal state changes to
wisely by skilled designers and programmers. change its behavior accordingly. This pattern is appropriate for
most games and can be also used to animate the players [11].
In this paper, we propose a framework that integrates some
creational and behavioral design patterns, with a specific game 2.2 Formal, Dramatic and Dynamic Game
design framework. In this way, we claim that the developers will Design Framework
have some hints on what DP to use with the main game aspects. Several game design frameworks have been proposed [8, 9].
This framework is suitable for games which can be developed However, they share the main elements, with minor variations in
after the first course of game design, regardless of the game details. We have chosen Fullerton [8] framework, which is one of
engine used for development. The framework can be extended the simplest, yet comprehensive frameworks to build on.
with more DP; for larger scale and more sophisticated game.
The framework has three main families of game aspects: formal,
The rest of the paper is organized as follows: Section 2 provides dramatic and dynamic. A summarized description of each aspect
brief background on the selected design patterns and the game is given below:
design framework, which we use on our framework. This is
followed by the related work. In Section 3, a detailed description 2.2.1 The formal aspects:
of the proposed framework is introduced. Section 4 highlights the According to this framework[8], formal aspects include the game
study limitations, where Section 5 provides conclusions and future objectives, which define what the player should achieve, game
perspectives. rules, which define what can or can’t be done by the player, and
how to respond and behave in different situations. Without
2. Background obeying the game rules, the game can’t proceed [8].The player
In this part, the software design patterns[2],and the game design interaction patterns refer to the classification of a game as a
framework [8] which we utilize in our framework are summarized single player or multiplayer. In case of multi players, it states how
in Sections 2.1 and 2.2 respectively. This is followed by the they interact (collaborate, compete, one versus one, etc.). One of
related work in Section 2.3. the most important elements here; is the game resources, which
defines any object of value inside the game, which enables the
2.1 Software Design Patterns player to achieve the game objectives; like (lives, health,
Design patterns are widely used in software engineering, as they
weapons, hints, maps, etc.).There are other formal aspects but are
help developers to understand the design and architecture used in
not included to the current framework[8].
a certain code. In addition, they help to understand the
implemented code itself and to analyze the behavior of this code 2.2.2 The dramatic aspects
at run-time. Software engineers design systems before Dramatic aspects refer in general to the game story and its
implementation using design patterns to ensure that the system characters. It refers to the aspect that adds the emotional
will be reusable, enhance its readability, and simplify the code [1]. dimension of the gameplay, and give a meaning to all formal
Due to the different nature of video games, the proposed elements, therefore; help engaging the player [8]. The game
framework in this paper will include only some of GoF DP[2]; characters are the objects which take role in the game story and
one creational pattern, and three behavioral patterns, namely, the game play.
prototype, state, strategy and observer DP. However, other design 2.2.3 The dynamic aspects
patterns have been utilized in game development in [6]. The dynamic aspects refer to the gameplay and game emergence
2.1.1 The Prototype design pattern [8].The gameplay aspect refers to the integration of game
Prototype design pattern belongs to the creational DP family. The elements that makes them “fit together to form playable
main idea of this pattern is to create new objects from an existing systems”[8].There are other aspects in Fullerton framework[8],
(prototype) object by “cloning” (GoF) [2]. The reason of but we only cited the elements which we build on.
choosing this DP for our framework is that, in many games, it is 2.3 Related work
quite common to need to create game objects with same attributes; The use of GoF design pattern in game development is relatively a
which could be enemies, playing or non-playing characters. This new area of research. However, few studies investigated this
48
topic[7, 11, 12]. Kounoukla et al. [12] studied the implementation these studies were done on the micro scale, where examples are
of game mechanics using GoF design patterns, through proof-of- given for certain game situations, and the use of DP on it. Only in
concept. They defined the game mechanics’ elements that can be [12], the authors proposed the use of GoF DP on game mechanics,
candidate for implementation using GoF DP, in the context of with again examples of certain game scenarios. To the best of the
OSS games. The study proposed to use the template method, author’s knowledge, there are no studies proposed the integration
strategy, visitor, composite, state, observer and abstract factory of GoF DP, with any of the game development frameworks.
patterns; for turn based games, AI agents and character Therefore, our proposal will be the first contribution in this area,
movements, power-Ups , the game world, the levels and varied which can work on the majority of games, regardless of its size
game play, game progress indicators, units, game mechanics and the challenges in its implementations. Furthermore, the
respectively [12]. Simple class diagrams have been proposed for selected DP to be added to our framework did not show any
each of those cases. The authors have also reported the number of negative impact on the software quality; when implemented, in
occurrences of each of those patterns in the OSS games, and the traditional or video games software [4, 7].
strategy, state, and abstract factory have been found [12]. Regarding the selected game design framework (Formal,
In another study[7], the authors went a further step and studied the Dramatic, Dynamic), it is one of the most comprehensive, yet
relationship between applying design patterns and the frequency simple and intuitive to understand and implement, regardless of
of game defect, as well as the debugging efficiency. Studying 97 the game size or type [8]. The objective of our framework is to
open source games of various sizes written in java, they selected find a general guidance, when and what to use from GoF DP with
the software that had more than 10 bugs in each of its versions. game development frameworks. This could be very helpful for
Analysis and descriptive statistics have been used. It was designers, as till now, there is no recipe for what and when to use
concluded that “there are certain characteristics of specific design DP with game development.
patterns, which influence defect frequency” [7]. In particular, they
have concluded that the more instances of the DP like composite, 3. Proposed framework
prototype, observer, abstract factory, proxy, state and strategy are The proposed framework builds on Fullerton [8] game design
used, the less the number of bugs found in the game software. The framework; which defines formal, dramatic and dynamic aspects
authors attributed that to the simplicity of those pattern’ structure of a game. The objective is to integrate that framework with part
and implementations [7]. This is not the case for the adapter and of GoF design patterns; namely state, strategy, prototype, and
template method patterns, where the more instances of these observer. However, the framework can be extended to other game
patterns found, the more the number of bugs reported in the design frameworks like [9], as the major components are similar
software [7]. in both, as well as other GoF DP.
Concerning the bug fixing, the authors concluded that some The DPs chosen in our proposal belong to the creational and
patterns are correlated to bug fixing rate, like singleton, adaptor behavioral patterns as suggested by GoF[3], and can work with
and decorator patterns. However, the use of the observer pattern large, complex games, as well as small size game, as the ones
improves the debugging process[7]. developed by students taking the first game design &
development module. Those games normally have at least two
2.4 Study Motivation levels, and each level has at least two scenes. The chosen DPs can
The area of game design and implementation is a relatively new also work with different game engines like XNA or Unity, as well
research area, due to the special nature of games. It has been as the games which are developed from scratch, including the
shown in the literature that using GoF design patterns has positive game engine; but with possibly using more advanced DP.
effect on software maintainability and usability including Furthermore, based on earlier studies; the selected DP for our
games[7, 10, 12]. However, the application of GoF patterns in framework, did not show negative effect on the developed
Figure 1.The proposed framework integrating game design framework and design patterns.
49
software quality in traditional software applications[4, 7]. As a future extension of this work, a practical study should be
In general, the use of more design patterns with games can relate conducted to evaluate the effectiveness of the selected design
to the game size in terms of number of levels, number of players, patterns on the game quality, according to the predefined software
number of enemies, number and type of strategies employed by quality metrics, namely; size, complexity, coupling and cohesion
enemies and players. The game genre has also an effect, where of the developed software.
adventure and strategy games can benefit more from patterns, References
rather than other game genres. In the following paragraphs, the [1] Mayvan, B.B., Rasoolzadegan, A. and Yazdi, Z.G., 2017.
proposed frame work will be explained. The State of the Art on Design Patterns: A Systematic
3.1 Formal elements and behavioral DP: Mapping of the Literature. The Journal of Systems and
As shown in Figure 1, formal elements can be implemented using Software, 95. 93-118.
state, strategy and observer patterns. The state and observer [2] Gamma, E., Helms, R., Johnson, R. and J. Vlissides, 1995.
patterns can be useful for the game resources of different types, Design Patterns: Elements of Reusable Object-Oriented
including also non playing characters (NPC).Game rules and Software. Addison-Wesley Professional, Reading 1995.
procedures (the decision taken by a player based on rules) can be [3] Ampatzogloua, A., Charalampidoub, S. and Stamelosa, I.
implemented using strategy and state patterns. Furthermore, 2013. Research State of the Art on GoFDesign Patterns: A
player’s interaction patterns element can be implemented using Mapping study. The Journal of Systems and Software, 86.
the observer, strategy and state patterns, as well as interaction 1945-1964.
between the players, enemies, and NPC.
[4] Fatimah Mohammed Alghamdi and M.
3.2 Dramatic elements and creational DP: RizwanJameelQureshi, 2014. Impact of Design Patterns on
Dramatic elements [8] can be implemented using creational DP Software Maintainability. I.J. Intelligent Systems and
[8, 13]. In particular, it was noted that in certain game types; some Applications, 10. 41-46.
characters and enemies are designed to be similar in the
[5] Ampatzoglou, A. and Stamelos, I., 2010. Software
appearance and behavior to a large extent. Therefore, prototype
Engineering Research for Computer Games: A Systematic
DP can be used for implementing such part, to allow the
Review. Information and Software Technology, 52 (9). 888-
characters to be “cloned”. Furthermore, state DP can be used to
901.
control character or enemy animations.
[6] Nystrom, R., 2014. Game Programming Patterns, 2014.
3.3 Dynamic elements and behavioral DP: [7] Ampatzoglou, A., Kritikos, A., Arvanitou, E.-M., Gortzis,
As mentioned in Section 2.2.3, the dynamic aspects refer to the
A., Chatziasimidis, F. and Stamelos, I., 2011. An Empirical
gameplay, which makes the game elements “fit together to form
Investigation on the Impact of Design Pattern Application on
playable systems”[8]. Based on that, several behavioral DP can be
Computer Game Defects. In 15th International Academic
used to implement the dynamic elements. In particular, the state,
MindTrek Conference: Envisioning Future Media
strategy and observer DPs are crucial for implementing the
Environments, MindTrek 2011, (Tampere, Finland, 2011),
gameplay of many game types and sizes, and perhaps the
ACM, 214-221.
prototype as well. This depends on the nature of game emergence
as well as the game story. The proposed framework is shown in [8] Fullerton, r., 2018. Game Design Workshop: A Playcentric
Figure 1. Approach to Creating Innovative Games. CRC Press, 2018.
It is important to remember here that the objective is to have a [9] Gibson, J., 2014. Introduction to Game Design, Prototyping,
framework that can be applicable to most of the game types, and Development. Addison-Wesley Professional, 2014.
therefore, have game design and implementations, which are less [10] Qu, J., Song, Y. and Wei, Y., 2013. Applying Design
prone to errors, easy to understand, expand and maintain, even by Patterns in Game Programming. In The International
junior designers and developers. Conference on Software Engineering Research and Practice
4. Study Limitation (Athens, 2013).
Even though the framework proposed here is simple and can be [11] Ampatzoglou, A. and Chatzigeorgiou, A. 2007. Evaluation of
generalized and expanded, yet a practical evaluation study is Object-oriented Design Patterns in Game Development.
needed to test the effectiveness of that framework. This can be Information and Software Technology 49. 445–454.
achieved by comparing the quality of several games designed and [12] Kounoukla, X.-C., Ampatzoglou, A. and Anagnostopoulos,
implemented with; and without using the proposed framework. K., 2016. Implementing Game Mechanics with GoF Design
5. Conclusions and future perspective Patterns. In 20th Pan-Hellenic Conference on Informatics,
Design patterns are not universally good or bad as the previous, (Patras, Greece, 2016), ACM.
empirical studies concluded. However, and till now; there is no [13] Kelle, S., Klemke, R. and Specht, M. 2011. Design patterns
method to identify which of design patterns improve the software for learning games Int. J. Technology Enhanced Learning, 3
maintainability and which of them has negative effect on (6). 555-569.
traditional software systems, let alone video games. Therefore, a
novel framework for selecting and using design patterns for game
development framework is proposed. The framework is simple,
and can be extended in size and scope.
50