Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38649
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Overloading methods question |
| Date | 2018-10-25 07:49 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <pqsak0$es4$1@dont-email.me> (permalink) |
| References | <pqqmoq$jeo$1@dont-email.me> |
On 10/24/2018 5:04 PM, Rhino wrote:
> Is it better to overload a single method name several times or to create
> uniquely-named methods to accomplish similar work?
> [...]
> APPROACH 1:
> I could have several overloaded versions of a single method. For instance:
> - getCurrentMonthName(boolean fullMonthName) and assume local time zone
> [...]
In addition to what Arne and Joerg have said, I'd suggest that
the association `true' -> "full name" and `false' -> "short name"
is not very self-documenting. Perhaps you should use an `enum'
instead, either TextStyle or something of your own, since
String name = getCurrentMonthName(TextStyle.SHORT);
is more easily read and understood than
String name = getCurrentMonthName(false);
Also, if you someday need to support extraterrestrial locales
and find out that Klingon has *three* common forms for month names,
an `enum' can always grow a third instance while a boolean can't ...
--
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