True is the contrary of false. Up is opposing of down. What is opposing of dog?
If you responded “cat”, what exactly makes cats the opposite of dogs the same way up is the opposite of down?
I usage this instance to allude out a common problem that software application developers make with variable and also parameter names. When there space two feasible values for part variable or parameter, the is an extremely common that it should be identified as a boolean type.For example, a parameter might be referred to as foobarEnabled and a True or False value is passed because that it. This provides sense. The foobar is either allowed or disabled. “Not enabled” has a distinct and also unambiguous the contrary value, “disabled”. A boolean below makes perfect sense.
You are watching: Opposite of down and opposite of cat
However, over there is additionally a case when the two (and only two) feasible values space not necessarily opposites. In this case, a boolean worth is the dorn data kind to use. Top top a recent web application I was functioning on, over there is a form that has actually an “add foo” and also “edit foo” mode, depending upon whether the widget is adding a new foo or modifying an present foo (they use pretty lot the same kind fields, however the backend requirements to know for technical reasons.)
To differentiate between them, the role that handle this kind has one isAddMode parameter. If the form was it is registered in include mode, a True value is passed to this parameter. If the type was submitted in modify mode, a False worth is passed to this parameter. Understanding that “add” and “edit” space the just two values, this provides sense to the programmer creating this code. (But climate again, programmers always think the password they themselves write provides sense.)
But native the perspective of one more programmer who needs to maintain this code later, this is the totally wrong name and data form for this parameter. Having “not add mode” does not instinctively convey “edit mode” the same means “not enabled” conveys “disabled”.
Dog is not the opposite of cat.
The correct name for a parameter favor this would certainly be something like “mode” or “addOrEditMode” relying on how verbose you desire to be. The exactly data kind for a parameter like this is one enum kind with two values for “add” and “edit”.It might seem prefer a trivial detail, yet making your password as readable together English is a key to having cleanly written code i beg your pardon is easy to understand and also easy come debug.
See more: How Big Is 40 Acres In Square Miles, How Big Is 40 Acres
(By the way, if you would like to know what the contrary of “cat” is, that “triceratops”.)
Learn to program with my books for beginners, cost-free under a an imaginative Commons license:
Take my Automate the Boring Stuff v Python online Udemy course. Use this connect to use a 60% discount.