[Sugar-devel] Object oriented programming in JS

Manuel Quiñones manuq at laptop.org
Wed Jul 24 11:05:06 EDT 2013


The spec is here, really:

https://github.com/manuq/oop-js/blob/master/spec/SuperHeroSpec.js

2013/7/24 Manuel Quiñones <manuq at laptop.org>:
> The test runner is here: http://manuq.github.io/oop-js/
>
> 2013/7/24 Manuel Quiñones <manuq at laptop.org>:
>> 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 ..
>
>
>
> --
> .. manuq ..



-- 
.. manuq ..


More information about the Sugar-devel mailing list