Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!feeder.erje.net!eu.feeder.erje.net!newsfeed.pionier.net.pl!news.dialog.net.pl!not-for-mail From: Arivald Newsgroups: comp.lang.java.programmer Subject: Re: Fixing "typos" in enums... Date: Tue, 19 Nov 2013 00:29:46 +0100 Organization: Dialog Net Lines: 49 Message-ID: References: NNTP-Posting-Host: dynamic-78-10-81-78.ssp.dialog.net.pl Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.dialog.net.pl 1384817385 11456 78.10.81.78 (18 Nov 2013 23:29:45 GMT) X-Complaints-To: abuse@dialog.net.pl NNTP-Posting-Date: Mon, 18 Nov 2013 23:29:45 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:26550 W dniu 2013-11-15 17:25, Andreas Leitgeb pisze: > Let's assume, some non native English speaker writes up > a library, that's really useful and gaining broader use. > > Now, the author may have once caught up some misspelling > of a common word (like e.g. thinking that "first" was > spelled "furst" and that with a confidence level ways > above "I'd better look this up"). > > Eventually this misspelling goes into an enum constant, > and by the time the first user reports it, the library > is already too much in use to lightheartedly apply > Plan "A" (namely fixing the typo and thereby inducing a > compatibility issue) > > Now, Plan B could be to rename the enum constant, but add > a public static field by the old bad name (initialized > with the reference to the spelling-corrected field), to > alleviate the compatibility issue at least for those who > merely used the enum's field's name in their code. > > // 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. > > I'd further denote "Just leave the typo in" as "Plan *Z*", > and ask for better strategies. (at least better than Plan Z) > > PS: I vaguely remember that even Sun Java had some typos in its > API, but that predated enums, so adding a second constant with > same value but corrected name was a triviality back then... > > PPS: a similar problem could arise with misspelled class names, > but that's not currently in my focus. > Leave current API as is. But with major upgrade of library, change package name (ex com.me.superlib => com.me.superlib2), and in new version use correctly spelled enums and other names. Anyone who switch to new version of library will need to adapt and refactor code anyway, so fixing misspelling wont be a problem. -- Arivald