Monday, December 21, 2009

My Mockito Tech Talk. AKA: Conveying Information and Stuff

It seems that 3 weeks after writing Paying Myself First, I have already failed.  Well not completely.

I haven't been writing down my thoughts in blog form because I've been preparing slides for a tech talk at work.  I've been wanting to give a talk about Mockito.  My project is on a transition point so I figured that it would be imperative to give a talk this month before we ramp up again in January.

I suck at public speaking.  That process of reading your audience.  Conveying information.  All of that stuff.  Who needs it right?  Hook me up with my IDE, give me a fridge full of diet mountain dew and get out of my way.  I got things to do.

If only the world worked that way.

Since I'm on this whole, let's work hard and do awesome kick, I've been looking at public speaking as an area to focus on.  After all, if I want to be able to lead software teams, I need to be able to be someone who is able to be informative and also know what the hell they are talking about.  I've done the whole Toastmasters thing before.  I like the concept, but I didn't like the structure and organization of the particular group I was a part of.  So without any outside help, I got to searching on how I could improve my slides and effectively present a technical presentation to my peers.

And the search began.

I found this interesting PDF using the Google: Presentation Tips - How to Give a Technical Presentation.  It's main points were to break up your presentation into distinct beginning, middle, and end sections.  The normal presentation layout, which I totally brainfarted on.  My presentation sections were a mess.  I didn't show any importance, background, or motivation in the beginning.  I had no illustrations to help my audience during the meat of my presentation.  The end was the best part, most likely because the slides came to end.

When I fixed my slides a bit, I changed my presentation's beginning to grab my audience's attention with some facts about my project's level of code coverage. The middle gave the basic functionality of Mockito such as mocking, stubbing and verifying.  I added some code examples and gave some background on when and why you would want to use Mockito's features.  There were a lot of questions that were brought up during this part of the talk.  Some were of mocking and stubbing use-cases and others were related to project specific usages.  I got a sense of confusion from the audience at this point.  I tried to use the List examples from the Mockito documentation, but that turned out to be a bit too high-level for a presentation.  Most of the developers didn't "get it".

I finished off my presentation with a "real-world" Mockito example where I tested the behavior of a action class populating a stack.  The action class implemented ActionListener  and would operate on Stack's object interface.  I got good responses from this part of the presentation.  I think that developers had that "ah hah" moment when they could finally see Mockito in action from an IDE.
 
Overall I think the talk went well.  It was very informal and the I was getting a good vibe.  The best part was the fun-ness factor.  I'd have to give it a 9 out of 10.  This was the most fun I have ever had during a tech talk.  One thing I noticed that might have increased the fun-ness factor was the room's size.  Due to scheduling conflicts we had to switch to another room where the developers were comfortably crammed together.  Best move ever.  I think that helped the talk out a lot because it made the presentation feel less like a presentation and more like a discussion.  I think I'll always have my talks in that room if it's possible.

My team has already started to use Mockito to write their unit tests.  The real measure of success will be if the rest of the project's teams will start to drink some of that delicious Mockito Koolaid.  Oh yeah.  A coworker on another project likes the idea of Mockito and believe that he will use it for his tests.  Something interesting I ended up telling him was that:

"If you already write tests, then you know the pain of trying to setup and build the dependencies of the object you are testing.  If you don't write tests then you'll be wondering what's the point".

I hope they get it.

Thursday, December 3, 2009

Baselines, Branching and Reviews!

We have come to a crossroads at work.  On the left we have our latest release.  On the right, we have the road leading to future changes, improvements, and success!

Our latest release, lets call it FixLaterReleaseNow or FLRN for short, mainly consisted of developers committing to the trunk.  This caused developers to commit unfinished, broken code to the mainline.  When other developers would update, they would pull the broken code into their local workspace.  I'm not sure if this led to the code rot that manifested itself, but something was wrong.  Very very wrong.

Perhaps there was a problem with our peer reviews.  We had little to none.  The only set of eyes looking at the code were the author's.  In FLRN we used the Jupiter Eclipse Plugin to facilitate our peer reviews. Jupiter is a great tool, but there were two major sticking points for us:
  1. Some developers use IDEs other than Eclipse.
  2. The turnover from setup -> moderation -> fixing review issues was way too long.  On average it probably took developers 1.5-2 days to complete the process.
I love Jupiter.  I've been talking with Julie, the current maintainer of Jupiter, about how we can improve the plugin.  That talk is for another blog on another day.

There were broken windows everywhere and no clean up crew to whip it into shape.  Something needed to change and fast.  We had no time in the FLRN codebase, but we have some time (a little) in the new release to get moving towards the proverbial Awesome Path.

To get on track we have integrated Crucible, a code review tool from the great people at Atlassian, into our development process.  It's a bit buggy and doesn't integrate with the other Atlassian products as we would like, but Crucible increases our review turnover.  It is much quicker to choose which files to review, comment on the source, and complete the review.  The reviews are persisted so other people can  checkout what happened in the review. What we are noticing is that developers are posting comments on lines of code and the author comes in and comments on his design decision.  You just don't get that kind of immediate feedback when using Jupiter.

So back to the developers committing broken code to the trunk.  We don't want that.  We want code that has been reviewed by other developers who are working on similar feature sets to be committed to the trunk.  So my question is "How do we setup our branches?".  (Keep in mind that we use Subversion)

We are currently thinking of having two lines.  The trunk, which contains "stable" code that developers can branch off of.  In this context, stable means that the feature is complete and somewhat tested.  There will be bugs, but we will iterate through them as we go.

The second line will be our feature branch.  The feature branch can have many other branches contained in it.  This is where developers can work on their specific features without touching the main line.  In FLRN (Fix Later Release Now in case you forgot) developers would wait on committing their features because they were broken, or there would be a lot of rippling changes throughout the system, or because they wouldn't have any documentation which would cause our build to become unstable.  Now if we force developers to use the "Feature Branch" they can commit at any time without fear of breaking anyone else.

Once the developers are ready to merge to the trunk, we can have other developers review their code.  This seems like a good idea.  Developers can commit early and often without breaking anyone.  They can get their code reviewed by their peers.  Everyone is happy.

Perhaps in the make believe place of No Bugs Land.

Complications arise when more than one developer is touching the same file.  What if two developers finish their features but are using the same file.  Do we merge their changes?  Can we combine their features into a separate branch and then create a review?  That might work.

We definately need some review and merging management.  The problem we want to avoid is having a backlog of reviews.  For example, Developer A might be working on file X.  He finishes and requests a review for it.  Later that day Developer B finishes his feature which includes file X.  He requests a review for his code.  We now have a problem because there are two revisions of file X to review.  If we don't merge both Developer A and Developer B's changes, we will have to review Developer A's changes, merge the changes, then review Developer B's changes.  I feel the Horribleness!

I'm wondering how people handle different code baselines in their development environments.  I'm going to have to do a bit of research, but this article by Jeff Atwood is a good starting point: Coding Horror: Software Branching 

(Edit: It seems that Jeff Atwood got his information from Streamed Lines: Branching Patterns for Software Development)