Junior
How to properly name properties that return true or false?
sobes.tech AI
Answer from AI
Prefixes is, has, or can are used to explicitly indicate that a property returns a boolean value and describes a state or capability.
is- for describing a state (e.g.,isLoggedIn,isLoading).// Property indicating loading state bool isLoading = true;has- for checking the presence of something (e.g.,hasData,hasChanges).// Property checking for data presence bool hasData = data != null;can- for checking the possibility of performing an action (e.g.,canEdit,canDelete).// Property checking editing capability bool canEdit = user.role == UserRole.admin;