why test driven development is “harder”

While I still don’t always do test driven development when coding at work, I do a lot of it.

I don’t always do TDD

  1. If I know the exact shape of the code before I start, it’s easier to create that shape before writing tests.  This happens a lot in web app development or when using generated code or certain framework.  I still write the tests with the code though. I think this happens because the interface I’m constrained by isn’t where I start thinking about the problem. When working on libraries or within a method/framework I do still TDD.
  2. For spikes.  If I have no idea how to approach something and just need to experiment.  I don’t know what tests to write because I don’t know what to do.

Ok, let’s suppose you’re working on an algorithm

This is something I find to be a great starting point for TDD.  It’s fairly obvious what the interface should be and most of the thought is on the implementation.  It is also a great example because you’ll want to try the same test cases repeatedly as you work making TDD save time.

Great, what makes TDD harder?

It’s not really.  The problem is when developers aren’t fluent in JUnit.  If the person coding isn’t good at writing tests, that becomes another thing to think about.  And when the mental load is higher, the task is harder.  The solution to this is to practice writing tests and get better at it.  Instead, some people merely complain that testing is hard and “expensive.”  Which becomes a sell fulfilling prophecy.

An example of how this affects me

I can think of three testing libraries that I’m at different levels of comfort with. And my reaction to writing a test in them. (just a regular test, forget about TDD here)

Library Comfort level Reaction
JUnit Fluent TDD, no problem.
HtmlUnit I have enough experience to know how to do common things and where I’m likely to hit a problem requiring more time. (I’m using it to test an app I didn’t write which makes things harder). While I’m comfortable writing tests, I’m limited for TDD.  I can definitely use TDD when fixing a bug.  But I couldn’t write a new screen that way.  I need the app to work enough to make sure my HtmlUnit test is right.
Selenium I know enough to know it changed a lot since I last used it. While my comfort level is a lot lower than HtmlUnit, I have the same feeling about TDD.  I could use it to fix a minor bug presuming there is enough app for me to test my Selenium code.  (And yes, Selenium as an HtmlUnit driver now which probably accounts for the similarity in reaction)

While I do have different feelings about TDD based on comfort level, one of the biggest differences is time.  It would take me a lot longer to write a Selenium test than a JUnit test.  That’s a sign that I need to practice/learn more/gain more experience.  Which is a perfectly normal part of coding.  We do need to plan for this.  Telling your developers to test with a tool they aren’t fluent in and not recognize it takes longer is a perfect way to invite no tests, poor tests or the quality of the code slipping.

Why was I thinking about this?

I’m working with someone on what I thought was an outline.  He suggested “I think a good way for us to communicate about these topics might be to first imagine …  questions we’ll want to ask”.  Kind of like TDD for an outline.  Think of what the student needs to know and get the “curriculum” from that.  I’ve never done that before and it was a lot harder than just writing an outline.  And I think the reasons it is “harder” are the same as for people new to TDD:

  1. A new way of thinking – I’ve never written questions before the objectives before.  People new to TDD aren’t used to thinking about how to test before they write the “real” code.
  2. Lack of experience with the “tool” – While I’ve written a fair number of questions, I’m by no means at the point that I feel fluent in doing so.  I’m probably just under where I feel with HtmlUnit in terms of experience there.  I know where many obstacles are but am still surprised often.
  3. More balls in the air – Just like thinking about both the tests and code in TDD, I had to think about both the questions and topics.

What is the takeaway

“Harder” doesn’t always mean harder.  Sometimes it means you need more skills and practice.  So if TDD seems “harder” to you, don’t run screaming.  You’ll get there.

jeanne on software – thoughts on Joel Spolsky’s “Smart and Gets Things Done”

A co-worker gave me a copy of “Smart and Gets Things Done” by Joel Spolsky.  It came out in 2007 so his thoughts might have changed since then.  Or not.  I have read Joel on Software so much of this isn’t new to me.  But I have more experience than I did in 2007 so it was interesting to see how I react to it now.

Banks

Over time, I’ve seen a number of references from Joel referencing banks or accounting systems as “boring” work. (I work for a bank.)  I almost would have been disappointed if that wasn’t in the book.  It was.  On page 16 – the very end of chapter 1 – Joel writes “That’s why the most satisfying careers, if you are a software developer, are at actual software companies, not doing IT for some bank.”

Maybe, maybe not.  I’ve worked on challenging projects at “some bank.”  I do think that it is important that the company values IT and has a development or IT group.  If it is literally “here’s what the trader wants now go and please him” I can see where Joel is coming from.

