Smart composition of game objects using dependency injection

  • Authors:
  • Erick B. Passos;Jonhnny Weslley S. Sousa;Esteban Walter Gonzales Clua;Anselmo Montenegro;Leonardo Murta

  • Affiliations:
  • UFF - Media Lab;LCD - UFCG;UFF - Media Lab;UFF - Media Lab;UFF

  • Venue:
  • Computers in Entertainment (CIE) - SPECIAL ISSUE: Games
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

Abstract

Most game engines are based on inheritance of game objects and/or componentization of behaviors. While this approach enables clear visualization of the system architecture, good code reuse, and fast prototyping, it brings some issues, mostly related to the high dependency between game objects/components instances. This dependency often leads to static casts and null pointer references that are difficult to debug. In this article we propose the use of the dependency injection design pattern to safely initialize game objects and lessen the programmer's role in handling these issues both during the prototyping and production phases. Since these dependencies are attributes of game objects and the injection occurs only at the initialization pass, there is no performance penalty at the game loop.