GameMechanicExplorer-HaxeFlixel icon indicating copy to clipboard operation
GameMechanicExplorer-HaxeFlixel copied to clipboard

Standardize comments and optimizations across all examples

Open gamedevsam opened this issue 10 years ago • 1 comments

Each example should be as complete and straight forward as possible (including ample use of comments). Also, we should strive to use the best coding practices we can think of, considering users are likely to use this code as the framework for their own projects.

Watch this video, and this video, to learn more about the concept of "clean code", to learn some good coding practices.

In general:

  • Keep comment capitalization consistent.
  • Comment everything.
  • Avoid branches that just return if the condition is false at the top of a function, move that check upwards, and branch before calling the function (see example here).

We should keep this list updated, and turn it into a contributing guide, for those interested in adding their own examples.

gamedevsam avatar May 05 '14 19:05 gamedevsam

"Commenting everything" is dangerous. You'll quickly run into comments that don't add any value, they just rephrase what the code already says and are pretty useless. Example:

// make the block immovable
groundBlock.immovable = true;

Gama11 avatar May 06 '14 08:05 Gama11