Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Enums: Properties vs. Methods Date: Tue, 29 Mar 2011 09:26:36 -0700 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <2f38bb8e-9a8d-4464-ad3d-b9ce0b557219@e21g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 29 Mar 2011 16:26:39 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="mZZsLHtx2uLqa4fpyB5uww"; logging-data="8482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aCjvwcuUTE2xZqKvMydU48S8yhkp9d7Y=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <2f38bb8e-9a8d-4464-ad3d-b9ce0b557219@e21g2000yqe.googlegroups.com> Cancel-Lock: sha1:k5b4TFqy/d5h073Ov2B1EDoNa8Y= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2552 On 3/29/2011 8:18 AM, Robert Klemme wrote: > /** We use custom methods. */ > public enum Meth { I agree with Lew that this second example was pretty confusing and hard to follow. I also think that it's difficult to predict memory usage without careful analysis. I'd like to see a "motivating" example. What do you actually intend to use this for? I can't see that a general case is too interesting, except to disqualify the method pattern. > Then different > enums can have differing implementations of the method and we have an > instance of Strategy / State pattern. I don't think State works this way. Strategy ... maybe, but the use of enums for Strategy seems confining. I'd just use regular inheritance and classes. The "method pattern" for Strategy would be fine I think if it weren't shoe-horned into an enum. > Full toy class https://gist.github.com/892503#file_prop_vs_meth.java I'll check it out.