Guys, thank you for pointing me to erik's weblog.

What is the proposed strategy for defining methods which should be
available for all classes, created by "var MyClass = new Class({});"
schema?

If I define these generic methods by "Object.extend({ genericMethod :
function(){}};" way, they aren't available for any objects. For
example anObject = new Object(); wont't have these methods.

Should I define these methods in every MyClass and invoke the
Object.genericMethod( this )? This is the way to go ahead? Or should I
define my own generic base class?

Thank you,
Zsolt

On dec. 6, 00:43, Aaron Newton <[email protected]> wrote:
> I hear cpojer outlawed that practice.
>
>
>
> On Sun, Dec 5, 2010 at 5:46 PM, Arian <[email protected]> wrote:
> > What you are doing is implementing new methods in Object.prototype.
>
> > You really shouldn't use Object.implement!
> > There's plenty info on the internet that explains this, for example
> >http://erik.eae.net/archives/2005/06/06/22.13.54/
>
> > You can use Object.extend, for example like:
>
> >https://github.com/mootools/mootools-core/blob/master/Source/Types/Ob...
> > The methods/functions can then be used as Object.equals(firstObject,
> > secondObject);
>
> > On Dec 5, 7:27 pm, ZsZs <[email protected]> wrote:
> > > Hi,
>
> > > I want to extend the Object with some methods, like getClass(),
> > > equals(), compare(), etc. Here is an example implementation:
>
> > > Object.implement({
> > >    getClass : function() {
> > >       var constructorName = this.constructor.toString();
> > >       return constructorName.match( /function (\w+)\(.+/ )[1];
> > >    }
>
> > > });
>
> > > This code runs fine in FireFox, Chrome, but fails in IE. After a long
> > > debugging I found that the issue is related to:
>
> > > // IE purge
> > > if (window.attachEvent && !window.addEventListener)
> > > window.addListener('unload', function(){
> > >         Object.each(collected, clean);
> > >         if (window.CollectGarbage) CollectGarbage();
>
> > > });
>
> > > The concrete error : "attached[events].keys is null" in
> > > removeEvents(); in line: 4062 of mootools-core-1.3.js
>
> > > Please let me know how can I overcome on this problem.
>
> > > Thanks,
> > > Zsolt

Reply via email to