Random software engineering thought of the day

Dec 18, 2006 21:49

One interesting concept that aegisknight uses to reason about code is the notion that duplication in source code is always inherently bad and should be attacked mercilessly at all times. This is an interesting idea in and of itself, but that's not the idea of the day. (besides, it's Chad's idea, not mine ( Read more... )

code

Leave a comment

Comments 4

aegisknight December 19 2006, 07:23:30 UTC
It's certainly not my idea either, since I took it from TDD and the TDD list. :) But it's fun to see how far you can apply it...

Until today, though, I'd never heard the hidden duplication argument. Does that mean that any duplication found in tests should be folded into the API?

Reply

hiretsukan December 19 2006, 15:11:00 UTC
At that point, wouldn't you be testing your tests? I'm not even sure if that's a bad idea. :D

Reply

thespeedbump December 19 2006, 15:57:50 UTC
I think it is more a matter of simply having a much more solid understanding of what your interface needs to be. If you're folding test code into the production API, it's probably because you didn't know you needed that functionality in production.

Besides, if you're doing TDD right, you test your tests every time you write a new one. If it's not red the first time you ran it, then it is probably broken. (the whole point is to use the test to determine that you've changed something successfully, so it should be red if you haven't changed anything yet)

Reply

thespeedbump December 19 2006, 15:55:27 UTC
Sometimes.

Writing the tests first can do things like expose the need for utility functions that you may not know that you need if the implementation only uses the functionality once. (or not at all!)

Reply


Leave a comment

Up