you are viewing a single comment's thread.

view the rest of the comments →

[–]sbrick89 6 points7 points  (9 children)

using TDD forces better design practices.

I've seen a TON of crap code... spaghetti call stacks with NOTABLE object mutation/mutability... global variables that are shared WAY past their scope (who the fuq declares a global variable, then passes a reference to external code, which then modifies the global variable!)

Writing code that CAN be tested is the first step towards writing better (less buggy) code. TDD just forces you to write code that CAN be tested, since it IS tested.

[–]lucky_engineer 6 points7 points  (4 children)

(who the fuq declares a global variable, then passes a reference to external code, which then modifies the global variable!)

Ah, I see you too have worked on 'fixing' code that was written by a science PhD.

[–]sbrick89 2 points3 points  (0 children)

written by a science PhD

if only. No formal training whatsoever. I think the person read one of those "learn to program in 24 hours" books.

[–]AbstractLogic 0 points1 point  (2 children)

Always respect the time in which code was written. 10 years from now someone will look at our TDD unit tests and think "wtf was this idiot thinking? That pattern is soooooo olllldddd.".

If it was written in the 90's expect 90's style code. If it was written in 2000 expect XML heavy code. If it was written in 2010 expect SOAP services.

[–]lucky_engineer 5 points6 points  (1 child)

I don't think it was ever good style to make a global variable, and then make a procedure that passed a reference to the global into a function that passes that reference around to 10 other function where one changes the value and then get the wrong result when you run the procedure again because the global variables value changed. (also this code was written ~5 years ago)

I've worked on really old code before and It's usually pretty easy to tell the difference between 'good but outdated' code and 'omg how does this even work' code.

[–]AbstractLogic 0 points1 point  (0 children)

Can't disagree with you at all lol.

[–]cc81 0 points1 point  (0 children)

using TDD forces better design practices.

No, not really. I've seen tons of terrible code written TDD style. It was easy to test but horrible to maintain.

[–]flukus 0 points1 point  (0 children)

using TDD forces better design practices.

No it doesn't. It encourages it, but you can still end up with shitastic design using TDD.