Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26967 > unrolled thread
| Started by | lipska the kat <"lipskathekat at yahoo dot co dot uk"> |
|---|---|
| First post | 2013-12-17 16:56 +0000 |
| Last post | 2013-12-17 16:56 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.java.programmer
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: A little concept puzzle (involving refactoring) lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-17 16:56 +0000
| From | lipska the kat <"lipskathekat at yahoo dot co dot uk"> |
|---|---|
| Date | 2013-12-17 16:56 +0000 |
| Subject | Re: A little concept puzzle (involving refactoring) |
| Message-ID | <lI6dnUvIQtnFHy3PnZ2dnUVZ7sWdnZ2d@bt.com> |
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 top | Article view | comp.lang.java.programmer
csiph-web