Quote:
|
Originally Posted by Lop
Why is it such a bad thing to use globals anyway?
|
Globals are bad because they represent shared state. Shared state is bad because it means different pieces of code depend on each other. Obviously, you have to have shared state information. But, by encapsulating it into a class who's job it is to track and update the information, you've centralized the logic associated with that shared state.
Now, that being said, globals aren't really
such a bad thing - they're just something to watch out for. Sometimes, the convenience of a global is worth it. But, then again, it's usually not too hard to replace a global with something (if only slightly) better.
Back to the original question, I should've tried to flesh out
why the number of clicks needed to be tracked. I suspect that road would lead us to a class who's job would be to take some action based on clicks - and that job should probably be moved out of the Form (where it no doubt lives right now). By proposing a ReadOnly Property to expose that information, I think I probably proposed splitting out the logic that deals with the number of clicks - and that's not normally a good thing.
Just moving the tracking information inside a subclassed Button isn't really the whole solution, but based on the info given - it was the best I had at the moment.