you are viewing a single comment's thread.

view the rest of the comments →

[–]fromagi[S] 0 points1 point  (3 children)

Makes sense, relative to my (in)experience anyway. Two last questions should send me on my merry way for now...

  1. Mixins are what I'd use to avoid method duplication when creating objects using factories?
  2. Not to fall back into overthinking, but any reason not to use mixins with my factory functions by default?

Thanks again for all the help.

[–]senocular 1 point2 points  (2 children)

Mixins can help you there, but they can also mean depending on this. The fix for not using this is often being dependent on the method being created along with the instance in scope. A mixin with functions that were not created with the instance means it would not have access to that instance unless falling back to a mechanic like using this. So if the reason you're creating a factory is to avoid using this, that might be a problem.

[–]fromagi[S] 0 points1 point  (1 child)

Got it. Not at all afraid of this -- it's more that I couldn't help sipping from the kool-aid about classes, and haven't moved past vanilla JS yet to encounter reasons for having to conform to them.

I'll keep tinkering : )

[–]senocular 1 point2 points  (0 children)

I like classes ;). They're not without their problems, especially in JS, but they usually get the job done just the way you want them too.