Questions regarding Composite Pattern & Ex09 Task1

sfelsen
Neuling
Neuling
Beiträge: 3
Registriert: 20. Jan 2018 12:51

Questions regarding Composite Pattern & Ex09 Task1

Beitrag von sfelsen » 20. Jan 2018 13:10

I am a bit confused about how to implement the Composite Pattern. According to the GoF book and the ReadMe that has been supplied, the child management methods are supposed to be declared in the component interface. How are we supposed to handle these methods in the Leaf classes? I've found an example in which an UnsupportedOperationException is thrown but most implementations of the pattern seem to move the child management methods to the composite class.

Could you maybe comment on what getPosition and getSize are supposed to return in Edge and Node? How is the size and position of a composite component defined?

meichholz
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

Re: Questions regarding Composite Pattern & Ex09 Task1

Beitrag von meichholz » 22. Jan 2018 10:57

Hi,

it is fine to just throw an UnsupportedOperationException.
sfelsen hat geschrieben:
20. Jan 2018 13:10
Could you maybe comment on what getPosition and getSize are supposed to return in Edge and Node? How is the size and position of a composite component defined?
This was already discussed in other threads, please have a look.

Best,
Matthias

sfelsen
Neuling
Neuling
Beiträge: 3
Registriert: 20. Jan 2018 12:51

Re: Questions regarding Composite Pattern & Ex09 Task1

Beitrag von sfelsen » 22. Jan 2018 11:33

Thank you!
Follow-up question: Are we supposed to annotate those methods in the leaf classes?
Also, does an element border have a size?

meichholz
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

Re: Questions regarding Composite Pattern & Ex09 Task1

Beitrag von meichholz » 22. Jan 2018 13:19

Hi,
sfelsen hat geschrieben:
22. Jan 2018 11:33
Are we supposed to annotate those methods in the leaf classes?
Yes, please annotate them.
sfelsen hat geschrieben:
22. Jan 2018 11:33
Also, does an element border have a size?
You can just use the the size of the element + 1.

Best,
Matthias

Antworten

Zurück zu „Archiv“