471,610 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 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 1400
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Perttu Pulkkinen | last post: by
26 posts views Thread by Michael Strorm | last post: by
21 posts views Thread by Jon Slaughter | last post: by
16 posts views Thread by Richard Brown | last post: by
11 posts views Thread by pemo | last post: by
1 post views Thread by =?Utf-8?B?UiBD?= | last post: by
20 posts views Thread by tshad | last post: by
5 posts views Thread by eliben | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by
1 post views Thread by ZEDKYRIE | last post: by

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.