Guys, you're both right.

We don't actually know what meppum's exact requirement is. Does the code
really have to strictly follow that exact design pattern? Or would it be
possible to use a simpler, more idiomatic approach to achieve the same
goals?

Either way, it doesn't hurt to get the original code working, so Ariel's
patch is just what's needed there.

But Henry, I did have a similar reaction to the code as you: "Sure, you can
get this to work, but is it really necessary? There are much simpler ways to
do the same thing."

Meppum, can you clarify what the real requirements are, so we will all be a
little less confused? :-)

Thanks,

-Mike

> From: Ariel Flesler
> 
> He is probably showing a dummy example to represent a more 
> complex, real situation.
> So there's no sense in judging the exact code he posted.
> 
> That was the solution to his problem, that he should be able to adapt.
> 
> If you want to suggest a whole new approach to, what you 
> suppose, he needs.. then propose it directly to him, not by 
> judging my fix.

> > From: Henry
> >
> > While that answer would be superficially effective (in the sense of 
> > resulting in code that would behave as specified) it is a stupidly 
> > inefficient approach, and so not something that should be 
> > suggested as a correction to the original code.
> >
> > ...
> >
> > So the above would be better as:-
> >
> > function myFunction(){
> > }
> > myFunction.prototype.foo = "hi";
> > myFunction.prototype.foo2 = function(){
> >     this.foo = "hi back";
> > };

Reply via email to