Re: A little concept puzzle (involving refactoring)
On 12/17/2013 12:16 PM, 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.?
I'm a little cog in a big machine, so my opinion carries little weight.
But that Fowlerian usurpation of the definition of a useful word to suit
his own opinions is not something I am all that happy about. It's an
overly constraining term, it's impractical, and it doesn't conform to
real life. What's a system? What's external behaviour? The entire list
of refactoring techniques is heavy on changing interfaces, at every
level of an application.
Don't get me wrong, I recognize the value of the espoused techniques.
But the definition is impractical. The extent to which it is ignored, in
the real world, is not an example of "an exception that proves the
rule", it's more like the rule is badly flawed.
I don't think Martin Fowler is an idiot, nor that we as software
developers shouldn't at least pay some attention to his musings. I don't
ignore what the GOF guys say either, or what Josh Bloch had to say, or
what Scott Meyers or Herb Sutter or Andrei Alexandrescu have to say, or
what Brian Goetz says, or Thomas Erl, etc etc etc.
But let's keep some perspective here. My apologies to Martin Fowler for
using him as an example. The man is a few years younger than I am, and
he started programming - according to his bio - well after me (or a
bunch of guys I went to school with, for that matter). Barely a decade
after he started FT work he wrote his first book. I'll give him credit,
he's articulate and he's obviously not stupid. Is he infallible like the
Pope? I daresay no more so than a dozen IT guys I can think of off the
top of my head who have more real world experience than he does...just
saying. But nobody's heard of these other guys because they ain't
writing books or going to conferences.
How many people here were experienced programmers when the original GoF
book came out? If you were like me, you may have read that book and
exclaimed to yourself, Boy, I've been doing half that shit all along but
it sure is nice to see my thinking validated. Now, it was fantastic that
those guys wrote that book, but it's seriously irksome to listen to all
the younger programmers who think that Gamma, Helm, Johnson and
Vlissides actually *invented* the patterns.
I have rather more basic terminology to describe what Fowler labelled as
"refactoring". Back in the day - believe it or not software
practitioners were this enlightened in the '60's and '70's even - we
called it maintenance. That term covers everything he is talking about.
AHS
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift