On 2/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi
I'm cuurrently refactoring some code in a project with lots of extended classes.

What is the recommended practice in declaring static vs non-static (private 
static vs private)
variables?
Should they be declared in both the super and sub classes?

My goal is to avoid any redundant code.
Thanks

Note:
----
class SuperClass {
   public static var CONSTANT:String = "SuperClass";
   public function toString():String {
       return CONSTANT;
   }
}
----
class SubClass extends SuperClass {
   public static var CONSTANT:String = "SubClass";
}
----
var obj:SubClass = new SubClass();
trace(obj.toString());
// Traces "SuperClass".
----

Overriding static variables does not work as you might expect. To get
this to work correctly, the variable would have to be non-static.

Other than that, you should never have to redundantly add anything to
the subclass. If the superclass and the subclass both use a string
variable called "name", just declare it in the superclass--there's no
point at all in redeclaring it in the subclass. The whole idea of
inheritance was created to avoid just that type of redundancy.

--
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
--
The Dinosauricon: http://dino.lm.com
Parry & Carney: http://parryandcarney.com
ISPN Forum: http://www.phylonames.org/forum/
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to