re: Object Calisthenics in Golang VIEW POST


Thank you for writing this. I had not encountered Object Calisthenics before and there are some interesting ideas.

I did not find your indention example easy to read. In fact, I only quickly understood it because I had the benefit of previous example. One thing that I feel got missed is Go has a very elegant way of traversing multi-dimensional arrays.

func (b *board) Board() string {
    var buffer = &bytes.Buffer{}

    for x, row := range {
        for y, v:= range row {
            cell := parseCell(x, y, v)

    return buffer.String()

Perhaps a better rule for nesting is that you should nest for only one purpose. Here the nesting is about traversing a board. But if you did any logic in the middle of my loop, that often makes it more difficult to read.

However, if I were manipulating 3-D space, having three nested loops would all share the same purpose. I just don't believe you can achieve the same easy understanding if you split it up into lots of functions.

code of conduct - report abuse