I have a boolean variable that flags if a price (on an individual item) should be displayed. I started to name it “DisplayPrice”, but that is really more descriptive of the price of the item to be displayed (think: decimal). What are some options here?
I didn’t think anything starting with “Is” was appropriate. For example, “IsDisplayPrice” seems more like meta of the price itself, where “IsPriceDisplayed” seems more like a condition than a setting.
ShouldDisplayPrice? Any ideas?
ShowPrice. Simple to the point.ShouldDisplayPriceis a suggestion. Kind of like telling the application “I think you maybe want to display it, but don’t mind me.” It tells future programmers that they are free to make up their own minds about it. I consider this a wholly dangerous situation as programmers shouldn’t be left to their own devices as they tend towards unproductive activities like forking linux or writing windows desktop apps.IsPriceDisplayedandIsDisplayPriceare questions that I’m not sure a data point stored in the database can actually answer. After all, the programmer might not have put the field on the screen. Setting to true in this situation may cause the universe to explode.Of course, you could go negative and use
HidePriceinstead. However, this may be confusing to the feable minded when you have logic such as “if (!HidePrice) { /*emit price */ }”The worst one along these lines is probably
CanPriceBeHidden. It’s a suggestion, a question and a negative value. Only to be used if you are feeling particularly snarky.