Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

chromatic
  (email not shown publicly)
http://wgz.org/chromatic/

Blog Information [technorati.com] Profile for chr0matic [technorati.com]

Journal of chromatic (983)

Wednesday December 19, 2007
08:30 PM

Repetition-Driven Development

[ #35156 ]

Less code is not necessarily more readable (and it's often less maintainable). I much prefer

draw(Rectangle rect, Point point)

over

draw(rect, point)

Notwithstanding the fact that the former enables automatic refactoring and easy browsing while hardly anything can be deduced from the latter.

a comment by Cedric Beust on his Continuous Tax

Read the examples carefully for a moment. Do you notice anything amusing? I'll give you a hint. How much more maintainable would the first example be with only one simple change?

draw(Rectangle rectangle, Point point)

There. That's much much better better. It almost doesn't need a comment.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Of course that should really be

    drawRectangleAtPoint(Rectangle rectangle, Point point)
    "Draw" is such a vague name...
    • Or:

        rectangle.drawAt( point )
      • You must be a Perl hacker. The compiler can't enforce and your IDE can't infer anything about rectangle or point. What if someone accidentally passed in a BouncyBall? It's like the end of Watchmen all over again.

        • "Ok?"
          ^rectangle drawAt: point
          • Just meaning, I get a pretty awesome IDE in Smalltalk but all I can infer about rectangle is that it responds to the draw: method.
            • Smalltalk had an IDE? It's impossible to write an IDE for a dynamic language! Now Eclipse, that's an IDE.

              (Before anyone responds, ask yourself "Hey, why did he mention Eclipse and Smalltalk together?")