View Single Post
  #5 (permalink)  
Old 06-01-2006, 03:49 PM
brackett brackett is offline
Programmer
 
Join Date: May 2006
Posts: 193
Credits: 0
Rep Power: 11
brackett is on a distinguished road
Default

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.
Reply With Quote

Sponsored Links