For the property, I would probably agree. In the "Clean Code" it is indicated (correctly) that bool hide the intention when used as parameters. For example, a formatting method might look like this:
public void Format(bool pBold, bool pItalic, bool pUnderline) { ... }
When called, it looks like this:
Format(true, false, true);
Instead, it would be much more readable:
public enum BOLD { BOLD, NOT_BOLD } public enum ITALIC { ITALIC, NOT_ITALIC } public enum UNDERLINE { UNDERLINE, NOT_UNDERLINE } public void Format(BOLD pBold, ITALIC pItalic, UNDERLINE pUnderline) { ... }
What then causes the call:
Format(BOLD.BOLD, ITALIC.NOT_ITALIC, UNDERLINE.NOT_UNDERLINE);
(Remember, this is just an example of how bool options hide intent, there may be more efficient ways to implement the above code.)
In your specific case, pay attention to the difference between the two constructor calls:
// enum; intent is clear Room r = new Room ("101", BookingStatus.Bookable); // bool; true what? Room r = new Room("101", true);
Dave cousineau
source share