473,396 Members | 1,847 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,396 software developers and data experts.

Question about visibility/ modifications of objects

Hello,

I´ve a general question about the visibility and modification of an object.

I will try to explain it in my code, where I have the problem:
DocumentList dList = initDocuments(thesaurus);

for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);
}
In my DocumentList dList I have a List of objects which I create with
initDocuments().

In the for-loop I am removing some objects (documents) out of the
DocumentList with my method algo.run.

Let´s say my DocumentList has a size of 100 _before_ entering the loop.
If I call algo.run, I am removing 4 Documents out of my DocumentList.
So I have 96 Documents in my list.

But I thought, that I am removing these documents _only_ in my object
"Algo" and not in my object dList which I have created _before_ entering
the for-loop.

In other words:

I want to have 100 Documents in my DocumentList.
Then I am doing the first loop iteration, removing 4 but when I am doing
my second iteration, I want to have 100 Documents again and not 96.
But that is exactly what happens.

If I run my loop a second time, I only have 96 Documents and not 100
Documents.
Well.. I hope I explained it right and somebody understands my problem.

My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.
Regards,

Martin
Mar 1 '07 #1
5 1252
On Mar 1, 5:26 pm, Martin Pöpping <marti...@despammed.comwrote:
Hello,

I´ve a general question about the visibility and modification of an object.

I will try to explain it in my code, where I have the problem:

DocumentList dList = initDocuments(thesaurus);

for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);

}

In my DocumentList dList I have a List of objects which I create with
initDocuments().

In the for-loop I am removing some objects (documents) out of the
DocumentList with my method algo.run.

Let´s say my DocumentList has a size of 100 _before_ entering the loop.
If I call algo.run, I am removing 4 Documents out of my DocumentList.
So I have 96 Documents in my list.

But I thought, that I am removing these documents _only_ in my object
"Algo" and not in my object dList which I have created _before_ entering
the for-loop.

In other words:

I want to have 100 Documents in my DocumentList.
Then I am doing the first loop iteration, removing 4 but when I am doing
my second iteration, I want to have 100 Documents again and not 96.

But that is exactly what happens.

If I run my loop a second time, I only have 96 Documents and not 100
Documents.

Well.. I hope I explained it right and somebody understands my problem.

My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.

Regards,

Martin
I think your problem might be in the Constructor for Algo. When you
assign the values of dList to I guess a local dList in the Algo
instance do you assign just the values? Please post the Constructor
and any other needs methods in the Algo class.

Mar 2 '07 #2
justin creasy schrieb:
>I will try to explain it in my code, where I have the problem:

DocumentList dList = initDocuments(thesaurus);

for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);

}
>My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.
I think your problem might be in the Constructor for Algo. When you
assign the values of dList to I guess a local dList in the Algo
instance do you assign just the values? Please post the Constructor
and any other needs methods in the Algo class.
Here is the Constructor:

private DocumentList dList_;

public A.go(DocumentList dList, double fuzzyness /*...*/)
{
logger_.Info("Initialisiere...);
dList_ = dList;
//...
}

I do not understand it. Remember:

DocumentList dList = initDocuments(thesaurus);

for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);
}

In every iteration I am creating a _new_ object "algo" with a _new_
Constructor.

So I do not understand why I have the changes of my DocumentList made by
algo in iteration 1 in my next algo in iteration 2.

How could it be?

Regards,

Martin
Mar 2 '07 #3
On Mar 1, 9:07 pm, Martin Pöpping <marti...@despammed.comwrote:
justin creasy schrieb:
I will try to explain it in my code, where I have the problem:
DocumentList dList = initDocuments(thesaurus);
for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);
}
My general question is about visibility and modifications of objects.
How can I reach that my object "algo" does not change my object "dList"?
In other words... the object "algo" should work with it´s own copy of
the object dList.
I think your problem might be in the Constructor for Algo. When you
assign the values of dList to I guess a local dList in the Algo
instance do you assign just the values? Please post the Constructor
and any other needs methods in the Algo class.

