27
H. Saygın Arkan, Murat Açar, Ender Demirkaya 30 December 2010

Aspect-Oriented Design of Game Application

Embed Size (px)

DESCRIPTION

Aspect-Oriented Design of Game Application. H. Saygın Arkan, Murat Açar, Ender Demirkaya 30 December 2010. - Outline. Introduction About Aqua Bubble Object-Oriented Design Applied Patterns Problem Statement Aspect-Oriented Programming Related Work Discussion Conclusion Demo. - PowerPoint PPT Presentation

Citation preview

Page 1: Aspect-Oriented Design of Game Application

H. Saygın Arkan, Murat Açar, Ender Demirkaya30 December 2010

Page 2: Aspect-Oriented Design of Game Application

Introduction About Aqua Bubble Object-Oriented Design Applied Patterns Problem Statement Aspect-Oriented Programming Related Work Discussion Conclusion Demo

2

Page 3: Aspect-Oriented Design of Game Application

The game at issue is “Aqua Bubble”

The requirements are in hand.

Limited Project◦ But good start for Aspect Application

Enhancements to the Project◦ Create & Solve Problems

3

Page 4: Aspect-Oriented Design of Game Application

Familiar Game◦ Shoot Gun◦ Collect 3 same colored bubbles◦ Balls are moving down

Bubbles are coming down with a certain time period.

The time it takes to move decreases with the increasing number of levels

Purpose: Finish all the balls before they came in the turret’s level.

4

Page 5: Aspect-Oriented Design of Game Application

Some sample screenshots...

5

Page 6: Aspect-Oriented Design of Game Application

Already distributed responsibilities to packages, thereby classes

UI includes menu panels and visual items as usual.

Controller does the main operation behind.

6

Two main packages:

Page 7: Aspect-Oriented Design of Game Application

7

•The package diagram is as follows:

Page 8: Aspect-Oriented Design of Game Application

8

•Ui package class diagram

Page 9: Aspect-Oriented Design of Game Application

9

•Controller Package class diagram

Page 10: Aspect-Oriented Design of Game Application

Singleton pattern◦ GameFrame, GameEngine, GamePanel and

ControllerFacade, InGameFacade Facade pattern

◦ Deals with in-game managers as a one-stop solution

Abstract Factory pattern◦ Creation of balls in game is the subject entry

Strategy pattern◦ Balls have specific explosion types.Strategy

smells

10

Page 11: Aspect-Oriented Design of Game Application

Singleton Pattern

11

Exactly one instance is necessary and sufficient

Page 12: Aspect-Oriented Design of Game Application

12

Facade Pattern

Page 13: Aspect-Oriented Design of Game Application

Abstract Factory Pattern◦ Different balls in game are the factory products

13

Page 14: Aspect-Oriented Design of Game Application

Strategy Pattern◦ For different type of explosions that the balls

have.

14

Context ClassContext Class

Interface ViewInterface View

+ findExplosion(ball: Ball)

+ findExplosion(ball: Ball) + findExplosion(ball: Ball)

+ findExplosion(ball: Ball) + findExplosion(ball: Ball)

Page 15: Aspect-Oriented Design of Game Application

High coupling & Low Cohesion

Enhancements = Tangling Code and Crosscutting concerns.

Sound affects are to be happened instantaneously.◦ Will we define sounds for each and every UI object

individually?

Logging mechanim crosscuts at all times.◦ Where are the logs of error handling and in-game controls to

be kept?

Some game add-ons are to be integrated.◦ Additional code to all the classes. What a disaster!

15

Page 16: Aspect-Oriented Design of Game Application

SoundEffect Concern◦ Panel changes, button clicks, ball explosion...

Costly without Aspect, needs update & modification on all button listeners, panel change functions and the related classes.

Logging Concern◦ Tracing all the process from beginning to the end.◦ Provides effective error handling◦ More controllable game process

16

Page 17: Aspect-Oriented Design of Game Application

GameAddOn Concern◦ Functionalities that recurred to the mind.

Graying the panel when game finishes (updating all objects behind)

Changing Ball Colors (gradient, more colorful)

AWTEnforcement Concern AWT use is strictly forbidden.

17

Page 18: Aspect-Oriented Design of Game Application

Sound Effects Aspect Sound Effects Aspect is applied to Panel Changes, Button Clicks, Ball Explosions and Level Ends

18

Page 19: Aspect-Oriented Design of Game Application

Logging Aspect Logging Aspect is applied to the set functions,constructor calls and panel changes.

19

Page 20: Aspect-Oriented Design of Game Application

Game Add-On Aspect Game Add-On Aspect is applied to change the color of all balls to dark gray when the level is finished. Also, ball types shall be re-drawn with different ball images

20

Page 21: Aspect-Oriented Design of Game Application

Game Add-On AspectGame Add-On Aspect

21

Previous implementationNew implementation

Page 22: Aspect-Oriented Design of Game Application

Game Add-On AspectGame Add-On Aspect

22

Previous implementationNew implementation

Page 23: Aspect-Oriented Design of Game Application

AWT Enforcement Aspect AWT Enforcement Aspect ensures that the project keeps it’s package structure. Thus, only UI package classes would use java.awt library and the use of AWT classes in Controller package is prevented

23

Page 24: Aspect-Oriented Design of Game Application

Inside AspectJ documentation, there exists a computer game named Space War by which

we are inspired.

After, we went beyond and made some core changes in the project, such as sound effects and changing the image of bubbles in the game.

24

Page 25: Aspect-Oriented Design of Game Application

AOP stepped into the breach

Aspect discovery and refactoring are the bottlenecks as per usual.

Legacy code, aspect mining has vital necessity all along the migration process.

Manual examination of aspect candidates.

AspectJ is a useful to track pointcuts, weaving etc.

25

Page 26: Aspect-Oriented Design of Game Application

The transition process of a non-modular application into a well-defined aspect-oriented structure is illustrated.

Almost at all levels that the old design congests, the fresh design pioneers the mechanism.

Shortfalls are attached to distinct aspect mechanisms with reference to the ostensible constraints.

Aspect-orientation is worth applying in the cases where the stakeholders do know much about the current system, and see the initiatory steps of migration process.

26

Page 27: Aspect-Oriented Design of Game Application