Илья Рассадин wrote:
Hi!

It's strange design decision.

If FOOR is ancestor for BAR, why can't you just place methods into FOO?

It´s because not both of FOO and BAR can have all the same methods.  Yet
there is functionality programs using FOO and/or BAR require from both of
them from different perspectives.

Think of the articles kept in storage.  From one perspective, the
article (FOO) is stored in quantities in storage units (BAR).  From the
other perspective, the storage unit stores articles in quantities.

Now you want to know how may FOO are stored in BAR.  What do you do?
Will you ask FOO or will you ask BAR?

What kind of answer do you expect?  One FOO can be stored in multiple BAR,
and multiple BAR can store the same FOO.

That leads to:  What exactly is your question?  Do you want to know how
many FOOs you have in BARs in total, or do you want to know how many of
a particular FOO you have, or do you want to know how many of a particular
FOO you have in a particular BAR --- and so on.

Necessarily, you end up with different methods for FOO and for BAR to answer
different questions.  But what if my program works with FOO and asks a question
that a BAR would have a method to answer?

That brings me to the point where FOO would have to use BAR to be able to
answer the question.  To do that, FOO would need to use BAR, but I´m reluctant
to do that because BAR is descended from FOO.

You see the conundrum?





03.08.17 21:44, hw пишет:

Hi,

suppose I have a class FOO and a class BAR.  The parent of BAR is FOO.

I would like FOO to /use/ BAR because BAR has some methods needed by FOO.
BAR is /decended/ from FOO because FOO has many methods needed by BAR.

Is this possible, or does it lead to some endless recursion when compiling?



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to