Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26967

Re: A little concept puzzle (involving refactoring)

Date 2013-12-17 16:56 +0000
From lipska the kat <"lipskathekat at yahoo dot co dot uk">
Organization Trollbusters 3
Newsgroups comp.lang.java.programmer
Subject Re: A little concept puzzle (involving refactoring)
References <refactor-20131217165545@ram.dialup.fu-berlin.de>
Message-ID <lI6dnUvIQtnFHy3PnZ2dnUVZ7sWdnZ2d@bt.com> (permalink)

Show all headers | View raw


On 17/12/13 16:16, Stefan Ram wrote:
>    Here is a little puzzle about the definition of concepts:
>
>        /The behavior/ of a program I call what can be observed
>        from the outside by running the program.
>
>        /A refactor/ I call a modification of the source code of
>        a program that does not change the behavior of the program.
>
>    Now, let's test these concepts!
>
> public class Main
> { public static void main( final java.lang.String[] args )
>    { final double value = java.lang.Math.random();
>      java.lang.System.out.println( value ); }}
>
> 0.8262472065326088
>
>    Now apply the modification
>    »renameLocalVariable("value","number")«:
>
> public class Main
> { public static void main( final java.lang.String[] args )
>    { final double number = java.lang.Math.random();
>      java.lang.System.out.println( number ); }}
>
> 0.4774192830734339
>
>    The behavior has changed - so that was not a refactor!
>
>    Should we see it this way or modify our definitions?

<snip>

You're kidding right?

public class Refactor {
	
    public static double cube(double i){
       return i * i * i;
    }

    public static void main(String[] args) {
       System.out.println(cube(3.6));
    }

}

===> refactor cube <===

public class Refactor {
	
    public static double cube(double i){
       return Math.pow(i, 3);
    }

    public static void main(String[] args) {
       System.out.println(cube(3.6));
    }

}



-- 
Lipska the Kat©: Troll hunter, sandbox destroyer,
treacherous feline and farscape dreamer of Aeryn Sun
GNU/Linux user #560883 - http://www.linuxcounter.net

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: A little concept puzzle (involving refactoring) lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-17 16:56 +0000

csiph-web