Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Beautiful code - part 2 - top down design

Beautiful code - part 2 - top down design

Norman Barrows
Gamedev info · · 1 min read
2,410 2
Beautiful code - part 2 - top down design

an example of beautiful code.

this was a result of top down design. IE high level routines fist, lowest level routines last.

first, the algo was written in comments in english.

then the highest level code was written, defining the lower level routines and their APIs as it was written, before ever actually defining the lower level code. so the high level code determined that there would be a camera_can_see_target function, and that it would take the index of a target as a parameter. the actual camera_can_see_target function was written later. the high level code defined what the lower level APIs would be. the highest level code was written to be as english-like as possible.

this is the high level code that started this process (from SIMSpace 8.0):void draw_targets(){// for each target, if in vis rng and pass frustum cull, add to render queue// vis rng = 100x tgt size = 200x tgt.radint a;for (a=0; a
clarity, simplicity, and read-ability are hallmarks of beautiful code.

Discussion

Loading comments...