GoF:"C++ [doesn't] treat classes as frist class objects"

  • Thread starter Steven T. Hatton
  • Start date
S

Steven T. Hatton

"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective C, derive less benefit, since you can always use a class object
as a creator. Class objects already act like prototypes in these
languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?". But
then I realized what they were saying. Does anybody else see the subtle
point they're making?
 
V

Victor Bazarov

Steven said:
"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective C, derive less benefit, since you can always use a class object
as a creator. Class objects already act like prototypes in these
languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?". But
then I realized what they were saying. Does anybody else see the subtle
point they're making?

Yes.
 
E

E. Robert Tisdale

Steven said:
"Reduced subclassing. Factory Method (107) often produces
a hierarchy of Creator classes that parallels the product class hierarchy.
The Prototype pattern lets you clone a prototype
instead of asking a factory method to make a new object.
Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++
that don't treat classes as first-class objects.
Languages that do, like Smalltalk and Objective C, derive less benefit,
since you can always use a class object as a creator.
Class objects already act like prototypes in these languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?".
But then I realized what they were saying.
Does anybody else see the subtle point they're making?

No.
Please elaborate. ;-)
 
H

Howard

Steven T. Hatton said:
"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective C, derive less benefit, since you can always use a class object
as a creator. Class objects already act like prototypes in these
languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?".
But
then I realized what they were saying. Does anybody else see the subtle
point they're making?

Is this a quiz? Or are you complaining about their lack of explanation?
Or...?

(BTW, what's "GoF"?)
--
NOUN:1. Money or property bequeathed to another by will. 2. Something
handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/

What's that all about?
 
D

David Hilsee

Steven T. Hatton said:
"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective C, derive less benefit, since you can always use a class object
as a creator. Class objects already act like prototypes in these
languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?". But
then I realized what they were saying. Does anybody else see the subtle
point they're making?
[...]

No, everything I gathered was stated clearly. "Design Patterns" isn't much
for subtlely, IMHO.
 
D

Dave Vandervies

"Reduced subclassing. Factory Method (107) often produces a hierarchy of
Creator classes that parallels the product class hierarchy. The Prototype
pattern lets you clone a prototype instead of asking a factory method to
make a new object. Hence you don't need a Creator class hierarchy at all.
This benefit applies primarily to languages like C++ that don't treat
classes as first-class objects. Languages that do, like Smalltalk and
Objective C, derive less benefit, since you can always use a class object
as a creator. Class objects already act like prototypes in these
languages." - GoF, page 120.

When I first read that, I thought to myself "what are they on about?". But
then I realized what they were saying. Does anybody else see the subtle
point they're making?

This:
--------
convertAll: aCollection with: aClass

| ans |

ans := (aCollection class) new.

aCollection do: [ :i |
ans add: ((aClass new) initialize: i) ].

^ans
--------
would be hard to do without some code gymnastics in a language like C++
that doesn't treat classes as first-class objects.


Doesn't seem all that subtle to me, though.


dave
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top