Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Circular dependencies

Reply
Thread Tools

Circular dependencies

 
 
ernesto basc?n pantoja
Guest
Posts: n/a
 
      11-29-2004
Hi everybody:

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.

There are another ways to implement this functionality without having
circular
dependencies?

Best regards



ernesto
 
Reply With Quote
 
 
 
 
Bob Hairgrove
Guest
Posts: n/a
 
      11-29-2004
On 29 Nov 2004 07:40:16 -0800, (ernesto basc?n
pantoja) wrote:

>Hi everybody:
>
>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.
>
>There are another ways to implement this functionality without having
>circular
>dependencies?


Yes ... use std::string, or don't make your String an Object, but a
stand-alone class.

--
Bob Hairgrove

 
Reply With Quote
 
 
 
 
Larry Brasfield
Guest
Posts: n/a
 
      11-29-2004
"ernesto basc?n pantoja" <> wrote in message news: 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:
Above views may belong only to me.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are circular dependencies possible in Python? Tim Tyler Python 8 04-10-2005 08:15 AM
Circular dependencies in Templates - better solution? ro86 C++ 4 03-06-2005 10:10 PM
circular dependencies and typedefs Dylan C++ 7 07-07-2004 06:59 PM
circular dependencies, unrecognized base types, oh-my crichmon C++ 3 06-28-2004 03:03 AM
Re: circular dependencies & globals - avoid w/ precompiler directives?betterdesign suggestions? Suzanne Vogel C++ 2 06-26-2003 12:25 AM



Advertisments