Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Two reasons:

1: My 15" screen is about 160 characters at my preferred font size. When I want split screen to compare two files then each one should only be about 80 characters. There is even less space when using IDEs or text editors that include file drawers or other widgets.

2: Excessive characters on one line is a code smell just like excessive line counts in one method. You agree that 300 characters is too much. If 90 is too little then at what point should an automated tool trigger a warning?



Well, the problem really stems for what you call a "code smell".

All the good practices about programming will mention that:

1) Excessive line count in a method is a code smell 2) Excessive number of characters is also a code smell 3) Non descriptive variable names are universally considered bad practice.

Now my problem with all this dogma is that if you combine 1, 2 and 3, you're left with a severe conundrum. And to me, excessive number of lines in a method and naming your variables a,b,c,d,e are concessions that I prefer to avoid if I can simply crank up the number of characters on a line (taking into account indentation caused by conditionals, method definitions, blocks, etc).


(1) (2) (3) can all coexist :

First you fix (3), by naming variables in a nice, descriptive way - that possibly causes violations of (2).

Then you fix (2), by having lines/statements that are clear and don't do ten things at once - that possibly causes violations of (1).

And then, you fix (1), by refactoring your methods properly - and that is a valid goal by itself.

If instead you have longer lines, then the problem of your method being too big doesn't go away, it still does the same thing, you just don't notice it. If (1)+(2)+(3) would force you to split up your methods, then that's an indication that those methods should be split up anyway, even if you choose to ignore (2) and (3) - "too many lines of code" is a code smell simply because it correlates to "does too much", and even a one-line method can possibly be doing too much, if it's written in code-golf-style.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: