views:

78

answers:

4

I have a Method name update, this will be called depending on the boolean variable. I need suggestion how should I name this variable.

+4  A: 

How about shouldUpdate? Or describe the conditions under which it should update, e.g. dirty, hasChanges etc.

Jon Skeet
+1 for `dirty`, and `hasChanges`, but maybe that should be `isDirty`
Chad
I've always disliked `dirty` as a variable/method name, though I've no idea why.
Dominic Rodger
I once saw in code a `dirty`, and then a `filthy` to indicate an advanced level of data "dirtiness"...
FrustratedWithFormsDesigner
@Chad: I would write a property called isDirty(), but back it with a dirty variable, probably. "changes" is more ambiguous though, hence hasChanges.
Jon Skeet
A: 

For a question with very little context you probably won't get much good input.

Since the variable is boolean the name should imply it's value is true/false, yes/no, etc... so shouldUpdate, needsSave, hasChanges, isModified etc are all good.

STW
+1  A: 

Well, "update" sounds like a bad method name. What's it updating?

But, you could name it something like "shouldUpdate", "requiresUpdate", "needsUpdate"

Boolean variables should have a "question like" name.

Chad
A: 

It would be helpful to know more about when update is called, but some possibilities are:

  • Dirty - if the data changed, then update it
  • Stale - if the data is stale, then update it :)
Justin Ethier