Live data from Hacker News

Ask HN: How often do you really reuse ​your code?

news.ycombinator.com

11–15 of 15 posts

Re: Ask HN: How often do you really reuse ​your code?

#11
Straight up reuse - very rarely. But fairly often I'll just go "ohhh i've done smth like that in that other project" and just go look at the code, paste it in, play around a bit. More about getting into the zone and having the past experiences pop back into the mind rather than reusing code.

Re: Ask HN: How often do you really reuse ​your code?

#12
I re-use my code less across projects in the web, but well designed MVC or MVVM can save you a lot of time. Just by having models available, I can re-use them on every page.

This turned out to be a life saver when I had to analyze / modify a bunch of data- I was able to get a node script up and running over one weekend re-using the existing javascript models and just focus on the analysis, instead of having to recreate everything in Java or Python.

Re: Ask HN: How often do you really reuse ​your code?

#13
How often? Daily!

I do a lot of HTML/CSS specialist stuff, writing a lot of front-end interactivity from scratch. I maintain a list of snippets that have helped me and others.

https://gist.github.com/tomhodgins/27c29ecb4aceaefe5cdf

Any code I have re-used three or four times ends up getting cleaner each time I work with it, and if it has proved useful a handful of times I add it to list of Snippets :)

Lately I have also been building teeny tiny HTML pages that illsutrate one concept clearly.

Here's my demo of how to harness multitouch cursors with plain JavaScript: http://staticresource.com/touches.html or heres another demo that illustrates JavaScript's Math.random() http://staticresource.com/marbles.html

Little pages like that serve as reminders, teaching tools, and provide a quick reference for me when I want to re-use similar concepts in another project, without looking up what other people are doing or grabbing the trendy Framework du jour.

Re: Ask HN: How often do you really reuse ​your code?

#15
If you count utilizing metaprogramming features within some of the more mainstream languages, my code re-use is sky-high.

If you aren't generalizing the problems you're solving in such a way that you can just use policy-types to customize behavior, you're probably not doing yourself any favors in the code re-use sense.

Post reply on HN