Home » Posts tagged "tdd"

What If Unit Testing Wasn’t Necessary? #noTDD

I recently read (yet another) post proposing that TDD “doesn’t work” and that we shouldn’t use it, or should use it very little.  What was shocking about this article wasn’t the content, but the fact that it is hosted on a Microsoft site.

While I’m not entirely on board with throwing out TDD, the one thing I will agree to is that learning TDD is difficult.  I am also willing to admit that, to a large extent, TDD is broken.  If you’ve been following my post for a while, this SHOULD be shocking news.

And so, I’ve been thinking.  Maybe we’ve been asking the wrong question.  Maybe, instead of asking “How do we encourage people to implement TDD?”  We should be asking, “How do we make TDD either unnecessary, or trivial to implement?”

What If Unit Testing Wasn't Necessary? #noTDD
Photo credit: abraham.williams via VisualHunt.com / CC BY-SA

Continue reading “What If Unit Testing Wasn’t Necessary? #noTDD”

The Myth of Sloppy Code

  • Tightly coupled code runs faster.
  • Tightly coupled code is easier to write.
  • Test Driven Development increases development time.
  • Test Driven Development negatively impacts code design.
  • Knowing the names of design patterns isn’t important as long as you can use them.
  • All my customer cares about is how soon they can have the product, not how clean the code is.

All of these statements, and others like them, are excuses for not writing code correctly.  And you know what an excuse is, right?

The skin of a reason stuffed with a lie.

The Myth of Sloppy Code
Photo credit: dynamosquito via Visualhunt.com / CC BY-SA

 

Continue reading “The Myth of Sloppy Code”

4 Reasons to Write Loosely Coupled Code

This past week I got into a small discussion about the importance of loosely coupled code.  Specifically, I was looking at event handler code that did nothing more than change the size of another element on the screen.  But the event handler code was in the controller which in the particular implementation we are using was the event handler portion of our Model in a MVVM architecture.  The question becomes does this code belong in the view, or does it belong in the controller?

The question of where code belongs leads eventually to arguments for loosely coupled code.  If I put code in my controller that is manipulating the view, then I either need to mock out my view in order to test my controller or I have to have an instance of my view available to test my controller.  Having coded enough systems to know that both of those choices are problematic, I opt for placing the view specific code in the view.  Another place where you might place this code would be in a View Specific event handler class.  But that would only be for the purposes of clean separation.  Something we might consider doing if the View were plain HTML.  But in our particular case, the view is generated from code, so placing the handlers in that same code seems to be the most appropriate location for it.

But all of this leads to a larger question.  Why should your code be loosely coupled at all?

4 Reasons to Write Loosely Coupled Code
Photo credit: Hernan Piñera via VisualHunt.com / CC BY-SA

Continue reading “4 Reasons to Write Loosely Coupled Code”

8 Reasons Johnny Does Not Write Bug Free Code

There have been a number of things that have occurred over the last week that have prompted this particular post.  And for anyone I work with, this is not an indictment of our work place so much as it is an indictment of our industry.  PLEASE don’t take this personally.

Some of those reasons will show up in this article.  But the question we need to examine today is why is it so hard to write bug free code.  And I’m not even talking about perfection.  Why is it that we miss the simple stuff?  The stuff that once it is found, we think, “how could we have missed that?!”.  I’m perfectly aware that all code has bugs some just haven’t been found yet.  I’m also aware that no matter how hard I try, the stupid bugs always make their way past my desk.

8 Reasons Johnny Does Not Write Bug Free Code
Photo credit: ~Pawsitive~Candie_N via Visualhunt / CC BY

Continue reading “8 Reasons Johnny Does Not Write Bug Free Code”

Test Driven Development Kata – Roman to Arabic in JavaScript

Coding Katas are a way of developing your skills as a programmer.  I thought it might be informative to tackle one of the classics as a blog post. Depending on how this works, I may or may not do another one quite so publicly.

The rules I’m going to try to adhere by.

  1. I will document what I am doing as I go.
  2. This is not a pre-coded blog post.  You’ll get to “see” me code as I go.
  3. I will write all tests first.
  4. I will only write enough code to make the current tests succeed.

 

Test Driven Kata - Roman to Arabic

Continue reading “Test Driven Development Kata – Roman to Arabic in JavaScript”