Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38653
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Overloading methods question |
| Date | 2018-10-25 17:49 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <pqtdpa$nl4$1@dont-email.me> (permalink) |
| References | <pqqmoq$jeo$1@dont-email.me> <1b2bqd7oqzez6$.sfpve8lwmic2.dlg@40tude.net> <pqt6v0$e65$1@dont-email.me> <75ad8b55-3def-4ec1-b46b-65ecd971d0fe@googlegroups.com> |
On 10/25/2018 4:58 PM, Eric Douglas wrote:
> [...]
> Use boolean where there are exactly 2 possibilities (print duplex? yes or no). [...]
Use booleans where there exactly two possibilities *and* where
their associations with `true' and `false' are flat-out obvious.
/** An old-fashioned binary-gendered person. */
public class Person {
/** A poorly-designed constructor API. */
public Person(Name name, boolean gender) {
...
Things would be a little bit better if `gender' were renamed to
`isMale' or `isFemale', but even with the improvement it's not great:
Person flawedSage = new Person(new Name("Kao", "Li"), false);
... is not especially transparent.
Also, be careful to distinguish between "there are exactly two
possibilities" and "I have thought of only two possibilities." It
is perhaps instructive that the example given would not work for the
printer that sits on my desk at this moment, which has *five* modes
for duplexing:
One-sided
Two-sided (automatic, flip on long axis)
Two-sided (automatic, flip on short axis)
Two-sided (manual, flip on long axis)
Two-sided (manual, flip on short axis)
(In the "automatic" modes the printer marks one side but doesn't
spit the page out, then sucks it back in and does the second side.
In the "manual" modes it prints and ejects all the back sides, then
you re-insert the stack in the paper supply and it prints the formerly-
blank fronts. "Automatic" is more convenient, "Manual" can be faster
for long documents.)
Duplex-or-not is, as suggested, a Yes/No question -- but if the
answer is Yes the answer is incomplete, lacking essential detail.
A good API offers (relatively) straightforward ways to supply all
the necessary information.
--
esosman@comcast-dot-net.invalid
Eight hundred nineteen days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-24 17:04 -0400
Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-24 18:56 -0400
Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-25 10:13 +0200
Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 15:53 -0400
Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-25 13:58 -0700
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 17:49 -0400
Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-25 22:29 +0000
Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 20:08 -0400
Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 00:37 +0000
Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 21:42 -0400
Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:46 +0200
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-26 07:50 -0400
Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 19:33 +0000
Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 13:13 -0700
Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-26 20:58 -0400
Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-27 22:36 +0000
Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-27 19:38 -0400
Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-28 10:39 +0000
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-28 07:54 -0400
Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 06:26 -0700
Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:52 +0200
Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-26 22:10 -0400
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-27 07:43 -0400
Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:40 -0400
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-29 16:39 -0400
Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-29 05:07 -0700
Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:41 -0400
Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 07:49 -0400
Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 16:07 -0400
csiph-web