[Sugar-devel] Object oriented programming in JS

Daniel Narvaez dwnarvaez at gmail.com
Sun Jul 28 15:42:25 EDT 2013


I like the version without helper more too. Thanks for investigating this!


On 24 July 2013 16:37, Manuel Quiñones <manuq at laptop.org> wrote:

> Hi,
>
> I'm looking the best way to do OOP in JavaScript, which we need in
> sugar-web.  I don't mind not doing classical OOP.  I think we should
> aim to do what suits better the JavaScript language: Prototypal
> Inheritance.
>
> Here is Mozilla documentation:
>
> -
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain
> -
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_Revisited
>
> The first article gives an introduction of prototypes.  The latter
> gives a real example of inheritance.
>
> There is also another option, using a helper like stated in:
>
> - http://stackoverflow.com/a/4389429/1178541
>
> I have tried both in a git repo with testscases.  Here is the spec:
>
> - https://github.com/manuq/oop-js/blob/master/src/SuperHero.js
>
> And here are the two implementations:
>
> - https://github.com/manuq/oop-js/blob/master/src/SuperHero.js
> - https://github.com/manuq/oop-js/blob/master/src/SuperHeroWithHelper.js
>
> Now I think the option without helper is better.  Although it seems a
> bit more verbose and nested.  Thoughts?  Any other options?
>
>
> --
> .. manuq ..
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>



-- 
Daniel Narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20130728/17a9eccb/attachment.html>


More information about the Sugar-devel mailing list