Friday, May 29, 2009

Dumb Bugs

Hi. Welcome to Grumbleblog.

I'm a programmer, and I currently code mostly in Actionscript 3.0, Flash's language (a sister tongue to JavaScript). In this blog, I will post info about Actionscript, other languages, and various technical topics that are too arcane for my regular blog.

To start the ball rolling, here's a list of dumb mistakes I frequently make when I'm coding. Though I'll come back here and update the list (as I catch more mistakes), the list will probably only useful to me.

However, I recommend that you make a similar list for yourself. It's useful when you're stuck. Before you start pounding your head against the wall, take a deep breath and check your list.


- typing function when I mean var and vice versa.
EXAMPLE: public var killMyself() : void...

- omitting the underscore prefix on private variables (my convention).
EXAMPLE: private var highscore instead of private var _highscore

- forgetting to make classes public (when they should be).
EXAMPLE: class ISuck... instead of public class ISuck...

- messing up close curly braces.
EXAMPLE: if (true) { while(true) { trace(true) } //missing a close }

- omitting the word "function."
EXAMPLE: private addTwo()... instead of private function addTwo()...

- omitting a var's type.
EXAMPLE: private var name = "Bob" instead of private var name : String = "Bob";

- leaving off var in for loops.
Example: for ( i : int = ... instead of for ( var i : int =...
NOTE: I'm especially prone to this with for-in loops.
NOTE: I also sometimes leave off the type:
for (var i = 0... instead of (var i : int = 0...

- forgetting to call new on classes that are sub objects:
EXAMPLE: o.point = {x:10,y:20}; instead of...
o.point = new Point();
o.point = {x:10,y:20};

- adding an event listener to a Loader to test for load completion. I should be attaching it to loaderInstance.contentLoaderInfo instead.

No comments:

Post a Comment