Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26541
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Fixing "typos" in enums... |
| Date | 2013-11-18 19:38 +0100 |
| Message-ID | <bev54gF3iq5U1@mid.individual.net> (permalink) |
| References | <slrnl8cing.mol.avl@gamma.logic.tuwien.ac.at> <ben9u0FeoueU1@mid.individual.net> <slrnl8kjkk.42s.avl@gamma.logic.tuwien.ac.at> |
On 18.11.2013 18:29, Andreas Leitgeb wrote:
> Robert Klemme <shortcutter@googlemail.com> wrote:
>>> // public enum Foo { FURST, SECOND }
>>> public enum Foo { FIRST, SECOND; public static final FURST = FIRST; }
>>> Any user having done a switch over that enum will still
>>> need to modify his code. Ditto anyone doing string comparisons
>>> on foo.name(), but that is most probably a bad idea, anyway.
>
>> Not at all: a String could be read from some configuration file or
>> database and then the corresponding enum value searched via valueOf() or
>> values().
>
> Fair enough. De-serialization from some persistent storage sure is
> a legit task, that would suffer from such an API-change.
>
> Basic Object-(de)serialization would be less of a problem, as that is
> already specified as unsuitable for long-time storage.
Well, but it *can* be used for that purpose which means it *will* be.
And telling them "it's your fault" is often not a good option as there
can be numerous ugly ways that can backfire...
>> A published API is basically set in stone. Keeping the wrong value
>> might actually be the best option.
>
> I just don't yet want to accept it, even though I can't refute it. ;-)
:-) At the university we had a lecture about exactly this kind of
problem and other issues specific to API changes in OO languages.
Unfortunately I neither remember the professor's nor the lecture's name
to dig up some pointers. What I took away was that sentence ("...set in
stone") and that there is quite a number of surprising and subtle ways
failure can be caused by API changes. That had two effects: it made me
think thrice whenever I am tempted to change an API; and I try to give
extra thought whenever I am designing an API (not only the public ones
as often all of a sudden what has been private becomes public).
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-15 16:25 +0000
Re: Fixing "typos" in enums... markspace <markspace@nospam.nospam> - 2013-11-15 09:05 -0800
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 17:20 +0000
Re: Fixing "typos" in enums... markspace <markspace@nospam.nospam> - 2013-11-18 09:33 -0800
Re: Fixing "typos" in enums... Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-18 13:37 -0500
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 18:58 +0000
Re: Fixing "typos" in enums... markspace <markspace@nospam.nospam> - 2013-11-18 11:35 -0800
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 20:34 +0000
Re: Fixing "typos" in enums... Robert Klemme <shortcutter@googlemail.com> - 2013-11-15 20:10 +0100
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 17:29 +0000
Re: Fixing "typos" in enums... Robert Klemme <shortcutter@googlemail.com> - 2013-11-18 19:38 +0100
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 19:34 +0000
Re: Fixing "typos" in enums... Jan Burse <janburse@fastmail.fm> - 2013-11-16 10:16 +0100
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 18:25 +0000
Re: Fixing "typos" in enums... Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-18 13:45 -0500
Re: Fixing "typos" in enums... Robert Klemme <shortcutter@googlemail.com> - 2013-11-18 20:20 +0100
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-18 20:09 +0000
Re: Fixing "typos" in enums... Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-18 17:00 -0500
Re: Fixing "typos" in enums... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-11-19 15:39 +0000
Re: Fixing "typos" in enums... Arivald <NOSPAMarivald@interia.pl> - 2013-11-19 00:29 +0100
Re: Fixing "typos" in enums... lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-11-19 11:14 +0000
csiph-web