≡ Menu

Prioritization vs Sequencing

When teams get introduced to various agile methods, one of the seemingly easy aspects is the notion of the product backlog. They then ask their business parts to prioritize the work in the backlog so the team(s) can pull the highest priority item.

It sounds easy because people think that priorities are binary. In reality, multiple things can be the highest priority. For example, a company might have a mandate to deliver a specific type of reporting feed to a government agency, while also needing to hit a critical product launch. Both are high priority, and would be “tied” for the top spot.

I often get around this by introducing sequencing as a distinct concept from prioritization. For example, in our above scenario the government report might take about two weeks of effort, while the product launch is 6 weeks of effort. If both are due in 8 weeks, we can sequence the work to hit the most critical portions of the product launch for 4 weeks, work on the government reporting feed for 2 weeks (giving a 2 week buffer), then finish up the product launch.

So if you find yourself struggling with “prioritizing” a product backlog with business partners, try talking about sequencing instead. That’s what you are really aiming for anyway, and opens the door to richer conversations about risks, costs of delay and business value delivery.

{ 1 comment }

A quick protip – if you are projecting (say for a conference or training), want to have your screen split (so it’s showing different things on each screen) but still want to show what you are typing in your terminal, you can use tmux to have it mirror what you are typing in a separate console window.

First, install tmux. If you are on a Mac and use Homebrew, you can do brew install tmux.

Once you have tmux installed, open up a terminal window and start a new tmux session with the following command:

tmux new -s training

This creates a new session on your localhost named training. Next, open a second terminal window and run the following command:

tmux attach -t training

This “attaches” the second window to the first session. Now, whatever you type in one terminal window will show in the other, and vice versa. It will even show you if the viewable area is smaller than your current window, so you know what the other screen will see.

{ 0 comments }

2015 Can Bite Me

At first it seemed silly to me to post a “2015 review” as if I do anything all that interesting, but I also know it’s good to step back and reflect on things, so here goes.

2015 can bite me.

I don’t want that to sound like everything was horrible. Back in June I came on board at The Iron Yard to build their Corporate Education / B2B business, and we’re building some incredibly awesome stuff that will be hitting hard in 2016. In addition, I got to play a tiny part in helping bring an awesome new platform for the deaf into play (much bigger kudos to VTCSecure who actually has been working on it for years to bring it to fruition). I also launched an apprenticeship program at my former employer based off of the 8th Light model.

I did some fun talks, too:

Outside of that, this was one of the most challenging years I’ve ever had, even blowing out of the water the time we bought a house and got laid off right after. The year started off promising enough with a new position as the CTO of a local company with 30+ developers, many who I knew personally. There were some interesting projects in the pipeline. But then the worst possible series of events that could have happened, did:

  • The team was behind on a critical project with tight deadlines. I was able to rally the troops, and by putting in an extraordinary effort (the final week I believe we worked well over 100 hours) we shipped it.
  • However, in the midst of that, my dad got extremely sick. He had to have emergency surgery, and we brought him up to stay with us. During that final project push, my dad had developed a blockage in his intestines that I should have been able to catch, but didn’t because I was at work.
  • So the day after we shipped, I ended up in ICU with my dad, where he spent 10 days in the hospital. I was then able to transfer him back to Florida where he ended up in the hospital twice – with me making frequent, frantic drives to Florida from NC – before he passed away in May.

I questioned a lot the decisions I made balancing work and family. Ultimately I couldn’t have predicted things happening as they did, and wanted to be able to be there for my team and my dad. You can’t take back decisions you made, and as much as I talk about work/life balance, I made a decision to not focus on my dad as much as I should have. That’s rough.

Looking back, I’m incredibly grateful for many things:

  • A strong family that has supported me
  • Friends I could bounce ideas off of
  • An awesome team at The Iron Yard who understands diversity and how to make people successful (even if we’re still figuring out the growth thing)
  • An amazing group of people I met this year on the Twitter that inspires me: Saron Yitbarek with Code Newbie, Cate Huston, Lesley Carhart, Carina C. Zona, Keri Karandrakis (and her Tweet heard round the world), Coraline Ada Ehmke for her journey, and Ruth Malan for her incredible generosity and motivational tweets. And let’s not forget Taylor Swift for helping expand the reach of security topics to more people than anyone could imagine.

I’m excited by what 2016 is going to bring. Maybe it’s just me coming off the first vacation I’ve had in years, but there is a lot of amazing things all coming together, and I’m ready to uncork a bottle of fizzy drink and celebrate the end of The Year That Shall No Longer Be Named.

So 2015, I leave you with this:

Bite My Shiny Metal Ass

{ 0 comments }

Huge thanks to Red Hat for having me out for Red Hat Agile Day 2015! Below are the slides from the talk!

Update: The talk was recorded! The video is posted below under the slides!