Here is the Constructor:

private DocumentList dList_;

public A.go(DocumentList dList, double fuzzyness /*...*/)
{
logger_.Info("Initialisiere...);
dList_ = dList;
//...

}

I do not understand it. Remember:

DocumentList dList = initDocuments(thesaurus);

for (int i = 0; i < testRuns_; i++)
{
Algo algo = new Algo(dList, 1.1, anzahlCluster, thesaurus, initType_);
run = algo.run(maxIter, epsilon);
tests.add(i, run);

}

In every iteration I am creating a _new_ object "algo" with a _new_
Constructor.

So I do not understand why I have the changes of my DocumentList made by
algo in iteration 1 in my next algo in iteration 2.

How could it be?

Regards,

Martin
I am not very familiar with the DocumentList control but it sounds
like when you write

dList_ = dList;

it is copying a reference to dList, not the values of everything in
dList. Read this MSDN article on how to use the DocumentList and see
if it helps. Also look around to find out if DocumentList is passed as
reference or value.

http://msdn2.microsoft.com/en-us/library/ms172535.aspx

Mar 2 '07 #4
justin creasy schrieb:
I am not very familiar with the DocumentList control but it sounds
like when you write

dList_ = dList;

it is copying a reference to dList, not the values of everything in
dList. Read this MSDN article on how to use the DocumentList and see
if it helps. Also look around to find out if DocumentList is passed as
reference or value.

http://msdn2.microsoft.com/en-us/library/ms172535.aspx
LOL! Sorry please. I am not using the DocumentList control!

The class DocumentList I wrote by myself.
It´s a subclass of ArrayList and manages my Document objects:

public class DocumentList : ArrayList
{
public new Document this[int index]
{
get { return (Document)base[index]; }
}

public override int Add(object document)
{
return base.Add(document as Document);
}
}
So how can I find out if it is call by reference or call by value?
Regards,
Martin

Mar 2 '07 #5
Martin Pöpping <ma******@despammed.comwrote:

<snip>
So how can I find out if it is call by reference or call by value?
That's completely separate to the fact that it's a reference type.

See http://pobox.com/~skeet/csharp/references.html
(work in progress) and
http://pobox.com/~skeet/csharp/parameters.html
http://pobox.com/~skeet/csharp/memory.html
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 2 '07 #6

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

Similar topics

2
by: Maze | last post by:
This may be a simple question to answer, but I don't have a clue since I'm not a dba. I am using sql server 2000, while a client of ours is using sql server 7. Both using Windows 2000 as an OS,...
11
by: NS | last post by:
I am relativly new to css positioning and have a question regarding the display of a DHTML pop-up Here is the basic HTML I am using: <html> <head> <script language="JavaScript"> <!--
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
15
by: designconcepts | last post by:
bo'jour, bo'jour, So I have question to present to the forum about OOD. This is a Csharp forum, but C# is the lang of choice and the question is an exercise based on some comments by the chief...
1
by: Mark Denardo | last post by:
I stumbled across a weird problem that I don't seem to understand and was wondering if anyone could help explain why it is occurring: Basically I have set up a client/server application where the...
3
by: xllx.relient.xllx | last post by:
I have a question about an example presented in the book "INFORMIT C++ Reference Guide" by Danny Kalev: <code> string getmagicword() ( return string("Supercalifragilisticexpialidocious"); );
2
by: Jamey Bon | last post by:
I am a C# newbie. I am having a tough time with several issues of scope and visibility. In short, why can't I see any of the elements of Form1 (the base form generated by the "Windows...
6
by: Aaron | last post by:
I want to build two abstract base classes. 1) Game 2) Position The Game object represents a boardgame in its entirety and the Position object represents individual game states. The Game object...
0
by: rw2007 | last post by:
I'd like to hear what you think about this... I'm working on a new architecture for an existing software product. I want this to be a flexible - and especially extendable - architecture for future...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.