Archive for November, 2009

Beware of Getters and Setters

Tags: , , ,

Getters and setters are indeed a very nice feature of AS3. They eliminate a lot of typing (.x versus .getX()) shaves off five characters and removes the need to hit the shift key for X) and make getting and setting values much more natural by disguising the fact that you’re actually calling a function. The downsides include the difficulty (impossibility?) of getting a Function variable for them and lower performance. This article is about that performance hit. EDIT: added a plain getter test)

Read the rest of this article »

13 Comments

Simple Regular Expressions

Tags: , ,

Lately I’ve been seeing a lot of AS3 code that uses regular expressions where the normal methods of the String class would seem to suffice. It seems common among programmers of all languages to catch on to new trends even when they do not particularly apply to the task at hand. For example, a new C++ or Java programmer may use templates or generics even for classes where only one data type will likely ever be used. I don’t know why programmers do this and I won’t attempt to tackle such a topic. Instead, I’ll do a test to show why this is a bad idea from a performance perspective.

Read the rest of this article »

2 Comments

Flexible If Syntax

Tags: , , ,

This article is sort of a follow-up to my article on Flexible Loop Syntax. This was reported to my by a coworker who spotted the anomaly. I guess he had done with if the same sort of thing that I had done with for. Read on for a little insight into how the comma operator interacts with the if statement.

Read the rest of this article »

5 Comments