True is the opposite of false. Up is the oppowebsite of dvery own. What is the oppowebsite of dog?
If you replied “cat”, what precisely makes cats the oppowebsite of dogs the same way up is the oppowebsite of down?
I usage this instance to suggest out a prevalent difficulty that software application developers make with variable and parameter names. When there are two feasible values for some variable or parameter, it is exceptionally common that it must be identified as a boolean kind.For example, a parameter can be called foobarEnabled and a True or False worth is passed for it. This makes sense. The foobar is either permitted or disabled. “Not enabled” has a unique and unambiguous opposite value, “disabled”. A boolean here renders perfect feeling.
You are watching: The opposite of down and the opposite of cat
However, there is likewise a case when the two (and also just two) feasible worths are not necessarily opposites. In this instance, a boolean value is the wrong data form to usage. On a current internet application I was functioning on, tright here is a type that has an “add foo” and also “edit foo” mode, depending upon whether the widacquire is including a brand-new foo or modifying an existing foo (they use pretty a lot the exact same develop fields, yet the backfinish needs to recognize for technical factors.)
To differentiate in between them, the attribute that handles this develop has actually an isAddSetting parameter. If the form was submitted in Add mode, a True worth is passed to this parameter. If the create was submitted in Edit mode, a False value is passed to this parameter. Knowing that “add” and “edit” are the only 2 values, this renders feeling to the programmer creating this code. (But then aget, programmers always think the code they themselves write makes sense.)
But from the perspective of one more programmer that has to maintain this code later, this is the totally wrong name and data kind for this parameter. Having “not include mode” does not instinctively convey “edit mode” the exact same means “not enabled” conveys “disabled”.
Dog is not the oppowebsite of cat.
The correct name for a parameter choose this would certainly be something choose “mode” or “addOrEditMode” depending upon exactly how verbose you want to be. The correct data type for a parameter prefer this is an enum form through two values for “add” and also “edit”.It may seem favor a trivial information, however making your code as readable as English is a crucial to having actually cleanly written code which is basic to understand and straightforward to debug.
See more: Pos The Trepak Is A Folk Dance From:, What Does Trepak Mean
(By the way, if you would prefer to know what the opposite of “cat” is, it’s “triceratops”.)
Discover to regime via my books for beginners, free under a Creative Commons license:
Take my Automate the Boring Stuff via Python digital Udemy course. Use this link to use a 60% discount.