<div dir="ltr">I like the version without helper more too. Thanks for investigating this!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 24 July 2013 16:37, Manuel Quiñones <span dir="ltr"><<a href="mailto:manuq@laptop.org" target="_blank">manuq@laptop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm looking the best way to do OOP in JavaScript, which we need in<br>
sugar-web. I don't mind not doing classical OOP. I think we should<br>
aim to do what suits better the JavaScript language: Prototypal<br>
Inheritance.<br>
<br>
Here is Mozilla documentation:<br>
<br>
- <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain" target="_blank">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain</a><br>
- <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_Revisited" target="_blank">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_Revisited</a><br>
<br>
The first article gives an introduction of prototypes. The latter<br>
gives a real example of inheritance.<br>
<br>
There is also another option, using a helper like stated in:<br>
<br>
- <a href="http://stackoverflow.com/a/4389429/1178541" target="_blank">http://stackoverflow.com/a/4389429/1178541</a><br>
<br>
I have tried both in a git repo with testscases. Here is the spec:<br>
<br>
- <a href="https://github.com/manuq/oop-js/blob/master/src/SuperHero.js" target="_blank">https://github.com/manuq/oop-js/blob/master/src/SuperHero.js</a><br>
<br>
And here are the two implementations:<br>
<br>
- <a href="https://github.com/manuq/oop-js/blob/master/src/SuperHero.js" target="_blank">https://github.com/manuq/oop-js/blob/master/src/SuperHero.js</a><br>
- <a href="https://github.com/manuq/oop-js/blob/master/src/SuperHeroWithHelper.js" target="_blank">https://github.com/manuq/oop-js/blob/master/src/SuperHeroWithHelper.js</a><br>
<br>
Now I think the option without helper is better. Although it seems a<br>
bit more verbose and nested. Thoughts? Any other options?<br>
<br>
<br>
--<br>
.. manuq ..<br>
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Daniel Narvaez<br>
</div>