473,799 Members | 2,734 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 1520
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
1864
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: - which member variables are expected from the form, which ones are not
26
2945
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 my first "proper" C++ program, so that's no big deal, but I don't want to waste more time working...
21
4083
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
4251
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, because eventually several add-ons will be able to reuse the code in the data classes). My...
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
3451
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 is free ?
1
1181
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
4047
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. This one works fine but is recreating the same methods over and over for each variable type. ...
5
1574
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 So, I've defined:
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
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

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.