directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <seelm...@apache.org>
Subject Re: Code review - constants in interface
Date Mon, 22 Nov 2010 16:42:45 GMT
On Mon, Nov 22, 2010 at 5:09 PM, Hammond, Steven
<Steven.Hammond@polycom.com> wrote:
> Maybe I am off, but I thought other classes already cannot inherit from it, because it
has a private constructor.

Oh, yes, you are right, thanks for the hint. Seems I have to give back
my Java diploma ;-)

> -----Original Message-----
> From: mail@stefan-seelmann.de [mailto:mail@stefan-seelmann.de] On Behalf Of Stefan Seelmann
> Sent: Monday, November 22, 2010 7:58 AM
> To: Apache Directory Developers List
> Subject: Re: Code review - constants in interface
>
> On Mon, Nov 22, 2010 at 2:50 PM, Guillaume Nodet <gnodet@gmail.com> wrote:
>> AFAIK, the best pattern for that is to use a final with a private
>> constructor and declare public static final fields in it.
>>
>> public class Constants {
>>        private Constants() {
>>                // non-instantiable class
>>        }
>>
>>        public static final String TYPE = "type";
>> }
>
> Sounds good. One additional improvement would be to declare the class
> as final, just to avoid that other classes inherit from it.
>
> Kind Regards,
> Stefan
>

Mime
View raw message