Is Code Written To Be Read?

The other day I attended a tech talk hosted by Facebook. Their internal platform team was talking about how they manage the Facebook framework and code base.

The presentation was titled “Code Is Written To Be Read”.

Immediately my gag reflex kicked in. Code is written to be read??? Really??? I literally can’t remember the last time I sat there and thought “hmmm, how readable is this code, I wonder if so and so will be able to understand this”. Having said that, I think I was the only person from a startup in attendance, most were from Google, Zynga, and other larger tech firms. So perhaps I was the wrong audience for this topic.

Whatever their problem is, it is not mine. In my world I have one reason to write code – TO SHIP.

“Code is Written for Users to Use It” (i.e. just ship or shipping is a feature) – that is the startup equivalent mission statement.

And this is where all the “maintainability” coding trolls come in and leave comments like “yeah, but it’ll be huge advantage if we can iterate quickly and get a v2 out and so on and so forth, thus we need code thats easy to maintain”.

No.

Here’s the reality – your product is likely going to fail, so if you wasted time and money making fancy abstractions, doing code golf, and focusing on elite coding craftsmanship… you blew it. You failed. You should have finished it 2-4 weeks earlier instead.

You have to EARN maintenance as a problem. You have to EARN v2. You have to EARN the right to practice expert craftsmanship. If you get there, if you really get to the point where maintaining your code base is a problem for you where many other developers are reading your code… congrats! You’ve succeeded. Go nuts, rewrite everything. You deserve it!! Forget every word I am writing, and go attend the Facebook tech talk and take diligent notes.

But for most of us, we are not going to earn that right. We are going to fail or pivot or leave or get acqui-hired or whatever. That code is going to get thrown in the trash never to be touched again. So how’s that clever FactoryOfTaskFactories abstraction feel now?

And that’s why you probably don’t want to hire Facebook or Google engineers for your startup. And more so, if you are a new grad engineer who aspires to be a startup founder one day, that’s why you don’t want to join Facebook or Google.

Look, it’s not that there is something wrong with those developers. I’m sure working at Facebook or Google is fantastic. It is the closest thing to a tenured prof position you can get in this field. The problem is that they operate under significantly different operating conditions than you do (unlimited money, unlimited time, lots of technical resources, working across massive teams, etc + MASSIVE scale problems, huge performance requirements,petabytes of data, etc). They learn a very different craft than you do.

Your craft, the startup developer craft, is simple – “get things done”. The other parts of the craft, you have to earn.

(caveat – if you are building a startup focused on platform or tools being used by other developers, your craftsmanship should be excellent)
(disclaimer – I have nothing against facebook or google, they are full of friends of mine and other wonderful and smart ppl)

Supersize Your Startup Dev Productivity


AttributionNoncommercialShare Alike Some rights reserved by Dav

Since I wrote the interview with Farhan of Xtreme Labs on Pair Programming, I have exchanged a number of emails on pair programming & developer productivity with some of Canada’s best developers. Most of them are pure gold that I am posting raw and unedited.

———————————————————————————————

“The main thing we like to stress on development is Test Driven development. We just find that it both ensures all the code is well tested, but also guides the architecture in a way that really improves maintainability. We use pairing in our interview process and also like to pair for the first couple of weeks to get developers up to speed, but after that we tend to split up work for the day and then attack separately.” – Jesse Miller, CEO of attachments.me

———————————————————————————————

“Whether to use pair programming or alone model really depends on the team personality and the kind of culture the leaders want to shape up. Some people do work better alone, and some prefer more teamwork.

Personally, I usually value teamwork more than individual results. At the end of the day, individual work will have to be integrated to form the end product, which is what really matters. There are too many examples where people think they got great ideas, but end up in epic failure during implementation. It is a result of not doing deep enough design validation. Coding alone is definitely more effective when you got the design details flushed out. Personally, when I am coding alone, I still ask for 2nd or 3rd opinions on a day to day basis. It forces me to think through the design again and again, which helps to refine my idea further. It is all about attitude. Never believe that you got it right until see the end product.

Another interesting thing is “pair troubleshooting” is more effective. When you’re trying to debug in an extremely stressed environment, it is always good to have some mental support and another pair of eyes.” – John Yuen, heads up dev for Fixmo

———————————————————————————————

“I think that pair programming does actually increase productivity, in most cases, and there are two reasons for this:

1. It keeps programmers from doing other things:private email, browsing, day dreaming, etc. I doubt that the average programmer actually spends even 50% of their time doing their job. If you can hire two developers, and get the work of one full programmer out of them, then I think, in a lot of cases, that would be an improvement. However, you could get almost the same result by pairing each
programmer with their own full-time low-cost supervisor who sits beside them to make sure that they’re actually working. This would be a lot cheaper and almost as productive, but the developers would find it insulting. This isn’t always the case of course; there are certainly many self-motivated, disciplined, highly-focused and productive developers who don’t need supervision.

2. Studies have shown that programmer productivity is limited, not by the time it takes developers to write code, but by the time it takes them to detect and correct errors. The limiting metric isn’t lines-of-code-per-hour, but rather, errors-debugged-per-hour. This is why Java is more productive than C++, despite the two languages being of similar expressive levels, Java’s runtime exceptions make it quicker to detect and recover from many times of errors, and garbage collection completely eliminates many other types. This is where pair-programming comes into play, if someone looking over your shoulder can spot an error as soon as it’s created, then that can lead to a lot of time savings. Maybe it would have only taken you two minutes longer to detect and fix a particular bug, but then gain, maybe it would have taken a week. Your partner wouldn’t need to early-detect very many problems in order to justify the overhead.

Maybe one developer sitting in a control booth, like a security guard, monitoring the work of half-a-dozen developers all at once, would be a good compromise between pair and pair-less programming.

Yes, it’s true that ACM programming contests are performed on only one computer, but you rarely have more than one person working on the same problem. While one is typing in and debugging their solution, the other programmers are working with pencil and paper solving their own problems (with occasional help from their team mates as required).

People are more important than any process or any tool. The best process is to hire the best people and a better developer is the best tool.

I half agree with what the original article says about hero developers. They say that you don’t need them, and that you’re better off with the a consistently productive 9-to-5’er. I think they’re
confusing heroes with heroics. I think that you do need heroes, but you don’t need the heroics of pulling all-nighters. Instead, you need the heroics of consistently creative and proactive problem solving which keeps you efficient, effective, and ahead of the game, day in, and day out. Effort should not be confused with results. I think they have the wrong definition of heroics, which leads to the wrong definition for heroes.” – Kevin Greer, Framework Lead at Redknee.

———————————————————————————————

Point #2 from Kevin Greer’s comments is widely unappreciated. Most people judge productivity by features and the “to do” list – when in reality it is not the to do list of features that usually makes projects late, it is the killer game of bug squashing, especially as you get to the stressful end of project delivery. Processes that reduce the upfront bug rate or increase the bug solving rate, even at the expense of adding features pay off quickly. This is were pair programming, test driven development, code reviews, architecture chats, etc all come into play. And why “pair troubleshooting” or other tools to debug problems fast are important. And also, use the damn debugger, it is there to make solving bugs faster.

I’d love to hear from more of the programming community in the comments. Tell us how you supersize your development productivity.