C
C
copal2015-03-20 20:47:04
Programming
copal, 2015-03-20 20:47:04

How is the display list formed?

Yesterday asked the question Multiple inheritance does not violate OOP? , in which I was criticized, and today I have a different view on this issue and for this I decided to ask again.
Yesterday's question sounded like - can one class implement many interfaces that are not similar in behavior. Type -

interface INode {
  next: INode
  prev: INode
}

interface ITask {
  execute(): void;
}

interface ISet {
  insert(target: INode): void;
};

class SomeClass implements INode, ITask, ISet{
  next: INode;
  prev: INode;
  
  execute():void {}
  insert(target: INode):void
  {
    // и здесь просиходит установка таргета
    this.next = target;
    target.prev = this;
  }
}

And I was already seduced by the answers that sounded like - "single responsibility" and "Barbara Liskov's substitution principle" and even that the composition already sucks and the future lies with aggregation ...
But today I opened my question and immediately came to my mind sheet display.
It also has a close compositional connection in the form of a link to the parent.
And he installs his own children. And it can even reach the forefathers and hundredths of children.
It turns out one in one my case, in which I have links to predecessors
and children and at the same time I am installing them.
Where is the truth?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pukhov, 2015-03-21
@copal

the question is a little strangely posed, it is not clear why in general in such a simple example to fence a bunch of interfaces if all this is solved elementarily:

class SomeClass 
        {
         public SomeClass parent;
         public SomeClass child;
  
          void execute{

          }
          
          void insert(SomeClass target)
          {
            this.child = target;
            target.parent = this;
          }
        }

I didn’t understand what language you have in the example, the example was given in C #

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question