Re: May I have a example of design pattern of "composite", I still feel fuzzy after reading book of Addison-Wesley's"design pattern "



Alf P. Steinbach wrote:
* jones9413@xxxxxxxxx:
Thank you for your kind & help !

See [http://en.wikipedia.org/wiki/Composite_pattern#Example], which I found in 1 second of googling (and so could you).

Yeah, but to be fair, from a quick reading, that Wikipedia page is a
terrible explanation. I'm sure they're trying to say something else,
but the way it reads, they seem to be implying all objects are shapes.
Or that the Composite pattern is always used with objects representing
shapes.

Also, under the "When to Use" section, their explanation could almost
just as easily be applied to explain the concept of inheritance. The
actual sentence I'm talking about is this:

You find that you are using multiple objects in the same way,
and often have nearly identical code to handle each of
them -- the only differences being that you are manipulating
an instance of a 'circle' versus a 'square', for instance.

Yeah, isn't that what inheritance is for -- when I have multiple
objects of different types that should have the same behavior? Once
again, I'm certain there really is something behind this explanation
and that they mean something else; it's just that it's not phrased
well enough to get across the intended meaning clearly.

- Logan
.



Relevant Pages

  • Re: how to analyze interaction between tow risk factors?
    ... And the pragmatic explanation. ... single genes result in overt "phenotypes" or overt traits. ... and a, and the model, in terms of proteins, is additive and sensible. ... inheritance produces an intermediate color. ...
    (sci.stat.consult)
  • Re: inheritance question
    ... Excellent Dmitriy, that was exactly the sort of explanation I was ... inheritance a bit better. ...
    (microsoft.public.dotnet.languages.csharp)