Skip to content

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

Comments

Think of your tests as a consumer of the software you create. You will know it's easy to test if your component does not take much setup. If you have to create all kinds of different objects to get a test to pass, you've built a coupled component.

Said another way: Making an easy to understand interface to your software should be your top priority. Make the interfaces within your public interface as easy to understand, etc., all the way down.

Easy to test: Easy to understand. That makes it easy to change.

AboutSource Built by g1lg1l

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