You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2015/01/04 19:58:13 UTC

[IMAGING] Constant interfaces vs. constant classes

Hi all,

imaging has a lot of constant interfaces and even the
org.apache.commons.imaging.formats.tiff.constants.AllTagConstants interface
which combine several interfaces.

I'm in the "no constant interfaces" group. An interface should be used to,
well, define an interface. Defining interfaces only for the purpose of
holding constants doesn't really make sense imho. I would like to use
constant classes instead. Using static imports, the use of constants in the
code will look the same as before.
Further more, logic that is currently contained in the TagConstantUtils
class (for example mergeTagLists, can be moved to the corresponding
Constant class as private static method, which will also remove it from the
public API.

I'd like to here what others think about this, since I expect this to be
partly a question of taste.

Regards,
Benedikt

-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: [IMAGING] Constant interfaces vs. constant classes

Posted by Benedikt Ritter <br...@apache.org>.
I've created https://issues.apache.org/jira/browse/IMAGING-156 to track
this change.

2015-01-04 21:12 GMT+01:00 sebb <se...@gmail.com>:

> +1
>
> On 4 January 2015 at 19:15, Gary Gregory <ga...@gmail.com> wrote:
> > +1: Interfaces should be used to define contracts, not constants. I like
> > using classes to define constants.
> >
> > Gary
> >
> > On Sun, Jan 4, 2015 at 1:58 PM, Benedikt Ritter <br...@apache.org>
> wrote:
> >
> >> Hi all,
> >>
> >> imaging has a lot of constant interfaces and even the
> >> org.apache.commons.imaging.formats.tiff.constants.AllTagConstants
> interface
> >> which combine several interfaces.
> >>
> >> I'm in the "no constant interfaces" group. An interface should be used
> to,
> >> well, define an interface. Defining interfaces only for the purpose of
> >> holding constants doesn't really make sense imho. I would like to use
> >> constant classes instead. Using static imports, the use of constants in
> the
> >> code will look the same as before.
> >> Further more, logic that is currently contained in the TagConstantUtils
> >> class (for example mergeTagLists, can be moved to the corresponding
> >> Constant class as private static method, which will also remove it from
> the
> >> public API.
> >>
> >> I'd like to here what others think about this, since I expect this to be
> >> partly a question of taste.
> >>
> >> Regards,
> >> Benedikt
> >>
> >> --
> >> http://people.apache.org/~britter/
> >> http://www.systemoutprintln.de/
> >> http://twitter.com/BenediktRitter
> >> http://github.com/britter
> >>
> >
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: [IMAGING] Constant interfaces vs. constant classes

Posted by sebb <se...@gmail.com>.
+1

On 4 January 2015 at 19:15, Gary Gregory <ga...@gmail.com> wrote:
> +1: Interfaces should be used to define contracts, not constants. I like
> using classes to define constants.
>
> Gary
>
> On Sun, Jan 4, 2015 at 1:58 PM, Benedikt Ritter <br...@apache.org> wrote:
>
>> Hi all,
>>
>> imaging has a lot of constant interfaces and even the
>> org.apache.commons.imaging.formats.tiff.constants.AllTagConstants interface
>> which combine several interfaces.
>>
>> I'm in the "no constant interfaces" group. An interface should be used to,
>> well, define an interface. Defining interfaces only for the purpose of
>> holding constants doesn't really make sense imho. I would like to use
>> constant classes instead. Using static imports, the use of constants in the
>> code will look the same as before.
>> Further more, logic that is currently contained in the TagConstantUtils
>> class (for example mergeTagLists, can be moved to the corresponding
>> Constant class as private static method, which will also remove it from the
>> public API.
>>
>> I'd like to here what others think about this, since I expect this to be
>> partly a question of taste.
>>
>> Regards,
>> Benedikt
>>
>> --
>> http://people.apache.org/~britter/
>> http://www.systemoutprintln.de/
>> http://twitter.com/BenediktRitter
>> http://github.com/britter
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

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


Re: [IMAGING] Constant interfaces vs. constant classes

Posted by Gary Gregory <ga...@gmail.com>.
+1: Interfaces should be used to define contracts, not constants. I like
using classes to define constants.

Gary

On Sun, Jan 4, 2015 at 1:58 PM, Benedikt Ritter <br...@apache.org> wrote:

> Hi all,
>
> imaging has a lot of constant interfaces and even the
> org.apache.commons.imaging.formats.tiff.constants.AllTagConstants interface
> which combine several interfaces.
>
> I'm in the "no constant interfaces" group. An interface should be used to,
> well, define an interface. Defining interfaces only for the purpose of
> holding constants doesn't really make sense imho. I would like to use
> constant classes instead. Using static imports, the use of constants in the
> code will look the same as before.
> Further more, logic that is currently contained in the TagConstantUtils
> class (for example mergeTagLists, can be moved to the corresponding
> Constant class as private static method, which will also remove it from the
> public API.
>
> I'd like to here what others think about this, since I expect this to be
> partly a question of taste.
>
> Regards,
> Benedikt
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory