1

I'm struggeling with the prefixes of my Booleans between Is- and Has-.
Because sometimes Has- make more sens than Is-

Sampe:

bool IsPrintable
bool IsChecked

bool HasDocument
bool HasPermission

so whats your opinion about that?

WiiMaxx
  • 5,322
  • 8
  • 51
  • 89
  • 2
    go through this: http://stackoverflow.com/questions/3874350/naming-conventions-for-java-methods-that-return-booleanno-question-mark it will definitely help you out. – Roshan Jun 13 '13 at 07:30

2 Answers2

5

Use both. It makes your code much more readable:

if (IsPrintable) Print()

if (HasDocument) Documents[0].Name = 'New Doc'

Etc.

Ryan
  • 3,924
  • 6
  • 46
  • 69
-2

You could always use _p

Document_p
Printable_p

This derives from an old Lisp convention. "P" stands for predicate, making it basically a form of Hungarian notation. This makes _p always precisely true, versus always using Is or Has, which would be misleading at best.

But seriously: Follow @Ryan's suggestion. Use both.

jpaugh
  • 6,634
  • 4
  • 38
  • 90