Which is why the use of an interface instead of a class makes no
sense.  It merely makes bad coding possible and does nothing else for
you.

Jack


On Sat, 22 Jan 2005 17:11:53 +0100, Leon Rosenberg
<[EMAIL PROTECTED]> wrote:
> 
> I wouldn't say it's a question of preference, the 'second approach' is an
> absolute NOGO and banned by each and every code conventions and code style
> book.
> 
> Regards
> Leon
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Frank W. Zammetti [mailto:[EMAIL PROTECTED]
> > Gesendet: Samstag, 22. Januar 2005 16:59
> > An: Struts Users Mailing List
> > Betreff: Re: constants interface
> >
> > I'm not sure there's a "better" answer... I'd say I see the first
> > approach used more often... In fact, I'm not sure I can think of an
> > instance where I've seen the second approach *IF* we're talking about an
> > interface specifically for storing constants... Obviously when your
> > extending an interface the second approach is probably the norm (i.e.,
> > most of the time I doubt anyone writes MyInterface.YES in that
> > WayTwo.myMethod() below).
> >
> > My own preference would be for the first approach.  I'm a fan of code
> > that is as obvious in meaning as possible.  The first approach tells me
> > pretty clearly that I'm referencing a field of the MyInterface class,
> > the only question I have to answer then is if it's a static field or if
> > MyInterface is actually a poorly-named instance of something.  In the
> > second approach, I could be dealing with a local variable, a class
> > member, or something inherited.  The difference isn't severe I think,
> > but the first seems just slightly more intuitive, and that's always a
> > good thing to me.
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> >
> > Carl Smith wrote:
> > > In Java, sometimes you would define an interface containg the constants:
> > >
> > > public interface MyInterface {
> > >     public static final String YES = "yes";
> > > }
> > >
> > > To access the contants, there are two ways
> > >
> > > public class WayOne {
> > >     public void myMethod(){
> > >            String yes = MyInterface.YES;
> > >            //...
> > >     }
> > > }
> > >
> > > public class WayTwo implements MyInterface {
> > >     public void myMethod(){
> > >            String yes = YES;
> > >            //...
> > >     }
> > > }
> > >
> > > I am asking which one is better? Or they are Ok and depend on the
> > developer 's flavor?
> > >
> > >
> > >
> > > signature
> > >
> > > ---------------------------------
> > > Do you Yahoo!?
> > >  Yahoo! Search presents - Jib Jab's 'Second Term'
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
------------------------------

"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to