Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying out Test-Driven Development

After reading this post I kinda felt in the same position as the guy who asked the question. I love technology and coming up with new ideas to solve real world problems just gets my neurons horny, but the other part of the equation - actually getting things done (fast) - is normally a pain in the ass to accomplish, specially when I'm doing this for myself.

Sometimes I kinda feel plain bored with code, some other times I spend more time moving the cursor in the text editor and staring at my code, trying to come up with a solution that is better than the one I already have. I heard this is a disease called perfectionism.

I've read in that same post (and also a few times here on SO too) that TDD is actually good to stop coding like a girl, however I've never given a chance at TDD - either because I'm too lazy to learn / set it up or because I don't think I need it because I can do all the tests I need inside my head.

  • Do you also believe that TDD actually helps to GTD?
  • What do I need to know about TDD?
  • What about alternatives to TDD?
  • What would be the best methodology to organize / develop a TDD web app?
  • What libraries should I use (if any) to make my life easier?

PS: I'm primarily (but not exclusively) working with PHP here.

like image 309
Alix Axel Avatar asked Sep 01 '09 03:09

Alix Axel


People also ask

How hard is test driven development?

TDD requires highly skilled developers. It takes time and practice to get good at it and there can be some frustration along the way. However, after you've developed the habits, it's an incredibly rewarding way of developing systems.

What are the 3 steps of test driven development?

“Test-driven development” refers to a style of programming in which three activities are tightly interwoven: coding, testing (in the form of writing unit tests) and design (in the form of refactoring).


1 Answers

Personally I think TDD is at best overkill and at worst an impediment to a the creative process of programming. Time that is spent laboriously writing unit tests for each as yet unwritten methods/classes would be better spent solving the original problem. That being said I am a big fan of unit tests and believe wholeheartedly in them. If I have a particularly complex or troublesome piece of code I'm more than happy to write 20 unit tests for a single method but generally AFTER I have solved the problem. TDD, just like every other programming paradigm, is no silver bullet. If is suits you use it if not keep looking.

But take my opinion with a grain of salt. A much more interesting one comes from Kent Beck and How deep are your unit tests?.

like image 171
sipsorcery Avatar answered Oct 05 '22 17:10

sipsorcery