I'm reading through a C# coding standards document and come across a section that reads as follows:

  • Try to prefix Boolean variables and properties with "Can", "Is" and "Has".

Can anyone give me an example of hows it's done or maybe a useful link on the subject please ?

I've had a bit of a Google myself but couldn't find a difinative answer.

Thanks in advance.

5 Years
Discussion Span
Last Post by Kru

Boolean is true of false, right? So normally it's used exactly to get/set if a "thing" Can or Can't be done, if it Is or if it isn't and if it Has or Hasn't something.

this.CanUpdate or this.IsUpdatable

Edited by AleMonteiro

Votes + Comments
great help

Also, if your looking into good coding standards, readability, naming variables, I would recommend 'Beautiful Code' that is published by O'Reilly. It is very well written in my opinion and helped me a lot with cleaning up my code and making my code more readable to the programmer that has to use it behind me.


I agree with some aspects of that article AleMonteiro, however, it does not mean we shouldn't strive to increase readability and maintainability of the code we do write. As was said, no code is ever going to be perfect, in design or otherwise. But in a business and team development environment, we can do things such as naming variables, functions, and such in a certain readable way to enhance the maintainability of the code in the future, by ourselves or whomever works on the code following.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.