Artist Kent Rogowski creates montages using puzzle pieces from different jigsaw puzzles. The resulting images are both spectacular and surreal, and definitely inspiring if you’re a programmer knee deep in plugins, libraries and web mashups.
Test Driven Development (TDD) is one of the techniques I use for creating Helicoid’s products. I’m still the only developer here, so I have to work incredibly efficiently and effectively. In fact, this technique is the greatest secret behind successfully “one man banding” without losing all of your evenings and weekends.
- Help you write better code: by working with the public interfaces from the start you’re encouraged to make cleaner interfaces
- Help design code
- Improve your confidence, ease deployment headaches: your tests will show recent changes are safe
- Communicate your intentions to colleagues (or yourself in the future!)
Don’t worry about UML, XP or any other unfamiliar jargon
There are plenty of books about TDD, and on the implications of it. Don’t read books about TDD, just start doing it right now.
- If you don’t already write tests, look how people usually write unit tests in your project’s language
- Take one of your project’s classes, and think about how you’d test the public methods
- Try and write discrete tests, communicating how the class should behave
- If your boss says writing tests wastes time and he needs this feature right now, consider ignoring him
Test from the ground-up
When adding new classes to a project, start by creating tests.
- Imagine you’re designing an API rather than a class that’s tied to your project
- Write a set of unit tests that define how the class should behave
- Start adding methods to your class to satisfy the tests
- As edge cases become apparent, add more tests
- If no edge cases are obvious, try writing more tests to discover them
Fixtures: an opportunity for design rather than a chore
When I write tests for a Ruby on Rails project, I have to create sets of test data. I used to regard this as a chore that slowed me down. However, carefully defining test data can force you to consider the validity of your assumptions about underlying data structures.
Don’t worry about volumes of data, because if volumes are required for particular types of tests you could easily generate sets of data in loops. If you’d like to create loops in your Rails fixtures, remember that you can use erb to safely embed ruby code.
It’s important to realise that repeated data created using random numbers is sometimes less useful than carefully hand crafted test data, since this should be closer to real user-input. I’ve found scrappy test data that just exists for the sake of testing is nowhere near as useful as real data.
When testing classes that rely on network resources or files, it’s tempting to just use real resources that you know should be available. This can make tests seem less encapsulated, so consider employing “mock objects” to avoid this.
- Find a mocking and stubbing library suitable for your project (Mocha is good for ruby projects)
- By mocking certain aspects of a system you can focus on testing a particular part of it without requiring a remote resource
- Mock objects are excellent for testing edge cases: for example, what happens when a network connection fails or a file could not be opened?
There are great tools out there for producing test code coverage reports. These reports will show you code that hasn’t been tested, sometimes in a graphical way. If you’re a fellow ruby developer, have a look at rcov. Rcov will produce HTML coverage reports, so it’s very easy for you (or your boss!) to see what’s currently tested.
Coverage reports are a good way to make you feel confident about your code’s quality. They also give a temporary sense of closure on a new feature.
TDD getting started checklist
If you do any of these things today, you’re already doing TDD:
- Learn how to write basic tests in your chosen language – don’t worry about fully learning the test framework, start by copying examples
- When adding a new feature, start by creating tests first. Write code to satisfy these tests
- Refactor old code to work well with automated tests
- Write test data carefully and patiently, using this as a design technique for exploring the quality of your data modelling
- Find a mocking library so you can write encapsulated tests that don’t require external resources
- Find a tool for producing coverage reports in your chosen language
- Investigate automated testing triggered when deploying/releasing code
Since this blog covers our product announcements, we’ve decided to launch a new blog entitled Helicoid Insider, covering:
- Technical tips on building web applications
- Interface design, and design culture
- Web industry observations, opinions, discussion
Recent posts include:
- Start using Test Driven Development today
- 20 free icons dedicated to programmers
- 10 essential ruby gems
Tiktrac, our time tracking app, has just been furnished with a Mac OS Dashboard widget.
To download the widget and get instructions on how to use it, visit the widget’s page.
We’d love to hear from you (and give you awesome free stuff) if you’ve used Tiktrac’s API to make any widgets, gadgets or interesting things. Also get in touch if you’d like help building something like this.
The Helicoid Icon Set is a collection of icons we use in our applications, including:
- Navigational cues
- Credit card images
- Scalable buttons
- Images to enhance web applications
Why are we giving these icons away for free?
As the lead programmer and designer of Helicoid’s applications, I’ve worked ridiculously hard over the last year at two jobs: programming and design. Programming software is my passion, but I’ve had to teach myself design skills in order to get our applications released on a shoestring budget.
I realised there might be a lot of programmers out there in a similar situation (especially open source developers), so these icons are dedicated to you. If you open them up in Adobe’s Illustrator (or try the SVG file with an open source image editor) you’ll find it’s easy to change colours around and scale the icons.
These icons are released under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.
There’s a few things I can’t live without when I’m programming. To that end, this is a list of 10 essential ruby gems that will make your life much easier, even if you only spend a small amount of time working with ruby.
Gems come and go, but these are keepers!
Capistrano makes Rails application deployment less of a hassle. It’s also a clever framework for interacting with remote servers. I actually have backup scripts written with Capistrano, as an alternative to Rake/Net::SSH or shell scripts.
Chronic is a natural language time parser, with the added bonus of having a pun for its name.
>> Chronic.parse('3rd wednesday in november') => Wed Nov 19 12:00:00 0000 2008
Ferret will make your boss/clients/customers love you. It provides tools for fast text searching, and you can even index PDFs and Office documents. I’ve used Ferret on some pretty big sites, and my clients all said “wow this is just like Google!”
hpricot is a fast and easy HTML parser. If you find yourself needing to extract content out of HTML or even XML, hpricot is one of the easiest ways to do it. I actually use it for a few things in Helipad
rcov is one of the reasons you don’t see our applications crashing too often. It analyses your source code, and highlights sections missing from your tests. It’s fast, doesn’t get in the way, and helps reduce headaches.
I’ve used Gruff for graphing, and while it’s very good, I prefer the design of scruffy’s API. The way it works is pretty ingenious: simple XML is generated to drive SVG graphs. Since SVG provides a way to work intuitively with image primitives, a lot of messy image magick code is just thrown away.
I’ve quite liberally inherited and overridden stuff in scruffy to create all kinds of clever graphs, so give it a try if you’re feeling a bit stuck with your current graphing library.
simple-rss parses RSS and atom feeds, does a good job of it and does it quickly. Its parser is easy to extend too, so you should be able to tame invalid or proprietary feeds.
Thin uses EventMachine, Rack, and Mongrel to create a very fast web server. I use it for my local Rails development, and it’s slightly faster than mongrel. To use it with my Rails app I just type
thin start in my app’s directory. At the moment I’m having problems with thin and IE cookies, so it’s worth remembering that if you run into the same problem and think your app might be at fault. (Note: This now seems to be fixed with 0.6.1 and Rails 2.)
To get thin,
gem install thin.
Turn makes your Test::Unit output easier to read. Turn might not seem like much, but it really helps me read my tests. I rely heavily on tests for maintaining Helicoid’s applications, so anything that helps make the process more intuitive is welcome.
To get turn,
gem install turn.
wirble makes irb easier to use. You get better history support (between sessions) and colour, so your eyes and fingers do less work in the long run.
Helicoid Insider is Helicoid Limited’s blog about design, code and the web industry. This blog will include materials and lessons learned while creating our applications. Comments, guest posts and feedback are more than welcome!
This blog is in addition to our company’s product blog, which provides updates and tips on our web applications.
Who are Helicoid?
Helicoid Limited was officially founded by Alex Young and Gabriel Gironda in 2005, with the help of Alex’s fiancé (Yuka Mizuno) and Kevin Ford. All Helicoid’s applications are currently designed and programmed by Alex, with thoughtful input and copy writing from Yuka, technical guidance and inspiration from Gabriel, and system administration and security help from Kevin Ford.
We recently updated the homepage for Tiktrac, our time sheets web application. While going over the copy we had an interesting idea: why not include a dynamic counter for the total time tracked?
So now you can see the total amount of time recorded by the Tiktrac community. It currently displays 22210 hours, which is almost 1000 days.
That’s a lot of work… maybe soon we’ll have to switch the counter to days instead of hours!