Home     About

Eating Elephants

Maintaing the Sense of Purpose

some problems require quick surface level patch fixes, there focus on reaching the solution the fastest. diving deep makes sense if the project is for learning or some deep refactor is required. another solution is to get started with a quickfix, followed by larger code refactors.

About Mental Models

code is just the textual representation of the mental model of the problem. so it's wise to focus on the mental model , and not to get lost into the code. the bug in code is because of some holes in the mental model, so focus on finding the holes in the mental model first than just fixing the bug. debugging without looking at the code

code is edited maybe 5 or 10 times in a decade, but it's read thousands of times, and the readers are trying to understand the mental model which lead to that code. make sure to write code such that it's easy for others to create a mental model when they read your code, and their mental models should be close to yours... it's your responsitility!

Code Documentation

let's take a look at a few bits of well written code which reads like prose. reading the interface definition, i exactly know what it is about and where to look next.

// The Filter interface represents a process that takes as input a
// sequence of strings from a channel and produces a sequence on
// another channel.
type Filter interface {
    // RunFilter reads a sequence of items from Arg.In and produces a
    // sequence of items on Arg.Out.  RunFilter returns nil on success,
    // an error otherwise.  RunFilter must #not# close the Arg.Out
    // channel.
    RunFilter(Arg) error
}

Rapid Prototyping

hack/prototype a quick end-to-end working solution that touches every part in a timeboxed setting, hardcode most of it. this way there will be less chances of running into the unknown and magical surprices.

estimation will be easy as you would know the simple and the complicated areas. work in small, solid increments to keep yourself motivated and to have something to show for all that time you spent on the project, one step at a time and verify the step everytime. this saves hours of painful debugging due to mixup of changes at different steps.

just reading can be misleading as code is not the same as the state of the program at a certain point. run the program, attach a debugger and step through the code to understand what it is doing, how it looks. use callgrind etc and look at the callgraph maybe.

Reading Code

Reading in General

Know Your Tools

Detailed Logging

Sources and Suggested Reads