In the app I'm working on, we have a table class that displays data. The user can load and reload data at various times, calling the table's load() method. I need to do one bit of logic ONLY on the first time load() is called. I'm considering using a boolean flag so I can check whether or not it's the first. But I seem to recall a fellow programmer or two turning their nose up at using flags in general....
Any opinions out there?
Joined: May 04, 2003
if you don't have something that shows you the state itself,I think you don't have any way else but don't let the flag to be global if you can.
Joined: Jul 28, 2006
A "flag" is just a boolean field, right? So what's to cock a snoot at?
Joined: Jun 19, 2001
as mentioned above: if you can not check the state then you have to add a "flag". perhaps you can "abuse" a different field ? e.g.
if they keep their noses up.... just call it "state" instead of flag, make it an int and assign it another value after each "phase" (e.g. init, load, reload, delete, flush or wahtever you have) :-)
Joined: May 07, 2001
Ok - Thanks for your support, guys. I'm gonna go ahead & use the flag. I tried "abusing" an existing field, but it didn't work out. I think these people "learned" something about a particular situation where maybe using the flag was bad, & are trying to over-apply it.