they're both eager, though, aren't they?
the only difference is that everything is instantiated in the first
method of the class rather than in the class head
a
On 11 Mar 2008, at 18:10, Mark Lapasa wrote:
Either way to me is a non-issue.
However, it is an issue if I want to implement lazy instantiation.
That is, instantiating objects only right before you need them.
Thus, in your first example, the bulk of instantiation occurs up-
front.
Lazy instantiation .... http://www.javaworld.com/javaworld/javatips/
jw-javatip67.html
-mL
Allandt Bik-Elliott (Receptacle) wrote:
hi
just a semantic question really
when writing your classes, would you only declare variables in the
class and assign variables later or would you assign values
straight away if you had them?
so for instance, would you...:
package com.receptacle.timeline
{
//package imports
import flash.display.Sprite;
internal class Class extends Sprite
{
// class variable declarations
private var cp:CommonProperties = new CommonProperties();
private var commonY:uint = cp. commonY;
private var commonCopy:String = cp.commonCopy;
private static var title:String = "Title";
private static var subtitle:String = "Subtitle";
public function Class()
{
myFunc1();
}
private function myFunc1()
{
trace ("function ran");
trace ("commonY is "+commonY);
trace ("commonCopy is "+commonCopy);
trace ("title is "+title);
trace ("subtitle is "+subtitle);
}
}
}
which works fine but is a little messy at the class level
or would you...:
package com.receptacle.timeline
{
//package imports
import flash.display.Sprite;
internal class Class extends Sprite
{
// class variable declarations
private var cp:CommonProperties;
private var commonY:uint;
private var commonCopy:String
private static var title:String
private static var subtitle:String ;
public function Class()
{
setVars();
myFunc1();
}
private function setVars()
{
cp = new CommonProperties();
commonY = cp. commonY;
commonCopy = cp.commonCopy;
title = "Title";
subtitle = "Subtitle";
}
private function myFunc1()
{
trace ("function ran");
trace ("commonY is "+commonY);
trace ("commonCopy is "+commonCopy);
trace ("title is "+title);
trace ("subtitle is "+subtitle);
}
}
}
which seems cleaner but is more round the houses.
thanks in advance
a
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Notice of confidentiality:
The information contained in this e-mail is intended only for the
use of the individual or entity named above and may be
confidential. Should the reader of this message not be the intended
recipient, you are hereby notified that any unauthorized
dissemination, distribution or reproduction of this message is
strictly prohibited. If you have received this message in error,
please advise the sender immediately and destroy the e-mail.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders