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

A nasty trap - Class Properties Changing Value Whilst A Program Was Paused !!

Hi,
I thought i should give a better explanation to my second 'bug' in my
previous post (Bugs in VS2003 SP1) because it's taken me ages to figure
out what was going on.

Basically, one of my project classes 'Tokenizer' had a property
'_Token'.
When i hovered my mouse over a line of code with 'Tokenizer._Token' in
it, i saw the value i expected. If i entered 'Tokenizer._Token' into
the watch window i saw the value i expected.

BUT! When i entered 'Tokenizer' into the same watch window and expanded
the treeview to view the '_Token' property it had mysteriously changed.
Hmmmmm.

Unfortunately for me, one of my other properties '_CommandType' resets
the tokenizer to the start of the string and gets the first token ...
which i only ever called once in my code at the beginning of the whole
tokenizing procedure, so my code never experienced any problems.

HOWEVER, when i enter 'Tokenizer' into the watch window, it obviously
gets '_CommandType' for the treeview, thus reseting the tokenizer to
the beginning and displaing the 'wrong' value in the watch window. Oh
how i now laugh through my tears.

I really hope this helps some poor, distraught person.

Please feel free to call me names. I would like to start the list with
'Moron'.

Cheers,
James Randle.

Jan 12 '07 #1
1 1500
Hi James,

You're not a moron - at least not because of this mistake :)

I've seen it happen many times. Developers will find a bug in their code
and try to debug it by listing properties in a watch window, but then
completely forget about them. Then, they report all sorts of weird behavior
that they think is related to the original bug. One indication of this
might be when they say, "I can't reproduce the problem in the debugger".
Right, because of the observer effect - as soon as you attach to the process
you're changing it.

This is something that all developers should be aware of when using the
debugger. One way this issue can be alleviated is to make sure that
properties don't change internal state or call methods in their get
accessors except for when lazy initialization is desirable for the backing
field.

--
Dave Sexton
http://davesexton.com/blog

"pigeonrandle" <pi**********@hotmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
Hi,
I thought i should give a better explanation to my second 'bug' in my
previous post (Bugs in VS2003 SP1) because it's taken me ages to figure
out what was going on.

Basically, one of my project classes 'Tokenizer' had a property
'_Token'.
When i hovered my mouse over a line of code with 'Tokenizer._Token' in
it, i saw the value i expected. If i entered 'Tokenizer._Token' into
the watch window i saw the value i expected.

BUT! When i entered 'Tokenizer' into the same watch window and expanded
the treeview to view the '_Token' property it had mysteriously changed.
Hmmmmm.

Unfortunately for me, one of my other properties '_CommandType' resets
the tokenizer to the start of the string and gets the first token ...
which i only ever called once in my code at the beginning of the whole
tokenizing procedure, so my code never experienced any problems.

HOWEVER, when i enter 'Tokenizer' into the watch window, it obviously
gets '_CommandType' for the treeview, thus reseting the tokenizer to
the beginning and displaing the 'wrong' value in the watch window. Oh
how i now laugh through my tears.

I really hope this helps some poor, distraught person.

Please feel free to call me names. I would like to start the list with
'Moron'.

Cheers,
James Randle.

Jan 12 '07 #2

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

Similar topics

4
by: Perttu Pulkkinen | last post by:
Hi all php freaks! Do you think this kind of "property class" is useful or not? I have bee bored to the way I've been coding earlier. because: - often i have database-oriented classes like...
26
by: Michael Strorm | last post by:
Hi! I posted a message a while back asking for project suggestions, and decided to go with the idea of creating an adventure game (although it was never intended to be a 'proper' game, rather an...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
16
by: Richard Brown | last post by:
Ok, now I am truely going nuts... probably why I didn't use the Class Builder in VB6 extensively. But, being the 'proper programmer' that I should, I'm trying to bite the bullet and build...
11
by: pemo | last post by:
Ambiguous? I have a student who's asked me to explain the following std text (esp. the footnote). 6.2.6.1.5 Certain object representations need not represent a value of the object type. If...
14
by: fdu.xiaojf | last post by:
Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the...
1
by: =?Utf-8?B?UiBD?= | last post by:
hi, i have an array of 30 adgroup objects, called arrAdGroup. i am using a loop to traverse through the array to set the adgroup.id property to a value (which is different every time). the code...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
5
by: eliben | last post by:
Hello, I have a game class, and the game has a state. Seeing that Python has no enumeration type, at first I used strings to represent states: "paused", "running", etc. But such a representation...
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.