Hacker News new | ask | show | jobs
by jdblair 3099 days ago
I like an 80 column limit for C and python, but it starts to be a problem in C++. This says something about C++ and I don't think it's positive.

I actually also like a fairly small limit on the number of rows (around 40). If my functions and methods are too complex to understand in this much space then it's time to refactor. Of course, I usually have to work on existing code and the functions/methods are not always so compact.

1 comments

I've often found that having all the code that's doing one thing in the same place is better than splitting it up into a bunch of functions just to keep rowcount low. It makes it easier to step through and reason about what is going on if all the steps of a logical sequence are actually laid out in a sequence (instead of intermittently jumping to other files). Whenever I find a function that I discover is only called in one place I just inline it, and in my opinion that improves the code every time. Abstraction is important, but understandability is more important.
The row and column limit is more of a guideline, not a hard and fast rule.