The following is just my opinion, but it has held up well throughout the years.
Use encapsulation, not inheritance. Just because your object needs to send events does not make it an event emitter. At most it means you should add an `emitter` property. Is it really that hard to type `myobject.emitter.on` vs `myobject.on`? There is no definitive rule about where properties belong, but generally if you're fretting about complex class hierarchies you have gone too far. Even if you want Javascript to behave like Java, good Java code uses interfaces, not inheritance. On Thu, Jan 31, 2013 at 12:10 PM, Diogo Resende <[email protected]>wrote: > +1. Java people should really read and learn about OOP before associating > it to just classes.. > > -- > Diogo Resende > > On Thursday, January 31, 2013 at 19:48 , Geerten van Meel wrote: > > In case you are wondering why you don't recieve a lot of love in this > topic, let me elaborate: You are trying to fix something which is not > broken, at least in the eyes of many that are reading this. You are trying > to make JavaScript more like Java by turning everything into classes. > > Things are not broken though. The CommonJS (~npm) and AMD (browser) > approaches are actually quite elegant in their respective environments and > allow to encapsule simple functionality into a module without considerable > overhead. While it is good that you gave something like this a decent > amount of thought, you may be barking up the wrong tree here by turning > JavaScript into Java. > > On Wednesday, January 30, 2013 12:15:20 PM UTC+1, [email protected]: > > Hi, Senior JS fans > > I am a senior Java/JS developer about 12 year+. I recently wrote a > specification named JCS. The goal of this specification is replace the > currently popular of CommonJS or RequireJS for building the next generation > of full object-oriented class system. The first implementation of the > specification is JSDK1.0: https://github.com/fch415/jtdk > > > The specification is still evolving, welcome you suggest improvements! > > JCS 1.0 document: https://github.com/fch415/jss/** > blob/master/%231/jss%231_jcs_**en.md<https://github.com/fch415/jss/blob/master/%231/jss%231_jcs_en.md> > > Sincerely, > FengChun > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
