Ask HN: How do you write code so it's easy to change?
11–20 of 78 posts
Re: Ask HN: How do you write code so it's easy to change?
#12don't get trapped by being "too DRY"
Re: Ask HN: How do you write code so it's easy to change?
#13Keep in mind you can always start over, especially if you componentize your work!
As you prototype, or just design by drawing on whiteboard, learn your domain and gain ideas what would improve your initial lack of design.
Iterate and refine when cost effective to do so, not sooner. If still on whiteboard, you could benefit from implementing rapid no-code solutions before diving into any code at all!
Resist committing to structure, unless your experience and insights into the domain require it and you see clear benefits from doing so. Deconstruct structure you find bring unnecessary complexity, as well as build on structure when doing so clearly brings leverage.
Care for your code.
Re: Ask HN: How do you write code so it's easy to change?
#14Re: Ask HN: How do you write code so it's easy to change?
#15Re: Ask HN: How do you write code so it's easy to change?
#16While you're adding a feature it's always tempting to go down the "what if" route and make some kind of crazy interface that is extensible and able to accept plugins and all that. The problem is you're likely making it extensible in ways that turn out to be useless down the road.
Just code the least amount you have to in order to achieve the current goal. That way down the road it's easy to delete what you did, or code up some changes to it. I personally think the worst thing you can do is write code that is all things to all possible future features.
Re: Ask HN: How do you write code so it's easy to change?
#17If the word "architect" springs to mind then you are doing it wrong
Re: Ask HN: How do you write code so it's easy to change?
#18Re: Ask HN: How do you write code so it's easy to change?
#19It should be removable in a way that does not break other systems and it should be easy to identify when "it" ends and when something else begins