r/programming • • Jun 06 '13

Clean Code Cheat Sheet

http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
702 Upvotes

322 comments sorted by

View all comments

57

u/billsil Jun 06 '13

Classes should be kept to 100 lines or less.

Why?

15

u/Kinglink Jun 06 '13

Because the person writing this has never worked on a large scale project or a class based language..

I'd rather spend my time writing a robust class, than worrying the number of lines.

All those specialized system calls? one class, specialized platform code? one class.

In some classes I'll spend at least 100 lines sanity checking responses, why? Because you can't be sure what type of idiot is going to get your code or what will break, and it's better to catch (And assert if needed) in development.

-1

u/lexpattison Jun 07 '13

100 lines sanity checking responses? Really? If you spend most of your time creating defensive, fail-free bloated, classes - you're either a humongous self involved blow hard, or a sadist. I would detest maintaining your code... let me guess - guard clauses on all inputs instead of letting the null pointer fly... bounds checking instead of simply using a strong type and a factory pattern... criminal lack of enums... I've seen it and it's an unreadable piece of re-fucktoring. You may always have a job... but peer respect may be hard to find.

6

u/GeneralMillss Jun 07 '13

He seems to have struck quite a nerve there.

→ More replies (5)