On Wednesday 24 May 2006 22:08, Ryan Gahl wrote:
> If there is functionality in the base class's constructor that, for
> instance, prepares the object instance (initializes an XHR object, etc..),
> or otherwise must execute, then use an instance. This is yet another "use
> what works for the situation" things... I use both methods frequently.
>
> I also use the instance method from within the subclass constructor
> sometimes (vs. from the Object.extend top portion), for instance if both
> constructors take arguments and the subclass needs to somehow calculate the
> value of one of the base class constructor's arguments.
>
> Object.extend(SubClass.prototype, {
> initialize: function(id, options) {
> //do some stuff that determines the value of "foo"
> Object.extend(this, new Testing(id, options, foo));
> }
> });this is great, this is exactly the kind of reply I was hoping for :) I never thought of having the initialize method instantiate the 'parent' class, that's nifty. Although I think you have the Object.extend backwards, i would think you'd do: Object.extend(new Testing(whatever), this); well, I guess it would just depend on the situation. Thanks again for the great reply :) -Jeremy
pgpgZu1H76ZLe.pgp
Description: PGP signature
_______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