Strategic Play from Cory Foy on Vimeo.

{ 1 comment }

Why are my commits attributed to devil man?

Last night, a scary looking message came to me from our Slack channel:

Slack message asking if a commit was mine

We were referring to the user as “Devil Man” because this was his profile picture.

Picture of a devil looking cartoon

After wondering if perhaps my ssh keys had been compromised, I came across something that makes way more sense, and isn’t sinster at all. I ran the following command on my laptop:

Corys-MacBook-Pro-2:~ foyc$ git config --list
user.name=BuildTools
user.email=unconfigured@null.spigotmc.org

Turns out, I have a new laptop that I haven’t configured with all my dotfiles, etc. However, I was playing around with a Minecraft/Raspberry Pi server, and pulling down the tools set my global Git configuration. Since I didn’t change it to anything else, the PR I sent got pushed up with the above as the configuration, and “Devil Man” must have that as his GitHub repository email, so GitHub helpfully linked the two.

Thankfully this wasn’t a security vulnerability per se, but in case you ever wonder why your commits are attributed to Devil Man, now you know that it isn’t his fault, but your own for not configuring your commits properly.

(For futher reading, GitHub has a more boringly titled article “Why are my commits linked to the wrong user”)

{ 0 comments }

This week I had the privilege of sitting in for the great Jared Richardson and giving his Continuous Testing workshop at SQE’s Better Software West. I added my own flavor to various parts, and wanted to post the slides for participants. If you are interested in finding ways to improve your practices, be sure to reach out!

{ 0 comments }

Thanks to everyone who came out to my TriAgile talk on Choosing Between Scrum and Kanban! You can also see a video of it from my presentation at the SQE Conference from November.

{ 0 comments }

Slides and Code Kata Recording from Triangle.rb

Last night I spoke at the Triangle.rb meetup on focused practice and code katas. Thanks to everyone who came out! Below are my slides, and a screen recording of the code kata I performed (known as Coin Changer).

{ 0 comments }

Test-Driven iOS Development with Specta and Expecta

I’ve always enjoyed Test-Driven Development. I find that it helps keep me focused on thinking about small steps and object interactions. But TDD has always been a challenge in UI heavy applications, and even more so in the mobile world where much of what we do is user interface interactions. But over the past couple of years, a lot of work has been done to make iOS and Xcode much more amenable to TDD. However, I haven’t found a great tutorial that goes end-to-end in getting up and running with tests in a step-by-step fashion. Gordon Fontenot’s Test Driving iOS – A Primer comes closest, but still leaves out some critical steps.

For this article, we’ll build towards an implementation of Conway’s Game of Life – a common exercise used in Code Retreats around the world. So let’s get started!

Getting Setup

To get setup, you’ll need to install:

(Note that if this is your first time using Cocoapods, you will need to open a terminal after installing and run the pod setup command. Otherwise you may end up with an error like No such file or directory @ dir_initialize - /Users/foyc/.cocoapods/repos (Errno::ENOENT) the first time you try to run pod install)

Open Xcode and create a new iOS Single View Application. Name it TDD Game of Life and set the org identifier to com.example.gol (if you don’t already know what to put in there). Select the directory to put it in, and let it create the project.

Single View Application

Screen Shot 2015-02-16 at 4.16.30 PM

Once you have the project created, close Xcode and open up a Terminal prompt and navigate to the directory that houses your project. Once there, run the command pod init. This creates a default Podfile for Cocoapods. This is where you’ll list the frameworks we’ll be using – similar to a Gemfile from the Ruby world.

Open the Podfile in your favorite text editor and add the following:

pod 'Specta'
pod 'Expecta'
pod 'OCMock'

in the target 'TDD Game of LifeTests' section:

Screen Shot 2015-02-16 at 4.23.13 PM

Save the Podfile, and then in your terminal, run the command pod install. You’ve now installed the Pods into your Xcode project and are ready to start testing!

Write our first test

Conway’s Game of Life is based on some pretty simple rules. One of those rules is that a cell can be in one of two states – alive or dead – and can either be killed or resurrected based on the state of the cells surrounding it.

The behavior of killing and resurrecting a cell seems to be a small enough chunk of behavior we can start with. Navigate to your project directory and open the “TDD Game of Life.xcworkspace” file in Xcode. In Xcode, right-click on TDD Game of LifeTests and choose “New File”. In the dialog, choose iOS->Source->Objective-C File:

Screen Shot 2015-02-16 at 4.31.52 PM

Name it CellSpec and leave the File Type as “Empty File”, then click Next. Make sure it is adding the file to the Tests folder (leaving everything else as defaults), and click Create. Xcode should now open the newly created file.

Inside the file, you should see an import for Foundation.h. Just below that import line, add the following:

#import <Specta/Specta.h>
#define EXP_SHORTHAND
#import "Expecta.h"
#import "Cell.h"

