By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Design Patterns Textbook - Monoglyph

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Fiber Optic wrote:
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

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.