commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Feist (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COLLECTIONS-276) *Utils classes should not be extensible or able to be instantiated.
Date Thu, 01 May 2014 10:36:14 GMT

    [ https://issues.apache.org/jira/browse/COLLECTIONS-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13986486#comment-13986486
] 

Daniel Feist commented on COLLECTIONS-276:
------------------------------------------

While you points in your original proposal are valid, the use case that you have ignored is
where a Util* class is extended and additional static methods are added.  We do this with
most, to avoid having two different MapUtils classes, one with the commons methods and one
with ours.  See: https://raw.githubusercontent.com/mulesoft/mule/477feb5e0c5df246865501eb995cf0b2e7e07bc2/core/src/main/java/org/mule/util/MapUtils.java

I propose these constructors be protected to avoid instantiation but allow extension.



> *Utils classes should not be extensible or able to be instantiated.
> -------------------------------------------------------------------
>
>                 Key: COLLECTIONS-276
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-276
>             Project: Commons Collections
>          Issue Type: Improvement
>    Affects Versions: 3.2
>            Reporter: Stephen Kestle
>            Priority: Minor
>
> I don't see any good reason why this CollectionUtils (and others) isn't final with a
private constructor.  There are no non-static methods, and any extension of them is going
to have to call through to the super to avoid compiler warnings.
> e.g. MyCollectionUtils.select() will provoke the warning that "static methods should
be called directly" (on CollectionUtils).
> Which would mean
> MyCollectionUtils{
> public static Collection select(){
>     return CollectionUtils.select();
> }
> Which really defeats the purpose.  In Java5, we have static imports now -  these provide
more benefit than previous extension did anyhow.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message