July 2nd, 2008
While working on a recent project, I had the pleasure of meeting Rob Rusher (www.robrusher.com), founder of the Denver RIA Developers Group.
Among a few other useful items, I learned from Rob that setting a Repeater control’s recycleChildren property to true will optimize a Repeater’s performance in certain situations: namely when not all items within the repeater are immediately visible.
More elegantly put: “The recycleChildren property is a boolean value that, when set to true, binds new data items into existing Repeater children, incrementally creates new children if there are more data items, and destroys extra children that are no longer required.” - Quoted from Flex Application Performance: Tips and Techniques for Improving Client Application Performance
Tags: Denver, performance, recycleChildren, Repeater, RIA
Posted in Best Practices | 4 Comments »
June 29th, 2008
It is sometimes useful to be able to define a class that is completely static in nature. In other languages (e.g. C#) it is possible to define a static constructor that can take care of initializing any variables on a class the first time a static property is referenced or a static function is invoked.
ActionScript does not have the notion of a static constructor, however, and so I offer this example as a solution. Consider the following example:
public class Formatters {
public static var dateFormatterShoreDate:DateFormatter = new DateFormatter();
private static var _isInitialized:Boolean = initialize();
private static function initialize() : Boolean {
dateFormatterShoreDate.formatString = "M/D/YYYY";
}
}
In this example there are two static properties defined. When the static property ‘dateFormatterShortDate’ on this class is referenced in a piece of executing code, all static properties are initialized which forces the initialize() function to be invoked. In effect, the initialize() function serves as our static constructor because it is executed before the value of dateFormatterShortDate is returned to the executing code.
This particular example may not prove to be extremely useful, but the convention is sound and can be applied in other situations to provide the same results as a static constructor.
Tags: constructor, static
Posted in ActionScript | No Comments »
June 29th, 2008
Enumerations are a very convenient language construct that lack any direct support in ActionScript.
There are, as I see it, two seperate ways to define a class in ActionScript with Enumeration-like features, but each has its advantages and disadvantages:
1. Class with static constants of type String or int/Number. Look at the following example:
public final class Days {
public static const SUNDAY:int = 1;
public static const MONDAY:int 2;
public static const TUESDAY:int = 4;
...
}
One possible advantage with this type of enumeration is that if each value is given an appropriate value (some integer multple of 2^n), then the values can be used as arguments to bit wise operators as in the following example:
var daysOff:int = Days.MONDAY | Days.WEDNESDAY | Days.FRIDAY;
One possible disadvantage with this type of enumeration is that a function can’t be defined to return a value of this type. Instead a function would have to return an integer or Number which works, of course, but falls short of the strongly typed solution a true enum type often provides.
2. Class with static constants that are the same type as the Class itself. Look at the following example:
public final class Days {
private var _value:int;
public static const MONDAY:Days = new Days(1);
public static const TUESDAY:Days = new Days(2);
...
public function Days(value:int):void {
_value = value;
}
}
This enumeration-like class is probably the closest we can get to a true enumeration, but doesn’t provide us with the ability to use its values as arguments for bitwise operations. This is, however, not always a requirement!!
In summary, I believe type #2 above is the best solution for defining an enumeration-like class in ActionScript. If you DO need the ability to pass multiple enumeration values as a single parameter to a function, then solution #1 might be a viable alternative.
Tags: Action Script, ActionScript, enum, enumeration, enumerations, enums
Posted in ActionScript | No Comments »
June 28th, 2008
A friend of mine recently forwarded this quote to me. It is one of the most succinct ways of expressing what I believe to be one of the most important tenants of software development:
“Sound requirements analysis is the single biggest contributing factor to the success of a web or software project, no matter what software methodology you choose to use, Agile or otherwise. This has been studied and verified over and over again for decades. Sound requirements are the foundation on which group planning, effective decision making, collaboration, and good design all rest. Without sound requirements, anything but the most trivial project will be wildly inefficient. Most will careen out of control. None will deliver definable outcomes, or meet predictable estimates for schedule, budget, or quality.” - Spire Media
Tags: Best Practices, requirements, software development
Posted in Best Practices | No Comments »