Skip to content

Comment on Ask HN: How do you write code so it's easy to change?

Comments

Whole books have been written about this. I use the following rules from [1] myself. I like them because they definitely put some constraints on my coding which I like. It forces me to think beforehand and gives me (a junior developer) some guidance which I desperately need:

* Write functions/units that are <= 15 LoC.

* Create units with <4 branching points

* Write functions/units with <5 parameters

These guidelines force you to write maintainable code. Always open for discussion. Note that these lessons are lifted straight from [1].

[1] https://www.softwareimprovementgroup.com/resources/ebook-bui...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.