473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Circular dependencies

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
Jul 22 '05 #1
2 3077
On 29 Nov 2004 07:40:16 -0800, oo******@gmail.com (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
No**********@Home.com
Jul 22 '05 #2
"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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jinal jhaveri | last post by:
Hi All, I have one question regarding circular inheritance I have 3 files 1) A.py , having module A and some other modules 2) B.py having module B and some other modules 3) C.py having...
8
by: Tim Tyler | last post by:
Like C, Python seems to insist I declare functions before calling them - rather than, say, scanning to the end of the current script when it can't immediately find what function I'm referring to. ...
1
by: Henry Miller | last post by:
I have the following code (much simplified for this post). Note that SessionKey uses DataAccess, and DataAccess requires SessionKey in it's constructor. Public Class SessionKey Public...
3
by: Keith F. | last post by:
Visual Studio doesn't allow circular references between projects. I have a situation where I need to allow 2 projects to reference each other. Is there any way to make Visual Studio allow this? ...
7
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time...
8
by: nyhetsgrupper | last post by:
I have written a windows service and want to expose a web based user interface for this service. I then wrote a class library containing a ..net remoting server. The class library have a method...
3
by: donnyma | last post by:
I have a problem that looks like it has not been discussed before in these groups. I have a simple SQLAgent job that runs sp_who (could be anything, but let's just say sp_who for this example). ...
5
by: =?Utf-8?B?Qm9i?= | last post by:
I have a table of dependencies and want to check to see if the dependencies cause a circular reference. Any sugesstions on how to do this using c#. Example, ID DependsOnID 1 2 1 ...
6
by: Mosfet | last post by:
Hi, I have two classes, let's call them class A and class B with mutual dependencies as shown below and where implementation is inside .h (no cpp) #include "classB.h" class A {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.