point taken :-)

Avi

"Jacques Morel" <[EMAIL PROTECTED]> wrote in message
ai8t4b$rfp$[EMAIL PROTECTED]">news:ai8t4b$rfp$[EMAIL PROTECTED]...
> I agree with Thomas not because he seems singled out but for the following
> reason:
> You do not necessarily introduce a constant right off the bat. You may
wait
> to have duplication and then you refactor and introduce a constant.
> Conversely you might arrive at a point where you only have 1 usage of the
> constant. At that point it is reasonable to want to inline it to make the
> code more readable.
> In general I would like all refactoring to have their inverse:
> introduce/extract XXX - inline XXX.
> Let's not forget that a refactoring is just a tool. How you could use it
to
> do harm doesn't decrease its usefulness used properly.
>
> Jacques
>
> "Thomas Singer" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > This seems to me to promote the bad programming habit of using values
> > > instead of constants.
> >
> > No, this is wrong. A better example:
> >
> > ======================= Example A =========================
> > public class Test {
> >
> >    private static final String HELLO_WORLD = "Hello world";
> >
> >    public static void main(String[] arguments) {
> >       System.out.println(HELLO_WORLD);
> >    }
> > }
> > ======================= Example B =========================
> > public class Test {
> >
> >    public static void main(String[] arguments) {
> >       System.out.println("Hello world");
> >    }
> > }
> > ===========================================================
> >
> > Now decide, what is better readable.
> >
> > Tom
> >
> >
> > On Tue, 30 Jul 2002 22:59:02 +0300, "Avi Rosenschein"
> > <[EMAIL PROTECTED]> wrote:
> >
> > > -1
> > >
> > > This seems to me to promote the bad programming habit of using values
> > > instead of constants. The whole purpose of the constant is to increase
> > > readability, and to ease maintenance by making future changes only to
> the
> > > initialization and not every place you used that value. If you are
> getting
> > > rid of the constant in order to improve readability, you probably
aren't
> > > choosing good constants in the first place. Generally I would think
the
> best
> > > thing would be just to rename the variable.
> > >
> > > Also, to give it a name like "inline constants" seems to imply that
> there is
> > > some efficiency benefit to be gained by "inlining" constants in Java -
> which
> > > in this case there isn't.
> > >
> > > --Avi
> > >
> > > "Thomas Singer" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > > Just curious. Why would you want to do this? The compiler puts the
> > > > > constant value in place of the constant "variable" so there is no
> > > > > performance gain.
> > > >
> > > > Why we use the refactorings at all? To make the code more readable!
> > > >
> > > > > What you appear to want is that YES is like a #def in C/C++ and is
> > > > > inlined. This is not necessary in Java.
> > > >
> > > > As the name already suggests, the example is just an example.
> > > >
> > > > Tom
> > > >
> > > >
> > > > On Tue, 30 Jul 2002 21:33:43 +1200, Pete Hendry
<[EMAIL PROTECTED]>
> > > > wrote:
> > > >
> > > > > Just curious. Why would you want to do this? The compiler puts the
> > > > > constant value in place of the constant "variable" so there is no
> > > > > performance gain.
> > > > >
> > > > > What you appear to want is that YES is like a #def in C/C++ and is
> > > > > inlined. This is not necessary in Java.
> > > > >
> > > > > Pete
> > > > >
> > > > > Oh yeah, -1 :-)
> > > > >
> > > > > Thomas Singer wrote:
> > > > >
> > > > > > Since months, I would like to have the option to inline
> constants --
> > > > > > simply replacing their usage with their initialisation...
> > > > > >
> > > > > > Example:
> > > > > >
> > > > > > public static final Option YES = Option.YES;
> > > > > >
> > > > > > ...
> > > > > >   setOption(YES);
> > > > > > ...
> > > > > >
> > > > > > ==>
> > > > > >
> > > > > > ...
> > > > > >   setOption(Option.YES);
> > > > > > ...
> > > > > >
> > > > > > I know, I can do it with cut'n'paste, but I'm able to do each
> > > > > > refactoring with the help of cut'n'paste.
> > > > > >
> > > > > > Tom
> > > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>


_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-features

Reply via email to