Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 38143 invoked from network); 19 Jun 2003 19:55:35 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 19 Jun 2003 19:55:35 -0000 Received: (qmail 5910 invoked by uid 97); 19 Jun 2003 19:57:59 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 5903 invoked from network); 19 Jun 2003 19:57:58 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 19 Jun 2003 19:57:58 -0000 Received: (qmail 37392 invoked by uid 500); 19 Jun 2003 19:55:28 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 37305 invoked from network); 19 Jun 2003 19:55:28 -0000 Received: from web41313.mail.yahoo.com (66.218.93.62) by daedalus.apache.org with SMTP; 19 Jun 2003 19:55:28 -0000 Message-ID: <20030619195533.48487.qmail@web41313.mail.yahoo.com> Received: from [65.213.54.59] by web41313.mail.yahoo.com via HTTP; Thu, 19 Jun 2003 12:55:33 PDT Date: Thu, 19 Jun 2003 12:55:33 -0700 (PDT) From: Al Chou Subject: Re: [math] design patterns To: Jakarta Commons Developers List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --- David Graham wrote: > >--- David Graham wrote: > > > > > Maybe I'm unique, but > > > > > sometimes I find that Java (as well as other languages) gets in my > >way > > > >rather > > > > > than letting me solve the problem at hand in a natural way. > > > > > > You're not alone in that belief. I've heard several people comment > >about > > > how easy it is to code Smalltalk when exploring new solutions. > > > > > > > >For example, one > > > > > thing I would have liked to see is the ability to invoke methods by > >the > > > >same > > > > > name either via static class methods or via instance methods of > >objects > > > > > (where > > > > > appropriate and useful, of course). I don't have enough experience > >with > > > >Java > > > > > to know if that's possible, though I suspect it would be difficult > >at > > > >least. > > > > > > Static methods are a necessary evil in OO languages and should be > >avoided > > > when possible. The entire Java Math class is a perfect example of poor > > > design because it's just a bunch of static methods. > > > It would have been > > > *much* simpler to make numbers objects and allow -1.abs() type > >semantics. > > > Anyways, my main point is that statics exist in Java to make certain > >things > > > easier, not to allow the type of thing you describe. > > > >I disagree. IMHO, in good OO design there is a place for utility classes > >that > >encapsulate operations on objects, apart from the objects themselves. > >Call me a brute, but Math.max(x,y) is more natural syntax to me than > >x.max(y). I agree that max(x,y) is more natural than x.max(y), but there are cases where the latter style of syntax might seem right. An example (perhaps not the best) that Java provides is the instance method Double.isInfinite(). > >The reason to avoid static methods in Java, IMHO, is that they cannot be > >overriden, not that using utility classes in general is "bad design". > > Exactly. Any time you need a utility class with static members you can > replace it with a Singleton object with non-static methods. A singleton doesn't provide non-overridability of the methods, does it? I guess if they're final methods, then it does. Al ===== Albert Davidson Chou Get answers to Mac questions at http://www.Mac-Mgrs.org/ . __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org