S
Steven T. Hatton
The 15th chapter of Accelerated C++ develops a rather lengthy, complex, and
(IMO) unusual example which seems to, on a small scale, defy many of the
intuitive notions I have about OOP. There are empty public interfaces to
most of the classes, and almost all of the functions in the interfaces are
private. The authors do this, they say, to hide the implementation details
from the user. They don't want the user of the classes to access their
functionality in any way except through what I might call a "wrapper" or a
"proxy" (I think I'm in agreement with GoF here). Add to that, the
operations on the hidden objects are performed by namespace local
functions. The authors actually call them "global", but I won't go that
far. They grant access to all the various parts to functions and classes
that need it by declaring function and classes as friends of others. Many
of these friendship relations are mutual.
You can find the code here: http://www.acceleratedcpp.com/
The example is very challenging to my sense of "proper" design. On the
small scale it seems very interdependent, and inflexible. OTOH, it
provides a lot of functionality to the user while hiding virtually all of
the complexity of the implementation.
Has anyone else read that chapter and formed an opinion about that design
approach?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
(IMO) unusual example which seems to, on a small scale, defy many of the
intuitive notions I have about OOP. There are empty public interfaces to
most of the classes, and almost all of the functions in the interfaces are
private. The authors do this, they say, to hide the implementation details
from the user. They don't want the user of the classes to access their
functionality in any way except through what I might call a "wrapper" or a
"proxy" (I think I'm in agreement with GoF here). Add to that, the
operations on the hidden objects are performed by namespace local
functions. The authors actually call them "global", but I won't go that
far. They grant access to all the various parts to functions and classes
that need it by declaring function and classes as friends of others. Many
of these friendship relations are mutual.
You can find the code here: http://www.acceleratedcpp.com/
The example is very challenging to my sense of "proper" design. On the
small scale it seems very interdependent, and inflexible. OTOH, it
provides a lot of functionality to the user while hiding virtually all of
the complexity of the implementation.
Has anyone else read that chapter and formed an opinion about that design
approach?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell