Edit
I improved the code again and created another question (the final one):
Edit
I improved the code again and created another question (the final one):
To those looking this question first I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done and I received lots of help from some of the good guys here :) The links above tell the whole story.
from @tkelleheFrom @tkellehe's and @SirPython@SirPython's answers:
from @tkelleheFrom @tkellehe's answer:
- I remove all _vars
_var
s from parameters, all private vars will use it from now on. Just there aren't any at the example at the moment. - I used Object.define
Object.define
in ViewtheView
classes so I don't need to use Object.keysObject.keys
anymore. - Because I reverted to this, new and prototype usage, override function doesn't work/it's not needed anymore. So I had to use Class.prototype.method.call
Class.prototype.method.call
instead and I don't need a Basebase class anymore or a salvage to not using new. At least at this point. - I know loading within context is important and I'll use it. I just don't think it's needed for this example. But that library loading function was really cool. Thanks.
- I don't like using Class.prototype.method.call
Class.prototype.method.call
. It's too long... and too clumsy. Is there a better solution for calling the superior method? Can you make override function work again in this format? - In ViewCallthe
ViewCall
and ViewBaseViewBase
classes, it would be better if I could put this.parse()this.parse()
in ViewBasetheViewBase
class in such a manner that it get called in the moment ViewClassViewClass
was instatiated. But I couldn't find a way to do it. Someone hasDoes anyone have an idea on how I could do this?
Better ? comments ?
To those looking this question first I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done and I received lots of help from some of the good guys here :) The links above tell the whole story.
from @tkellehe and @SirPython answers:
from @tkellehe answer:
- I remove all _vars from parameters, all private vars will use it from now on. Just there aren't any at the example at the moment.
- I used Object.define in View classes so I don't need to use Object.keys anymore.
- Because I reverted to this, new and prototype usage, override function doesn't work/it's not needed anymore. So I had to use Class.prototype.method.call instead and I don't need a Base class anymore or a salvage to not using new. At least at this point.
- I know loading within context is important and I'll use it. I just don't think it's needed for this example. But that library loading function was really cool. Thanks.
- I don't like using Class.prototype.method.call. It's too long... too clumsy. Is there a better solution for calling the superior method? Can you make override function work again in this format?
- In ViewCall and ViewBase classes it would be better if I could put this.parse() in ViewBase class in such a manner that it get called in the moment ViewClass was instatiated. But I couldn't find a way to do it. Someone has an idea how I could do this?
Better ? comments ?
To those looking this question first I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done and I received lots of help from some of the good guys here.
From @tkellehe's and @SirPython's answers:
From @tkellehe's answer:
- I remove all
_var
s from parameters, all private vars will use it from now on. Just there aren't any at the example at the moment. - I used
Object.define
in theView
classes so I don't need to useObject.keys
anymore. - Because I reverted to this, new and prototype usage, override function doesn't work/it's not needed anymore. So I had to use
Class.prototype.method.call
instead and I don't need a base class anymore or a salvage to not using new. At least at this point. - I know loading within context is important and I'll use it. I just don't think it's needed for this example. But that library loading function was really cool.
- I don't like using
Class.prototype.method.call
. It's too long and too clumsy. Is there a better solution for calling the superior method? Can you make override function work again in this format? - In the
ViewCall
andViewBase
classes, it would be better if I could putthis.parse()
in theViewBase
class in such a manner that it get called in the momentViewClass
was instatiated. But I couldn't find a way to do it. Does anyone have an idea on how I could do this?