And I do agree that banks aren’t typically the early adopters of innovation.  I don’t want Chase experimenting with some new funky way of managing transaction integrity.  Their appetite for risk should be lower in that arena.  However, performance counts when doing a trade.  Amazon has to worry about scale with acceptable performance, but they don’t have to worry about the difference between a quarter of a second and a half a second on individual transactions.  Incidentally, Amazon is a “name” employer to work for and doesn’t produce software as it’s primary business of sales either.  (Although with Amazon Web Services and the like, you could argue it is a software house as one of it’s primary business.)

Paid interns

I’m glad to see that Joel pays his interns.  Interns don’t produce at the same level as experienced employees, but they do create value.  I remember being asked one summer if it was worth having an intern on our team.  The answer was yes.  It took about a month to get the intern independent enough to hit the break even point.  Leaving two months of progress.  There was some progress in the first month of course, but we were still within the “faster to do it myself than train” area then. I also like that Joel views interns as a recruiting channel.

I remember in college having an unpaid offer for an internship (with a small healthcare company) and a paid offer for an internship (with a large bank).  I chose the later.  While I didn’t end up working for that particular bank when I graduated (although I could have), it certainly got my foot in the door in that industry.  I also learned more because the larger company was set up to actually have their interns learn while producing rather than look at them as cheap labor for tasks they already know how to do.

Employee referrals

Joel feels that employee referrals are a very weak source of hires.  He says he will skip the phone screen, but that’s it.  I strongly agree that you should still interview referrals to make sure they are skilled, have good communication skills, fit, etc.

However, I disagree that employee referrals are a weak source of hires.  Personally, I’ve made two referrals in my career.  Or one depending on whether you count recommending someone for another team within the company.  Both are individuals I think are very good.  I wouldn’t recommend them otherwise.  It affects my reputation if I recommend someone bad.  And for the external one, we didn’t skip the interview.

There are different types of employee referrals though.  Both of mine were “I worked with this person and think she would be good on team X because.”  I wasn’t disappointed in either case.  By contrast a teammate recommended a friend that he never worked with.  I did the interview and declined to hire that individual.  However, this referral wasn’t “this person is awesome”.  It was “this person is easy to get along with and is a programmer”.    Yes, that’s a weak recommendation.  But no weaker than other sources.  It doesn’t make referrals  weak across the board.  And it shows the reputation thing I was talking about.  He gave an honest evaluation of the weakness in the referral.

Private offices vs team rooms

Joel is big on team rooms.  I have mixed feelings about this.  I don’t need quiet to work.  I do need to be left alone at times.  I like hearing coworkers conversations as you sometimes hear something important.  I like working collaboratively.  I don’t like bothering people with my conversations who prefer quiet.

To date, my favorite environment has been cubicles where teams were located in neighboring cubicles.  Or two to a well designed cube.  At both my summer internships and when my team had interns, I shared a cube.  But it was designed well.  The computer was in a corner with a desk on both sides.  (I needed to add a cardboard box to make that happen in one of these scenarios, but it still happened.)

I’ve never seen a proper team room in person though.  I’ve seen the “everyone bring their laptop to a table and hunch over.”  That’s horribly unproductive to me.  Having a keyboard/mouse/monitor at proper height and a second monitor makes me much more productive.  Yesterday, I made a comment to a teammate about not being able to imagine working in a team room full time because of this lack of setup problem.  He said that’s not what a real team room is.  And he’s right.  I googled team room and found this and this.  Unfortunately, I also found this. I started a thread at CodeRanch to discuss the topic of team rooms.

Passion at Interviews

Joel writes about how being passionate about a topic gets rid of nervousness at an interview.  I remember at one of the interviews for my current job, I argued that pair programming works well when two people have approximately the same skill/knowledge level, but not when one person is a lot more experienced.  (I no longer hold that believe for anyone curious.)  I completely forgot I was at an interview during this conversation.  So yes, being passionate about a topic gets rid of nervousness.

certified scrum master

Passed the CSM (Certified Scrum Master) exam today with 34/35 correct which is 97.1%,

The Certified Scrum Master certification requires:

  • taking a two day class _ I like that the instructor made it electronic device free and threatened not to give credit to anyone mentally absent.
  • taking an online, unproctored test

About the test

The test is described well here.  The gist is that it is untimed, open book, unproctored and you don’t have to take it in one sitting.  The idea is clearly to reinforce what you learned in the class and ensure you were paying attention.  You need to get 24/35 correct which is about 68%.  You get 2 attempts and are given the correct answers once you pass.  If you need more attempts, they are $25 each.  Per the Scrum Alliance, the test is a mix of multiple choice and true/false.  (Or so the docs say – I didn’t get any true/false ones). It covers General Scrum knowledge, Scrum roles, Scrum meetings, and Scrum artifacts.

Once you pass, you are considered certified for 2 years at which point they ask you to pay $100 for another two years.  (by tying certification and membership together)

Some quotes indicated the test is really easy and more of a formality.  I agree that it is easy if you paid attention in class.  It is a good way to reinforce what you learned though.  “Certification” is probably too strong a word here.

My background

I’ve been doing parts of Scrum for about 2 years.  (The product owner isn’t as involved as he should be to actually call it Scrum.)  The point is that the material isn’t new to me.

Registering for the test on an iPad and popups

After the course, you get a link to the Scrum Alliance. At this point, you can take the test. It is offered in a number of different languages and run by mytestcom.net. I started the test on my iPad and quickly learned it requires you to allow pop ups. Went into ipad settings > safari and turned off block pop ups. It wasn’t immedidately obvious how to retry the pop up. But going back to the testcom homepage gave a clear link saying I was in the middle of a test. Then the iPad prompted me for whether to allow the pop up. I said yes, and was in.

Resuming the test on a ChromeBook and popups

WARNING: Don’t switch computers for the test.  Your bookmarks (questions to go back to) are stored in a cookie and not available on the second device.

I did half the test on my iPad and finished it up on a ChromeBook computer.  When I logged into Scrum Alliance with the ChromeBook, the button says “take CSM test in English”.  Which is fine.  But then the JavaScript says “are you sure you want to start the CSM test.”  Which I didn’t.  I wanted to resume.  Turns out that link is misleading and it does take you to resume your test.   And guess what?  The ChromeBook is set to not allow pop-ups either.  Ok.  Clicked the little window in the location bar to allow for this site and tried again.  Sadly, I spent about 10 minutes resuming the test.

Difficulty and time
I like to note how long each pass took and how it went. That gives a good sense of what to expect. Note that I think and test take a lot faster than average.

  • Pass 1 – 12 minutes – there were 17 questions that were so obvious, that I was comfortable answering them without more than 15 seconds of thought. And since the working of each was concise (no long scenario type things to read), this phase went rather quickly. The remaining 18 I was pretty sure of. I bookmarked them because i want to spend a little longer thinking about them or want to confirm in the Scrum book. Largely for learning purposes as I know that I already have enough right to get a passing score. Since I did phase 1 on my iPad, I also wanted to wait to be at a real computer to review and submit. Easier to look at the Scrum manual and test together on a real computer. Plus, i only had 10 minutes until my flight boarded
  • Pass 2 –  15 minutes – I had to go thru them all again because the bookmarks of which questions to go back to aren’t available on the ChromeBook.  I only looked up a few.  And even that was mostly to read more about the topic.  During this pass, I changed 1 answer.   There were 4 questions that I wasn’t 100% sure of.  I was able to narrow down to 2 choices and picked the one I thought best.  (Which worked out nicely)

Tips

  • Read carefully
  • Process of elimination is helpful
  • Don’t overthink it – they aren’t trying to trick you

Free Resources I used 

I actually looked at these between day 1 and day 2 to get a feel for what was going on.  After day 2, I didn’t do anything.  Then the morning following day 2, I did pass 1 of the test.

Resource My comments
Learning objectives and outline Good overview of what the course covers. Many parts will only make sense if you know the material though.
10 sample questions Easy if you know the material, but a good review.  I got one wrong, because I had never heard of the Product Backlog being referred to as the “Scrum Backlog”.
Scrum alliance open assessment This is more challenging than the official test and I learned more from it.

30 minutes, 30 questions, pass 85%.  Meant to evaluate your knowledge.  You can take it multiple times and get a few different questions each time. It requires 3rd party cookies which is annoying.  I took this three times after day 1 of the class and got 67%, 83% and 93% in that order.  The first two times, I did it from memory.  The third time, I used the actual Scrum guide as a reference.  (I’m not so good at remembering how long meeting X should be.  I know how long it is on our team, not the maximum.) It tells you what the correct answer is for the ones you got wrong.  Plus many have a paragraph explaining the rationale.  Making the by far the most valuable practice and reinforcement.  Both for the class and to learn more about Scrum.  This is definitely harder than the real exam as there can be multiple correct answers.

Resources I did not try

I don’t think you need them since the real test is open book and you can do research.

Resource My comments
Scrum Study Guide  This book is $50 for 50 pages.  It allegedly prepares you for the exam.  But the course does that.  I can’t imagine a book that short being worth the cost of $50 given this.  (I didn’t ask for a review copy because I suspect my review would be negative and I don’t want to approach a self-published author knowing that.)
Scrum Practice Test This is $7.  I looked at the preview on Amazon.  It seems harder than the exam, but interesting questions.
ScrumMaster Exam Questions E-book $20 book.  It’s 44 pages and you can preview the first four (along with the answers for free).  While some questions seem off topic (XP), the answer explanations are good.