The first import includes the Specta library. The second and third lines include the Expecta library and setup a shorthand to prevent us from having to write expectations with the prefix EXP_expect.

The final line imports our Cell class which doesn’t exist yet! It doesn’t exist because no test has told us to create it (and yes, compiler errors in our tests cound as test failures). So let’s try to build our test file. Either go to Product->Build or just hit Command-B. It should fail because Cell.h couldn’t be found. (If it fails for any other reason, make sure you have Cocoapods installed properly and ran the pod install command).

To make this “test” pass, right-click on the “TDD Game of Life” folder and choose New File. Selection iOS->Source->Cocoa Touch Class:

Screen Shot 2015-02-16 at 4.55.06 PM

Name the class Cell and leave all of the other defaults as is, then click Next. Make sure it is adding the file to the main “TDD Game of Life” folder, and click create. Once the file is created, build the application again using Command-B. You should see the build succeed. (If your build does not succeed because of a linker error, close Xcode and reopen it so the Cocoapods changes we made earlier can take effect).

Now let’s add some behavior. To write tests, we wrap our tests with SpecBegin/SpecEnd macros. So back in our CellSpec.m class, add the following code under the import statements:

SpecBegin(Cell)
describe(@"Cell", ^{
  it(@"is dead on creation", ^{
    Cell *cell = [[Cell alloc] init];

    expect([cell isAlive]).to.equal(NO);
  });
});
SpecEnd

There’s a lot of design assumptions packed into this one test. First, we assume we can create a Cell with no other information. Secondly. we assume we can query a cell’s status by using a method called isAlive. Lastly, we assume that method tells us that status by giving us a binary YES/NO.

We’ll go with those assumptions for now and see if we can get our test to pass. Trying to compile results in an exception because isAlive is not defined. In our Cell.h class, make your code look like this below the import line:

@interface Cell : NSObject
- (BOOL)isAlive;
@end

This should allow us to compile, although with warnings. If we now hit Command-U (or go to Product->Test), we should see our first test failure!

Screen Shot 2015-02-16 at 5.24.10 PM

We can also open the log files by enabling the bottom view in Xcode. In the upper right hand corner there shoudl be three boxes with lines to the left, bottom and right. Click on the one with the line on the bottom:

Screen Shot 2015-02-16 at 5.25.04 PM

and you’ll see output similar to:

Screen Shot 2015-02-16 at 5.25.13 PM

Alright! We have our failing test! Let’s make it green! Open Cell.m and implement our isAlive method by making our code look like the following under our import statement:

@implementation Cell

- (BOOL)isAlive
{
    return NO;
}

@end

If we now hit Command-U, we’ll see our tests pass! (If you don’t see the below in your Xcode, click on the diamond icon with the dash in the middle).

Screen Shot 2015-02-16 at 5.27.42 PM

Congratulations! You’ve written your first iOS Objective-C test!

Writing your second test

While writing our first test was awesome, the implementation wasn’t particularly interesting. After all, cells need to be able to be both dead and alive. So let’s add a second test to our CellSpec.m file:

it(@"is alive when brought to life", ^{
  Cell *cell = [[Cell alloc] init];
  [cell resurrect];
  expect([cell isAlive]).to.equal(YES);
});

So our whole file should look like:

SpecBegin(Cell)
describe(@"Cell", ^{
    it(@"is dead on creation", ^{
        Cell *cell = [[Cell alloc] init];

        expect([cell isAlive]).to.equal(NO);
    });
    it(@"is alive when brought to life", ^{
        Cell *cell = [[Cell alloc] init];
        [cell resurrect];
        expect([cell isAlive]).to.equal(YES);
    });
});
SpecEnd

If we try to run the tests (Command-U), we’ll get a failure because the method resurrect doesn’t exist. Again, we’re making a design assumption here that we’ll be using a method called resurrect to make a cell alive.

Let’s get our compiler happy by adding the following to Cell.h:

- (void)resurrect;

and the following implementation to Cell.m:

- (void) resurrect
{

}

Notice that the implementation is blank. That’s because we don’t actually have a test failure telling us to put anything in there. Now that our compiler is happy, let’s run our tests:

Screen Shot 2015-02-16 at 5.37.40 PM

Alright, test failure! To make this test pass, we’ll need to promote the constant we’re using in isAlive to be a variable. Objective-C makes this easier by using properties, so let’s add the following to our Cell.h, just under our @interface line:

@property (nonatomic) BOOL aliveState;

Now we’ll change our Cell.m file to use that property:

- (BOOL)isAlive
{
    return [self aliveState];
}
-(void)resurrect
{
    [self setAliveState:YES];
}

And if we run our tests – success!

Screen Shot 2015-02-16 at 5.43.43 PM

