DevTeach Montreal 2012 Wrap-up

Montreal skyline

A big thanks to everyone who attended my sessions earlier this week at DevTeach. When I give a presentation, my success criteria is that I get you excited enough to continue investigating the topic yourself. So an extra special thanks to all the attendees who took the time to talk to me afterwards. I obviously got some of you excited enough to continue learning what I was talking about! Awesome!!!

Another reason I love conferences is hanging with my peeps. I had a great time catching up with friends old and new in scenic, if somewhat cold, Montreal. Kudos to Jean-René Roy for putting on another fantastic conference.

Git Dojo

201212151800.jpgThe week started off with the fun-filled and action-packed Git Dojo with me on keyboards and Jessica Kerr on vocals and whiteboard. We even had a drummer, Howard Dierking, sit in for a set – attempting to wreak havoc on the repo when he .gitignore’d the Markdown files. The dojo was saved when he disappeared in a Spinal Tap-esque explosion midway through the set.

If you want to check out the Git Dojo yourself, you can clone the git-happens repo and follow along with the notes.

Emergent Architecture with TDD/BDD

201212151804.jpgI had a lot of fun with this session talking about the failure of UML as a design tool -though a great whiteboarding language. The holy grail of software design is the executable specification, which can be achieved with TDD/BDD. Executable specifications have the nice property of not only validating business requirements, but making it possible to validate non-functional requirements. I talked about some agile principles and techniques for good measure because that’s what I do. This led to the following tweet:

I’m not the first person to say this, but good to keep the idea circulating in our collective consciouses. 26 retweets and counting ain’t too bad. Happy to do my little part to make the software development world a better place for all of us.

I then talked about tools for creating executable specifications, specifically MSpec and SpecFlow (.NET) and RSpec and Cucumber (Ruby). We then dove into code with MSpec and SpecFlow because it was a more .NET crowd in the room. I especially loved the look of mild shock on some attendees faces when I executed what looked like a plain text file, which was in fact a SpecFlow/Cucumber file:

Shopping Cart Feature

The slide deck for Emergent Architecture with TDD/BDD is available here and the demos here.

Testable JavaScript

TestableJavaScript.pngAh, JavaScript… the red-headed stepchild of the language world. I talked a bit about the history of JavaScript and the increasing complexity of client-side applications as well as the recent rise of JavaScript on the server-side with Node.js. The need for JavaScript testing is more important now than ever. Fortunately there are some great testing/spec’ing frameworks available. I compared and contrasted QUnit, Jasmine, and Mocha. QUnit is wonderful for its simplicity, Jasmine excels at UI testing especially when paired with Jasmine-jQuery, and Mocha rules the roost for the elegance of its async testing support, which is no surprise given that it was born in the Node.js world. Regardless of which framework you choose, please please please give your client-side JavaScript code as much respect as your server-side code and write some tests/specs for it – preferably in a TDD/BDD fashion.

The slide deck for Testable JavaScript is available here and the demos here.

Coming Soon…

201212151852.jpgI’ll be presenting both Emergent Architecture with TDD/BDD and Testable JavaScript at CodeMash in Sandusky, Ohio, which is happening January 8 to 11, 2013. If you’re attending CodeMash, I’d love to see you in my sessions! Plus be sure to drop by and see me at the JetBrains booth where I’d be happy to teach you some ReSharper, RubyMine, or WebStorm ninja skills.

Posted in Presentations | Leave a comment

Prairie Dev Con 2012 Wrap-up

DeathMatch.jpgThanks to everyone who came out to my sessions at Prairie Dev Con in Regina last week. Once again, D’Arcy Lussier put on a great conference.

Testable JavaScript

The slide deck for Testable JavaScript is available here and the demos here.

ASP.NET MVC/Ruby on Rails Death Match

The slide deck is available here.

Posted in Presentations | 4 Comments

NYC Code Camp 2012 Wrap-up

201209171918.jpgThank you to everyone who came out to my sessions at the NYC Code Camp. I had an awesome time and I hope that you did too. If you’re looking for resources and/or slide decks, you’ve come to the right place.

Testable JavaScript

The slide deck for Testable JavaScript is available here and the demos http://jameskovacs.com/downloads/TestableJavaScript-NYCCC2012-demos.zip”>here.

Hands-On Git

The slide deck for Hands-On Git is available here.

A huge thanks to Steve Bohlen, Erik Stepp, Rachel Appel, and everyone else who helped out for putting on a great code camp. I’d also like to thank all the sponsors for their support in making community events like this possible.

Posted in Events, Presentations | 2 Comments

Upcoming Speaking Engagements

SaintLouisSkyline.jpgI’ll be in Saint Louis, MO in mid-July to speak at the local Ruby and JavaScript user groups.

St. Louis Ruby User Group
Wednesday, July 18, 2012 @ 6:30pm
The Able Few LLC (2603 Cherokee Street, Saint Louis, MO)
TDD/BDD with RSpec and Cucumber
RSpec and Cucumber are the bread and butter of Ruby development. Learn how to write Cucumber features to drive out high level system behaviour. Then jump down into RSpec specifications to test-drive out the actual implementation of the system. See how outside-in development can improve your code and keep you focused on the problem at hand.

St. Louis JavaScript Meetup
Thursday, July 19, 2012 @ 6:30pm
The Able Few LLC (2603 Cherokee Street, Saint Louis, MO)
Testable JavaScript
Your client-side JavaScript is code as worthy of testing as any server-side code that you might write, but often JavaScript testing is ignored. This session will introduce you to QUnit and Jasmine, two popular JavaScript testing frameworks. Come see how you can easily incorporate TDD/BDD techniques into your web development stack and increase your confidence that your JavaScript code is as robust as your server-side code.

201207031557.jpgIn mid-August, I’ll be speaking at That Conference in Wisconsin Dells, WI. That Conference, which is being organized by Scott Seely and cohorts, is shaping up to be a lot of fun and has a fantastic line-up of speakers. I must admit that talking about That Conference with friends causes a lot of confusion. The conversation usually goes something like this:

Friend:
Which conference are you speaking at?
Me:
That Conference.
Friend:
Which conference?
Me:
That Conference.

Lather, rinse, repeat.

That Conference
August 13th – 15th, 2012
Kalahari Resort, Wisconsin Dells, WI
ASP.NET MVC/Ruby on Rails Death Match
In this corner, our first contender, weighing in at 35 kLOC of C#, we have ASP.NET MVC. In the other corner, weighing in at 168 kLOC of Ruby, we have Ruby on Rails. We’re going to see what it takes to build a web app – test-first – in both frameworks. We’ll compare and contrast their relative strengths and weaknesses. The goal is to give a balanced perspective on these two popular frameworks.

201207031600.jpgIn late August, I’ll be giving a number of Ruby-focused talks at devLINK in Chattanooga, TN. My friend and fellow vegan developer, Alan Stevens, has been bugging me for years to come speak at devLINK and I’m finally going. Very excited!

devLINK
August 29 – 31, 2012
Chattanooga Convention Center, Chattanooga, TN
Getting Started with Ruby on Rails
In this session, get a gentle introduction to the Ruby language and how to get started with your first Rails app.
Ruby without Rails
Ruby is about more than just Rails and web development. Ruby is a fascinating and powerful language that will put a smile on your face with its elegance. Come learn some Ruby.
ASP.NET MVC/Ruby on Rails Death Match
In this corner, our first contender, weighing in at 35 kLOC of C#, we have ASP.NET MVC. In the other corner, weighing in at 168 kLOC of Ruby, we have Ruby on Rails. We’re going to see what it takes to build a web app – test-first – in both frameworks. We’ll compare and contrast their relative strengths and weaknesses. The goal is to give a balanced perspective on these two popular frameworks.

If you’re at one of these events, don’t be a stranger! Come over and say hi. I’d love to see you there.

Posted in Events, Presentations | Leave a comment

Ruby and RSpec: Powerful Languages Allow Simpler Frameworks

Recently I was doing a simple kata – the Roman Numeral kata – to practice my Ruby and RSpec skills. (The Roman Numeral kata is to build an algorithm test-first that converts a number into its Roman numeral equivalent. For example, 1 to i, 7 to vii, 10 to x, etc. The problem is intended to be simple so that you can focus on the process.) I had the following RSpec code:

require 'roman_numeral'

describe RomanNumeral do
  # specify is just an alias for it. specify reads better in this case
  specify '1 should be i' do
    numeral = RomanNumeral.new(1)
    numeral.to_s.should == 'i'
  end
end

I go through the Red/Green/Refactor cycle and get this first spec working. (I won’t show the production code as it’s not that interesting.) I move onto the second spec.

require 'roman_numeral'

describe RomanNumeral do
  specify '1 should be i' do
    numeral = RomanNumeral.new(1)
    numeral.to_s.should == 'i'
  end

  specify '2 should be ii' do
    numeral = RomanNumeral.new(2)
    numeral.to_s.should == 'ii'
  end
end

Red/Green/Refactor and all is good. But I’m seeing some repetition in my specs and it’s only going to get worse. The specs are almost identical except for the data. So I start hunting through the RSpec docs for something akin to NUnit’s [TestCase] or xUnit’s [Theory]. I find nothing. Maybe, like MSpec, RSpec wasn’t designed to do this sort of data-driven testing.

Undaunted I turn to Google and stumble upon this StackOverflow question asking exactly the same question that I had. Matt Di Pasquale, the OP (original poster), found his own answer and that answer was fascinating! No, RSpec doesn’t have a syntax for test cases because it doesn’t need one. Use the Ruby, Luke!

require 'roman_numeral'

describe RomanNumeral do
  cases = {
    1 => 'i',
    2 => 'ii'
  }

  cases.each do |k, v|
    specify "#{k} should print as #{v}" do
      numeral = RomanNumeral.new(k)
      numeral.to_s.should == v
    end
  end
end

For those not as well-versed in Ruby, “cases” is simply a variable that contains a hash. I then iterate over the key/value pairs and define my specifications. It’s that simple. I didn’t need any special attributes or framework support from RSpec. I didn’t need to learn the inner workings of RSpec to write my own custom extension or attributes. I simply wrote some Ruby code. Let that sink in for a second. I simply wrote some Ruby code.

Now think about that a bit more. I’m writing regular Ruby code to implement the notion of test cases. Rather than defining test cases, I could have used very similar code to define a benchmark that verifies an algorithm scales linearly with number of input elements. Or I could have fuzz tested an external API for my application. The possibilities are only limited by my imagination and don’t require me to gain an ever deeper understanding of my testing/specing framework to implement.

For someone who cut his teeth on C, C++, and C# (with some JavaScript thrown in for good measure) and is used to learning (or building) frameworks to solve problems, the notion that you can just write plain old code to solve these types of meta problems is eye-opening. It is one of those ah-ha moments that matures you as a developer. Not every problem needs a framework to solve it. Sometimes it just requires a little code.

Posted in Ruby | 10 Comments