473,544 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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._Tok en' in
it, i saw the value i expected. If i entered 'Tokenizer._Tok en' 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 1510
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

"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ 38g2000cwa.goog legroups.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._Tok en' in
it, i saw the value i expected. If i entered 'Tokenizer._Tok en' 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
1855
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 product, category, news etc. - often i have fex. load, request, insert, update and delete functions for them - often problems are the same ones: -...
26
2911
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 excuse to write- and learn- some C++). To cut a long story short, I wrote a fair chunk of it, but realised that it's... not very good. Okay, it's...
21
4038
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 A { std::vector<B*> Bs; public:
16
4230
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 classes for each of my 'entities' that operate within the program, ie, passenger, vehicle, etc. Then seperate UI classes that link to these. (Partially,...
11
437
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 the stored value of an object has such a representation and is read by an lvalue
14
3420
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 program can save all running data to a file when I want it to stop, and can reload the data and continue to run from where it stops when the computer...
1
1172
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 sets the value of all the objects in the array to the value of the last object. the code is below: For i = 0 To counter - 1
20
4010
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 tells me if a variable has changed, give me the original and current value, and whether the current value and original value is/was null or not. ...
5
1561
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 has many negatives, so I decided to look at the Enum implementation given here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413486 ...
0
7416
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7761
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7363
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4906
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3400
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1833
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
653
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.