1

I have been using Traits.js and/or JSTraits, but I'm having a lot of difficulty combining OOP and the concept of traits in some instances. Is there a good example showing inheritance, complex object instantiation, and traits?

I would like to avoid builder functions, if possible, and still be able to use 'new Foo()' to construct instances.

JMHNilbog
  • 1,073
  • 1
  • 8
  • 13
  • traits and inheritance don't sit well together. – Raynos Jul 24 '11 at 14:35
  • It's really late answering this Q. But in case someone stumbles over it, I meanwhile did refactor the code of 3 other JavaScript+Trait related Qs, which can be found here [Compostions and mixins in JS](http://stackoverflow.com/questions/41999608/compostions-and-mixins-in-js#43141778), here [Mixins for ES6 classes, transpiled with babel](http://stackoverflow.com/questions/30732241/mixins-for-es6-classes-transpiled-with-babel#43129978) + there [Refactoring legacy mixin-based class hierarchies](http://stackoverflow.com/questions/43027388/refactoring-legacy-mixin-based-class-hierarchies#43059101). – Peter Seliger Apr 07 '17 at 10:12

1 Answers1

0

I eventually gave up and decided to use Coffeescript's little class mechanisms, and rolled my own mixin code like everyone else on the planet.

JMHNilbog
  • 1,073
  • 1
  • 8
  • 13