• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of boolean flags

 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
mohsen fakhari
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dana Bothner-By
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "flag" is just a boolean field, right? So what's to cock a snoot at?
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) :-)

pascal
 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



Thank you for all the input - you guys rock!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic