I wonder how it looks for other people, is it worth to make your code reusable in the first place?
Ask HN: How often do you really reuse your code?
1–10 of 15 posts
Re: Ask HN: How often do you really reuse your code?
#2Though in Rails, very rarely, it's usually faster just rewriting it than trying to 'frankenstein' it from a set of piecemeal snippets.
Re: Ask HN: How often do you really reuse your code?
#3Re: Ask HN: How often do you really reuse your code?
#4Custom CMS - 100% reuse - always start with a rolling base and constantly improving it though WP sites have cut into this - people think WP is better - get what you pay for.
Random 1-offs - how many times I've had to build a newsletter system... Base system gets copied and installed with specifics changed - where to pull the email list from, mailgun or aws for sending, etc...
Server config could be considered "code reuse" - I'll almost always refer to another server I built or run myself to copy apache / php / whatever config sections as a starting point.
Re: Ask HN: How often do you really reuse your code?
#5Then, go and create that library. You'll get more reuse (and better test coverage, maintainability, open-source ability) than just making spaghetti code every time.
Re: Ask HN: How often do you really reuse your code?
#6Re: Ask HN: How often do you really reuse your code?
#7But that's probably not the way you were looking at it when you asked the question...
Re: Ask HN: How often do you really reuse your code?
#8Re: Ask HN: How often do you really reuse your code?
#9It also prevents code from turning into spaghetti when adding "special" cases
Re: Ask HN: How often do you really reuse your code?
#10The huge advantage of making reusable code, even if you never reuse it, is that it's clean and decoupled from the other parts of your application. Thus it'll be easier to understand and to deal with - you won't have to look over what dependencies might cause unwanted effects here or there or what might be able to go wrong in case X. With decoupled code you only need to make sure it does it's "one" (main) function pro…