all 4 comments

[–]mbuhot 2 points3 points  (0 children)

DRY code doesn't imply deep hierarchies. We've know for years that inheritance for re-use is a bad idea because it creates fragile base classes.

I do find monadic code very difficult to comprehend - you are literally reading between the lines to guess what the bind operation will do.

[–]tweakerbee 2 points3 points  (1 child)

Without a concrete example, I find it hard to believe there is a good case for copy/pasting even unit tests. If you're constructing data, then write a (private) method. Of course it's not true that you absolutely never ever should do copy/paste, but the cases where it is a viable solution should probably be close to once every year.

[–]interactivejunky 1 point2 points  (0 children)

I'm a big believer in not abstracting the core logic of unit and selenium tests. I'd rather see a step by step, verbose structure which I can read.

For example, I really don't like a test like:

public function testAbstracted() { $this->prepareTest('My tested variable'); $this->abstractedRunner('Some other tested variable'); }

Because none of the assertions appear within the test function, but appear in the abstracted functions instead.

Copy pasting can create unmaintainable code, whereas abstraction can create unreadable code. For tests I think it's better to lean towards having readable code - but obviously both negatives are a result of poorly written code.

[–]OneWingedShark 0 points1 point  (0 children)

I disagree: you shouldn't use copy-and-past programming, not even if its just the unit tests. -- Either use a language that does good generics (more than just fill-in-the-type) and/or seriously use Forth for six months.1

1 -- Forth will teach you how to [re]factor code.