We now have one more test to write – killing alive cells. So let’s add the following test to our CellSpec.m class:

it(@"is dead when killed after being brought to life", ^{
    Cell *cell = [[Cell alloc] init];
    [cell resurrect];
    [cell kill];
    expect([cell isAlive]).to.equal(NO);
});

This fails because we don’t have the kill method, so let’s add that. Add the following to Cell.h:

- (void)kill;

And the following to Cell.m:

-(void)kill
{
}

Then run our tests.

Screen Shot 2015-02-16 at 5.49.25 PM

With our test failure in our place, implement the kill method:

-(void)kill
{
  [self setAliveState:NO];
}

And…..green!

Screen Shot 2015-02-16 at 5.50.31 PM

…Refactor

TDD’s lifecycle is known as the Red-Green-Refactor loop. We write a failing test, write just enough code to make it pass, and then refactor any duplication. In this case, our production code is pretty straightforward and doesn’t have any duplication. But our test code does – namely, the creation of the Cell class over and over. It’s important to remember that test code is still code, and should be as clean as our production code (although I will sometimes trade redability for no duplication).

We can refactor that out in our describe block. Change your code in CellSpec to look like:

SpecBegin(Cell)
describe(@"Cell", ^{
    Cell *cell = [[Cell alloc] init];
    it(@"is dead on creation", ^{
        expect([cell isAlive]).to.equal(NO);
    });
    it(@"is alive when brought to life", ^{
        [cell resurrect];
        expect([cell isAlive]).to.equal(YES);
    });
    it(@"is dead when killed after being brought to life", ^{
        [cell resurrect];
        [cell kill];
        expect([cell isAlive]).to.equal(NO);
    });
});
SpecEnd

Yay! Less code!

Lessons Learned

Now we have a basic TDD workflow setup with Expecta and Selecta that gives us the opportunity to test our code. Remember the cycle of Red-Green-Refactor: Don’t write production code where a test isn’t failing because you don’t have it.

Now go forth and have fun!

(You can see an example of this workflow in this repository up on GitHub)

{ 4 comments }

Debugging a Rails Initializer Problem

Over the past couple of weeks, I’ve been upgrading a particularly large and older Rails 3 app to Rails 4. This app uses Oracle against a legacy database, meaning a large chunk of the data structure does not follow Rails conventions.

One of the examples is that the primary key we use on the tables is not named id but is instead called something like row_no. This is defined in the table as a NUMBER type with no precision or scale (in Oracle, you can define types like NUMBER(9,2) which would have 9 significant digits, 2 of which are after the decimal). To access the database, we’re using the excellent Oracle Enhanced adapter. However, by default, the adapter treats columns defined as NUMBER with no precision or scale as a decimal type. Since we’re using them as IDs, we expect them to be integers.

Prior to the Rails 4 upgrade, we had forked the adapter library to change this behavior. However, that left us in the position of having to maintain our own library – something I didn’t want to do. In looking at the latest version of the adapter, they had added the ability to configure the behavior of NUMBER types using an initializer: `

ActiveSupport.on_load(:active_record) do
    ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
        self.emulate_integers_by_column_name = true
        def self.is_integer_column?(name, table_name = nil)
            !!(name =~ /row_no$/i)
        end
    end
end

<

p>`

This worked great to convert all of the columns. But, we discovered along the way that, for one specific table, this logic wasn’t being applied. The adapter has a method called simplified_type which applies the appropriate logic. But when I put a breakpoint on it, I noticed that the logic wasn’t applied for this one specific table.

The first clue came at the timing of the breakpoint. I noticed that I hit the breakpoint for the trouble table during startup of the rails console, while the other tables weren’t hit until I interacted with them in the console. The second clue was then when I hit the breakpoint, emulate_integers_by_column_name was set to false – even though I had it set above. The third clue was remembering that initializers are run in alphabetical order and since my Oracle initializer was named, well, oracle.rb, there was a good chance something was running ahead of time.

And there was – but it wasn’t what I was expecting. Because this is a legacy database, there are some specific sanity checks we run on startup to check certain aspects of it. And sure enough, we were doing a call which caused the problematic table’s model to become initialized. That meant that table would be called – and column mappings cached – before we had the chance to configure the database to have the behavior we really needed.

We solved the issue by renaming the database adapter initializer to run first (000_oracle.rb).

This problem represents the joy and challenge of debugging problems. The debugger was able to tell us the state of the application, but it should provide input for hypothesis. The column isn’t converted – what could lead to that? The flag isn’t set – when should it be set, and why wouldn’t it be? When could code run before other code? So when you face a challenge, start with a hypothesis before the debugger – not only will you potentially learn more, you might be able to deploy it in the right spot. Use it to answer questions.

Special thanks to the folks at the Oracle Enhanced forum especially the ever awesome Lori Olson and Yasuo Honda!

{ 0 comments }