F
F
fr0zen2018-04-13 12:13:58
JavaScript
fr0zen, 2018-04-13 12:13:58

Is it possible to access the parent's private methods from a mixin?

Is it normal practice to access the private fields and methods of the parent from the mixin?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
RidgeA, 2018-04-13
@RidgeA

Private methods for this and private so that no one else would contact them

K
Konstantin Kitmanov, 2018-04-13
@k12th

If you need to access the fields of the parent from the children, they are marked as protected, not private.

M
Mikhail Osher, 2018-04-13
@miraage

In my understanding, no. A mixin is a self-contained unit. Otherwise, she will take on more responsibility than necessary. This will increase the connectivity of the components, which is bad.
Change my mind.

F
forspamonly2, 2018-04-13
@forspamonly2

in languages ​​with decent OOP, mixins can limit the type of object they can be mixed into.
in the same rock, a mixin (trait) has a self type. and if the object does not correspond to it, the mixin does not agree to mix with it. but, having this guarantee, inside it can freely access methods of this type on the object to which it is mixed. this is a completely normal mechanism to clearly indicate at the level of the type system what the mixin needs to work.
I don’t know what meaning this question has in the context of the javascript, there are no private fields there either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question