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


Groups > comp.lang.java.programmer > #26996 > unrolled thread

Re: A little concept puzzle (involving refactoring)

Started byDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
First post2013-12-19 12:18 -0800
Last post2013-12-19 12:18 -0800
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.


Contents

  Re: A little concept puzzle (involving refactoring) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-12-19 12:18 -0800

#26996 — Re: A little concept puzzle (involving refactoring)

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2013-12-19 12:18 -0800
SubjectRe: A little concept puzzle (involving refactoring)
Message-ID<3wIsu.5892$543.1458@fx02.iad>
On 12/17/13 8:16 AM, 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?
>
>    PS: Here's a quotation from the book »Refactoring« by Martin
>    Fowler at al.:
>
>        »Refactoring is the process of changing a software
>        system in such a way that it does not alter the external
>        behavior of the code yet improves its internal structure.«
>
Behavior and outcome are not the same thing. You're preconditions are 
different, and therefor your test is invalid.

  Math.random() explicitly uses 
http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#Random(), 
which implicitly takes "time" as a precondition.

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web