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
2010-08-17 14:26:28
+1 for `dirty`, and `hasChanges`, but maybe that should be `isDirty`
Chad
2010-08-17 14:27:55
I've always disliked `dirty` as a variable/method name, though I've no idea why.
Dominic Rodger
2010-08-17 14:28:38
I once saw in code a `dirty`, and then a `filthy` to indicate an advanced level of data "dirtiness"...
FrustratedWithFormsDesigner
2010-08-17 14:31:02
@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
2010-08-17 14:35:34
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
2010-08-17 14:26:46
+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
2010-08-17 14:27:01
A:
It would be helpful to know more about when update
is called, but some possibilities are:
Dirty
- if the data changed, then update itStale
- if the data is stale, then update it :)
Justin Ethier
2010-08-17 14:27:06