commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <dgraham1...@hotmail.com>
Subject Re: [math] design patterns (was Re: cvs commit: jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat UnivariateImpl.java)
Date Thu, 19 Jun 2003 18:06:11 GMT

>--- David Graham <dgraham1980@hotmail.com> 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).
>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.

David

 >  To deal
>with the language limitation, it is sometimes a good idea to declare what
>really are class methods as non-static.
>
>Phil
> >
> > David
> >
> > _________________________________________________________________
> > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> > http://join.msn.com/?page=features/virus
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.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
>

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message