True is the contrary of false. Up is the opposite of down. What is opposing of dog?
If you responded “cat”, what precisely makes cats the opposite of dogs the same way up is the contrary of down?
I usage this example to allude out a typical problem that software program developers make v variable and also parameter names. When there space two possible values for some variable or parameter, it is really common that it need to be defined as a boolean type.For example, a parameter can be referred to as foobarEnabled and also a True or False worth is passed for it. This provides sense. The foobar is either allowed or disabled. “Not enabled” has actually a distinct and also unambiguous opposite value, “disabled”. A boolean here makes perfect sense.
You are watching: Opposite of down and opposite of cat
However, over there is likewise a case when the two (and only two) feasible values space not have to opposites. In this case, a boolean value is the not correct data kind to use. ~ above a current web app I was functioning on, there is a kind that has an “add foo” and also “edit foo” mode, relying on whether the widget is adding a new foo or editing and enhancing an existing foo (they usage pretty much the same form fields, yet the backend requirements to recognize for technological reasons.)
To differentiate between them, the role that handle this kind has an isAddMode parameter. If the form was it is registered in include mode, a True worth is passed come this parameter. If the form was it is registered in modify mode, a False worth is passed to this parameter. Discovering that “add” and “edit” are the only two values, this renders sense come the programmer composing this code. (But then again, programmers constantly think the password they themselves write makes sense.)
But native the perspective of another programmer who needs to maintain this code later, this is the completely wrong name and also data form for this parameter. Having actually “not include mode” does no instinctively convey “edit mode” the same means “not enabled” conveys “disabled”.
Dog is not the the contrary of cat.
The correct name for a parameter choose this would certainly be something favor “mode” or “addOrEditMode” depending on how verbose you want to be. The correct data form for a parameter like this is one enum kind with two values because that “add” and “edit”.It might seem like a trivial detail, but making your code as readable together English is a vital to having actually cleanly created code i m sorry is easy to understand and easy to debug.
See more: What'S A Remington Model 34 Worth, Remington 34 Rifle Price And Historical Value
(By the way, if you would like to recognize what opposing of “cat” is, the “triceratops”.)
Learn to routine with my books for beginners, totally free under a an imaginative Commons license:
Take my Automate the Boring Stuff through Python virtual Udemy course. Usage this attach to use a 60% discount.