Game Development Reference
In-Depth Information
Custom Data Structures
In the event that you need even more functionality than these
built-in classes afford, you can of course extend any of them to a
new class. One important thing to remember about all of these
classes is that they are dynamic , allowing them to have any proper-
ties added to them at runtime. In order for your subclasses to
inherit this same functionality, they must also be dynamic. We
look at an example of a custom data structure (though not an
extension of any of these) in Chapter 14.
Part 5: Keep Your Comments
to Everyone Else!
Probably the single-most overlooked task of any developer, particu-
larly in crunch time, is commenting code. Comments are invalu-
able when handing code off to another developer, or even just
returning to it later. The convention is usually
the more com-
ments, the better,
but this can actually sometimes make code
harder to read. Here are a few tips for commenting your code.
t comment the obvious: If a line of code simply declares a
variable called
it should be fairly self-explanatory what
is happening; extra comments like
simply clutter up the code.
Be thorough, but concise: Explain as much as you can in as few
words as you can; if comments break onto multiple lines or trail
off so the reader has to scroll sideways, it breaks the overall
flow of the code.
When possible, use the ASDoc formatting standards of commenting
classes: This primarily means creating comment blocks in a specific
format (established by Adobe) just prior to properties and methods;
by creating your comments this way, documentation can easily
be generated for your code and many script editors such as
FlashDevelop can use the comments in tooltips to help remind you
of proper syntax (see below for example).
Keep comments correct: This may sound like an unnecessary
statement, but if you write your comments for a piece of
functionality and later than functionality has to change, your
comments must be updated, too.
Use header comment blocks: Sometimes a simple, complete
spread out over a file; if you can explain everything that a class
does in a few sentences at the top of a file, don
Here is an example of ASDoc formatting
more precise standards
and style guides are available on Adobe
s Web site. This is taken from
a SoundEngine class, which we will look at in a later chapter.
Search Nedrilad ::

Custom Search