Skip to main content
Included a link to the conclusion
Source Link

Edit

I improved the code again and created another question (the final one):

Simple object-oriented calculator - part 4

Edit

I improved the code again and created another question (the final one):

Simple object-oriented calculator - part 4

deleted 36 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

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_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.defineObject.define in Viewthe View 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.callClass.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.callClass.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 ViewBasethe ViewBase 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 _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 the 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.
  • 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 and ViewBase classes, it would be better if I could put this.parse() in the 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. Does anyone have an idea on how I could do this?
corrected code format
Source Link
Loading
added 15 characters in body
Source Link
Loading
edited tags
Link
200_success
  • 144k
  • 22
  • 188
  • 471
Loading
correct code format
Source Link
Loading
Source Link
Loading