Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Class composition #319

@rowaasr13

Description

@rowaasr13

Composition, mix-ins, etc is a natural feature of JS as dynamic language. How can prviate fields from this proposal used with dynamically composing a class?

Say, I have a class that have several utility fields and some mix-ins with functions that want to read private data - i.e. some generic logging and some mix-ins with functions that want to modify data - some generic normalization. Classes are not homogenic enough to throw everything into single base class and extend from there: I want different set of mixins in each class.

With read-only functions this can be somewhat "solved" with wrapper for each "external" function that would pass hidden field as argument, but this doesn't look very dynamic with lots of extra boilerplate in "host" class. Wrappers for R/W functions would be even more ugly with first passing everything that could possibly be needed in and then reading returns and writing them as necessary to hidden fields.

Is there a prettier and more natural solution for me as author of both "host" and "mixin" code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions