AS3 : OOP thought process [ inheritence, composition, type casting, Null, void ]

My study of “Essential Actionscript 3.0 ” continues…

final :
1. no inheritence
2. no override
3. executes faster ( future version of flash player may execute “final” and “non-final” methods at same speed )
4. hides a class’s internal detail

Note : There is a major opinion difference exists, between developers, whether to make things “final” or not on the basis of basic OOP priniciple.
[OOP says : An instance of a subclass can be used anywhere an instance of its super class is expected.]

Relationships : is-A, has-A, uses-A

Composition is favoured over Inheritence as an application design strategy.

1.Changing code that uses composition has fewer consequences than changing code that uses inheritence.
want to use service of another class : use composition
2. Code based on inheritence often executes faster than code based on composition.
want to use polymorphism : consider inheritence

DataType : Automatic runtime-conversion is known as “coercion” (conversion).
as : “Date” and “Array” type casting is done with “as” operator ( myVar as Array; ) rather than usual type casting like “dataType(Expression);”
is : “is” is used to check the datatype of an Object. ( if( msg is String ) )

“Null” and “void” are data types
“null” and “undefined” are values
“void” data type objects has got one and only value “undefined”.
“Null” data type objects has got one and only value “null”.

“null” value represents the absence of data with a specified type annotation set to anything but Boolean,int,uint,Number.
“undefined” value represents the absence of data without a specified type annotation. “undefined” value also represents the complete absence of a variable or method on an object whose class is defined as “dynamic”.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s