Skip to content

Comparing polytype with other methods #14

@AbdealiLoKo

Description

@AbdealiLoKo

I've been trying to figure out inheritance / mixin approach for the past few days.
And I've seen a few methods around

polytype seems to be the most robust approach I have come acorss based on the documentation so far.
I was wondering if there was some nice comparison of some of the common approaches and pitfalls or other approaches that could exist ?

For example -

  1. The single inheritance available in JS now prototype replacement (which does not allow multiple inheritance)
  2. The approach of modifying the prototype of classes - like Object.assign(MyClass.prototype, MyMixin); (which does not allow me to use super(), instanceof, doesnt handle typing, etc.)
  3. The approach mentioned in typescript's mixin documentation right now about dynamic classes inherited in a function (Which has a bit of an awkward syntax ? But seems to handle everything else ?)
  4. ts-mixer

And so on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions