Design Patterns Textbook - Monoglyph

F

Fiber Optic

If anyone has a suggestion for a better location for this post please
let me know. Thanks.

On page 45, of the Design Patterns text shows the following:

void MonoGlyph::Draw(Window *w) {
_component->Draw(w);
}

Questions...

1. Is _component a member of Glyph or MonoGlyph?

2. What data type is _component?

3. There is an aggregate line in Figure 2.7 showing that "component" is
contained within MonoGlyph (or is it saying that MonoGlyph is the
component and is a data member of Glyph?), and Glyph contains a
reference to it. Or does it contain a reference to MonoGlyph, which is
contained within Glyph? I guess I'm having trouble understanding what
the line is showing. Can someone clarify?

4. 2nd paragraph says "MonoGlyph subclasses reimplement at least one of
these forwarding operations. Border::Draw, for instance first invokes
the parent class operation MonoGlyph::Draw on the component to let the
component do its part-that is, draw everything but th border."

void Border::Draw(Window *w) {
MonoGlyph::Draw(w);
DrawBorder(w);
}

What -is- the "everything" which they speak of? If I envision the border
to be a simple elongated filled rectangle, then what is
MonoGlyph::Draw() drawing?

5. Class Scroller has a Draw(Window) method as well. Does scroller just
call the parent Draw() method? If so, then how does the Glyph::Draw()
method know how to draw the scroller?

Any help appreciated.

Chris
 
F

Fiber Optic

After consulting with a colleague, it is apparent that the answers
below reside in the "composite" pattern, on a page starting near 163-167
of said text. I didn't see any replies, so I thought I would provide
this followup for posterity.
-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top