Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-26-2007, 06:02 AM   #1
drexle
...
 
Join Date: Mar 2005
Posts: 248
Default var x:Superclass = new Subclass(); ... appropriate?

I'm curious if it's appropriate to do something like in the subject header:

var x:Superclass = new Subclass();
drexle is offline   Reply With Quote
Old 09-26-2007, 06:06 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

yes, in fact it is one of the key principles of OO: Program to the interface and not the implementation.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 09-26-2007, 06:33 AM   #3
drexle
...
 
Join Date: Mar 2005
Posts: 248
Default

Awesome!

I'm following the crowd and reading over the Head First Design Patterns book and I'm playing around with the examples in the first chapter. I wanted to make characters who could equip "equipment" objects regardless of what subclass of equipment it might be (hacksaw subclass, pastry subclass, tophat subclass, etc). I just wanted to make sure I was interpreting things correctly.
drexle is offline   Reply With Quote
Old 09-26-2007, 06:35 AM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

yup, of all the things I've learned that....there is a reason while that is the first rule. It is essential to polymorphism.

good luck with your reading. I read the head first book, but I don't remeber the examples you are giving....
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FlvPlayBack-component... Electrix Components 10 05-28-2008 06:04 PM
Don't Repeat the Arraycontent ashishkummar2 ActionScript 2.0 8 07-07-2007 11:36 AM
[AS2] Game Over...now what? notaflasher Gaming and Game Development 15 06-13-2007 04:24 AM
Problem with a for...in loop in a for...in loop VictoriaWelby ActionScript 2.0 2 04-09-2007 11:20 PM
Variable Scope Issues.. slalonde44 ActionScript 2.0 1 03-02-2007 01:52 AM


All times are GMT. The time now is 09:05 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.