"ernesto basc?n pantoja" <oo******@gmail.com> wrote in message news:7a**************************@posting.google.c om...
Hi everybody:
Hi.
I'm implementing a general C++ framework and I have a basic question
about circular dependencies:
I am creating a base class Object, my Object class has a method
defined as:
virtual String toString();
where String is defined as:
class String : public Object
This is similar to the Java or .NET Object class implementation, but it
is not a good OO design because the circular dependency between my
Object and my String classes.
I have never heard of this precept before, and I doubt that it is
a generally held view. In fact, I think it is rare for frameworks
to be designed without any circular dependency whatsoever.
There are another ways to implement this functionality without having
circular dependencies?
You have set out "this functionality" as:
(1) an object hierarchy with a single root
(2) any object can be converted to a "String"
(3) a "String" is part of the object hierarchy
That inherently has some circularity, hence circular dependency.
So I have to say, "No there are no other ways to implement that
functionality without some degree of circular dependency." The
issue is not implementation; it is your requirements.
I suggest simply dropping the "not a good OO design" notion.
If you have a specific C++ question about how to declare and
define classes with circular dependency(s), you are welcome
to pose them. C++ provides ways to accomplishing that.
--
--Larry Brasfield
email:
do***********************@hotmail.com
Above views may belong only to me.