BlogPost_BooleanNames #22

Merged
jeff merged 12 commits from BlogPost_BooleanNames into master 2020-07-30 22:44:26 +00:00
2 changed files with 13 additions and 1 deletions
Showing only changes of commit 58008d1e2a - Show all commits

View File

@ -340,3 +340,11 @@ button.round, .btn.round {
} }
.blue { --clr: #42A5F5 } .blue { --clr: #42A5F5 }
pre {
background: #eee;
border-radius: 5px;
padding-left: 1rem;
color: black;
font-size: 0.95rem;
}

View File

@ -20,7 +20,11 @@ A boolean name should give the reader more clarity as its scope expands. A bool
## Bad Boolean Names ## Bad Boolean Names
As with many things in software engineering, it is easier to find mistakes than to do something correctly the first time. Here are some naming conventions to avoid: As with many things in software engineering, it is easier to find mistakes than to do something correctly the first time. Here are some naming conventions to avoid:
1. Names that are already a negation. 'featureTurnedOff' and 'notProd' may make sense in one use case, but they become confusing in a larger context. The following code is both hard to read and ambiguous (what if there is a third environment). 1. Names that are already a negation. 'featureTurnedOff' and 'notProd' may make sense in one use case, but they become confusing in a larger context. The following code is both hard to read and ambiguous (what if there is a third environment).
<p class="friendly">confA.useProd := !confB.notProd</p> ```go
confA.useProd := !confB.notProd
```
2. Names that are not negatable. A name such as 'sheets' has ambiguous meaning. It probably has something to do with a spreadsheet, but it is the writer's responsibility to prevent the reader from needing to do an investigation. 2. Names that are not negatable. A name such as 'sheets' has ambiguous meaning. It probably has something to do with a spreadsheet, but it is the writer's responsibility to prevent the reader from needing to do an investigation.