0
\$\begingroup\$

Question about game engine object oriented design.

Let’s say I have an engine with a main loop, and many handlers that will be executed by the main loop every time on next iteration of main loop. So every handler will be invoked frequently, and can do necessary game logic that needs to be run in a loop.

Having many handler of the main loop, I can implement modular system, and separate different concerns in different handlers.

Every of this modules not necessary will have a visual representation on the scene, it just any process that should run in main loop.

What is name convention for such classes. I need to give some suffix for class. What is industry standard for naming class prefixes like that?

——

I saw few examples like:

while(true) {
   update(…)
   render(…)
}

Instead I would like to do something like:

loopHandler = [
  new UpdateGamePlayerPosition(),
  new UpdateAiPosition(), 
  …
  new RenderScene(),
  new SendNetworkUpdates()
]

while(true) {
   for(loopHandler in handlerCollection) {
      loopHandler.execute(gameLoopEvent)
   }
}

——

The reason why I needs suffixes, it came from my web/enterprise experience. Let’s say I have a Player in the game, now I need to have a PlayerLoop to refresh his PlayerEntity state, also PlayerSceneObject for rendering, also I may need to transfer it over network, so I will have PlayerTransferObject, also I might want to save into save game file PlayerSaveObject.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Why do you need to prefix those classes? \$\endgroup\$
    – Vaillancourt
    Commented Sep 2, 2021 at 0:14
  • \$\begingroup\$ Sorry, suffix, not a prefix. To indicate a layer. Like here: springfox.github.io/springfox/javadoc/2.7.0/springfox/petstore/… \$\endgroup\$ Commented Sep 2, 2021 at 1:24
  • \$\begingroup\$ I think you are doing something idiosyncratic that does not have an associated "industry standard" name. \$\endgroup\$
    – DMGregory
    Commented Sep 2, 2021 at 1:32

2 Answers 2

1
\$\begingroup\$

Although all game loops have the same purpose, they're not all written in the same way; the way you're coding your loop is not an industry standard.

Thus, there is no industry standard for naming those classes.

The "typical" industry standard in this case is naming those classes in a way that you and your team easily and rapidly recognize and understand their purpose and intention.


If you think you need a suffix to organize your classes, you might as well consider using the concept of "namespace" and move all the classes that are intended for the same purpose into this namespace.

\$\endgroup\$
3
  • \$\begingroup\$ The reason why I needs suffixes, it came from my web/enterprise development. Let’s say I have a Player in the game, now I need to have a PlayerLoop to refresh his state, also PlayerSceneObject for rendering, also I may need to transfer it over network, so I will have PlayerTransferObject, also I might want to save into save game file PlayerSaveObject. \$\endgroup\$ Commented Sep 2, 2021 at 14:00
  • \$\begingroup\$ Your concern seems akin to premature optimization. If you can right away see ambiguity in the names you use, then fix them now. Otherwise, wait until the issue pops up and fix that specific issue instead. Modern IDEs offer nice means to rename stuff. \$\endgroup\$
    – Vaillancourt
    Commented Sep 2, 2021 at 14:09
  • \$\begingroup\$ I think you might also want to investigate component-based solutions, where instead of having a dedicated XSceneObject for rendering each and every X in your game, you have something like a reusable SpriteRenderer or MeshRenderer component that's agnostic to what kind of object is being rendered. You can then achieve specialized behaviour, not solely by creating new specialized classes, but by composing these reusable components, using them like building blocks to assemble into a variety of different entities. \$\endgroup\$
    – DMGregory
    Commented Sep 2, 2021 at 14:12
0
\$\begingroup\$

I didn’t find any naming convention yet, but I’ve used Loop as a suffix:

  • UserInputLoop
  • PlayerLoop
  • AiBotsLoop
  • RenderingLoop
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .