Dream of the kind of world
you wanna live in.
Dream it out loud,
at high volume

Bono, U2

Blog

05 Feb 2014 We take care

We write idiomatic code

When we write Ruby code, we do it the Ruby-way. Same goes with Javascript or Perl or Go. We read code a lot and know how to use language-specific benefits and avoid the drawbacks. Our code is not different from any other code.

We follow Rails conventions

Ruby on Rails comes with its own set of assumptions and conventions (which is why it is called opinionated). We are not only aware of these, but we follow them in our everyday work. Recommended reading The Rails 3 Way, Obie Fernandez.

We follow common styleguides

There are a couple of good styleguides around on GitHub and others. We know them, we use them and we highly recommend them. Even to the point to force ourselves by setting up these guides in our editors. For example Styleguide for Ruby.

We use best practices

We visit conferences and read books to know how the good guys write code. We listen to people telling us about not the better ways, but the best ways to achieve our goals. Every day.

We read all the commits

It’s our codebase. We love it and we don’t want anyone destroying it. This is why we read any commit coming in. I mean literally, every commit.

We do pair programming

If the issue to tackle is complicated, or we just want to talk to someone while writing code, we simple ask anyone to join us in doing the work. Call it 4-eye-principle, Wackeldackel or Rubberduck, it’s on our toolbelt, ready to be used when needed.

We have a refactoring board, from which we pick regularly

Technical debt is everywhere. Our means to tackle this pile of guilt is our refactoring board, which grows and shrinks, visible for each and everyone. No process needed. There is always time to change existing and running code. No broken windows allowed.

We use pull-requests to review code

We have a number of ways to push our code to the repository. Sending pull requests is one of them. We ask others to take a look (or even ask ourselves one day later), before we let it go into the wild. Simple and effective, if needed.

We talk about our code

There’s a plethora of chances to talk about our codebase. Stand-ups, coffee-times, ad-hoc discussions, lunchtime, and so on. Non-coders disrespectfully shake their heads on us talking so much about our work. We always talk about major code changes long before we implement them.

We know what everybody is working on

In order to avoid conflicts we tell others what we are working on. No surprises, and no major merge conflicts. And even if we are working in the same code area, we are able to handle any conflict showing up.

We know our co-workers

By working together every day, we know each others leanings, our strengths and weaknesses. So we know when we have to support each other on tackling complex problems and writing code. Even when someone tries something new and experiments around, we trust what they are doing, because we know they are doing right.

We seek code smells

Whenever we write code, we take a look around, identifying and marking code smells. We utilize TODO, FIXME and QUESTION a lot, and find the time to decover these spots and remove them.

We modularize our code

Even with all conventions, the codebase grows to a point where it is no longer maintainable. We sport modules, mixins, concerns, gems, plugins, packages. We know when to use inheritance and STI or composition. We do this to remain focused on our given business case.

We test

A lot. All kinds of tests. Sometimes first and sometimes after we write the actual code. No bug without adding a test. No refactoring without a test. To write a test it to write code. We utilize test coverage, but 100% is not our goal. That’d be insane. There’s a kind of test for each usecase. We use the one most appropriate.

We struggle for fast tests

While writing tests is important, having a fast test suite is equally important. Slow tests won’t be run, it’s simple as that. That’s why we observe the trend on Jenkins (or Travis CI).

We check the performance

Every code change might have an impact. This is why we do log-jammin’. We do it regularly and a lot. Logjam is a great tool for that.

We update

We not only keep our tools up-to-date, we keep the tiny bits of libraries and packages up-to-date as well. We not only update gems mentioned in the check-gem-versions build, we check for rarely used or development-only gems as well.

We give back

Monkey-patching is easy. And dangerous. This is why we have a natural tendency to return our code changes back to the original developers, in order to improve their code and let ours grow smoothly and independently. We pullup a lot.

We organize our codebase

Rails provides good means to organize the code. But that’s not sufficient. There are authorizers, utilities, external APIs, decorators and so on. And there’s a neat little place for all of them.

separator line

05 Sep 2013 dConstruct 2013

Back in Brighton, England for the dConstruct conference, after 2008 and 2010. If it wouldn’t be for the conference, visiting Brighton is worth all the time. Easy to get there (choose Gatwick Airport as your destination, and take the First Capital Connect train for 30 minutes), grab a bed in any hotel close to the beach and make your way around. It’s marvelous!

But the dConstruct conference is worth attending, too, and your time and money couldn’t be spent any more unrepentantly. I got repeatedly asked what the conference is all about, and to be honest, it’s not easy to answer. From what Clearleft and others state on its website itself, it is a collection (a smörgåsbord) “of clever clogs gathered together to twist our perceptions of technology and culture”. Yeah, that fits. It’s about technology for sure (lots of web developers and designers around), and it’s about culture as well, regarding all the Internet, but even more than that. It’s about how we see the world, what drives our motivation and inspiration. And anytime I get back home, I’m more focused and inspired than before. It’s about that, finding your place in the world around you.

It’s good to be back.

separator line

25 Aug 2013 All along the watchtower

All I've got is a red guitar,
three chords, and the truth.
All I've got is a red guitar,
the rest is up to you.

taken from “All along the watchtower” by Bob Dylan

separator line

01 Nov 2012 Valid fixtures

tl;dr

Validate your fixtures.

Details

As mentioned in our Ploppcasts session about Testing (German only, sorry) I'm using both fixtures and factories when testing my Rails applications. One of the drawbacks from using fixtures is that these don't have to be valid in terms of ActiveModel validations. In order to make sure my fixtures are in fact valid I introduced a fixtures test, which is simply a unit test to automatically verify the fixtures' validity:

So, taken these fixtures:

the test will indicate one failure, because the fixture user_without_email is invalid. The fixture invalid_user won't be marked as failure, because its name is starting with invalid_ telling the test that it should expect an invalid fixture, and return a failure otherwise. By this, we can keep having even invalid fixtures without failing tests.

separator line

08 Oct 2012 Painted a year ago

Instagram Photo of bird painted with chalk

Roughly a year ago a very good friend of mine, Benjamin Rabe, was organising an event for iPhone fingerpainters from all over the world. He invited them to come over to our shared office space and have a couple of drinks. I can't remember who came up with the idea, but we finally bought a bunch of paint tubes and asked the painters to try and somehow return to real painting, with real paint and a real canvas. And since all of them should do it together, the canvas simply had to be one of our office walls.

Instagram Photo of fingerpainting in progress

Over the next couple of hours, these guys really went into something, and so the painting on our wall grew and grew.

Instagram Photo of fingerpainting in progress

And it grew even further.

Instagram Photo of fingerpainting in progress

We really had good fun watching the work in progress. Everybody, even guests without prior painting experience, was giving it a try. Everybody was invited to fill the wall up and paint what they were feeling like.

Instagram Photo of fingerpainting in progress

Everybody was in a flow. Even when waiting outside, it was a nice and warm night, the people couldn't stop painting, this time using crayons, and they went on painting little pictures on the street.

Instagram Photo of fingerpainting on the streets using chalk

After having painted for almost 5 hours, everybody was happy with the result and proud of being part of this happening. The final picture is about 5 meters wide and almost 3 meters high, and it does not fit in full size on the following image.

Instagram Photo of finished fingerpainting

But feel invited to come over and take a look yourself! The painting is still there and will be around until we leave the office to the next residents. When coming back to the office the next morning, we were glad it haven't rained yet and the chalk paintings outside were still visible.

Instagram Photo of finished chalk fingerpainting

When taking a closer look at the big painting inside, I noticed a number of nifty details.

Instagram Photo of fingerpainting details

Instagram Photo of fingerpainting details

Instagram Photo of fingerpainting details

It was just a wonderful evening. Thanks to everyone who was taking part in this, and even more thanks to the guy who created this living and one-of-a-kind experience, Benjamin Rabe!

separator line

03 Oct 2012 Why do I add to_s methods to a Ruby class?

tl;dr

Adding a to_s method to a Ruby class helps with debugging.

Details

I more and more tend to add to a Ruby class I want to test is a to_s method returning some sort of information about the underlying object.

So whenever I have to dig a little deeper and have to debug code that uses an instance of that class or I simply want to write some details to the logfile, I can use the returned string and thereby make sure all relevant information is printed.

Returning only a hard-coded string or name doesn't make any sense at all though. So, let's assume we have some sort of business object, for example a job doing some kind of work in the background. It has a certain state which we want to know about:

If you put this into an application which keeps the waiting user up-to-date with the current state of processing (as simulated below with a Ruby irb console), the user knows exactly what's going on.

There are more methods a Ruby class should have. Make sure to take a look at Robert Klemme's "The Complete Class" article. I don't think a class should contain all of the methods described there, but it's a good starting point.

separator line

25 Sep 2012 That's Wellington

Instagram Photo of a typical house and road in Wellington, New Zealand

This picture represents the Wellington style pretty much. Old and new in once place, with lots of very steep hills and roads.

Taken with Instagram

separator line

27 Aug 2012 Castlepoint, New Zealand

Instagram Photo of the lighthouse in Castlepoint, New Zealand

Last weekend we stayed in Castlepoint on east coast of the north island of New Zealand. Words cannot describe how beautiful this spot is. If you haven't been there yet, do so as soon as possible! No excuses accepted!


Größere Kartenansicht

Taken with Instagram

separator line

15 Aug 2012 The Karori tunnel

Instagram Photo of the Karori tunnel

This is the Karori tunnel which connects the suburb Karori with the Wellington city centre. Most people take their car to drive through it. But that day we decided to do the walk of about 4 kilometers.


Größere Kartenansicht

Taken with Instagram

separator line

28 May 2012 Remembering wars

Perhaps, when we remember wars, we should take off our clothes and paint ourselves blue and go on all fours all day long and grunt like pigs. That would surely be more appropriate than noble oratory and shows of flags and well-oiled guns.

Kurt Vonnegut from “Cat's Cradle”, published in 1963

separator line

Older Posts are to be found in the archives...