I've been programming for the many months.

What I've found is :

  • My team leader illustrates to me the project.
  • I start up with an empty project.
  • For many common tasks (like calling webservice, showing grid etc.), I either open my evernote account or my previous project.
  • I copy and paste the code and tweak it to meet my current requirement.
  • For just normal things (like alertboxes, storing cookies etc.) I use intellisense.
  • For anything else I go to google, I search and copy the code after reading and adjust it to my need.

When I complete my project my team leader and client are happy because the task is getting done.

But is it OK to google the code, store it and use it later? Remember I understand the code, I can tweak it later but I don't remember even the proper names of classes.

I don't really remember the code. Am I doing it right?

  • 8
    Just be sure to honor the licenses of the code you are copying. Otherwise, it could open your company up to some very serious legal ramifications. – bitsoflogic Apr 13 '11 at 16:01

I tend to say "Yes, you are doing it right". It's called code reuse.

Saving elements of your work for future use helps you avoid redundant googling over and over. It saves you time and improves your performance.

I too tend to quickly forget the names of classes and so on. In fact remembering them has no particular value. It was possible 20-30 years ago when we had one programming language which never changed through the course of the years. These days we're literally overwhelmed with dozens of new languages, libraries, tools and frameworks that release new versions every few months. Remembering all their details would be a futile exercise for a human.

  • 1
    +1 for sharing your thoughts about previous and current scenario. – necixy Apr 13 '11 at 16:23

Yes, this is perfectly OK. As you program more, you'll be able to remember class and method names better. Using evernote is not a bad idea for keeping personal notes, but I hope you guys are using proper source control for the client's code.

If you find that the same code is used in many projects with little or no variation, you can build a seperate API project with the common code and then include your API into any project that needs it. Obviously, it can get a bit more complicated than that in practice but this would be a good start.


A couple thoughts - saving and reusing code is absolutely a great practice - and I tend to think it's totally up to the developer how you archive your previous work and other useful code samples.

But... a few caveats from the view of a big company:

  • I'm assuming it's a given that among your tweaks are renaming classes, methods and variables as necessary if they impact the problem domain of the current work.
  • Be aware of where and how you store code that was written on your company's nickel. I know that many companies would be very upset to discover that code that they consider proprietary has been stored on the internet IN ANY FORM. The issue isn't mitigated by saying that it's in an account controlled only by you (GoogleDocs, Evernote, etc). The issue is that the code is in a place the company's security officer and lawyers did not approve. Storing it on your hard drive - no big deal. Storing in on a company supported file share - no big deal.
  • Be aware and check in with management on whether you can take code (even a small bit of it) from another job and unless you know it's OK, don't move code between jobs. The code is generally work for hire and it's owned by the company. The inter-company legal stuff is quite a mess and management is likely not to want any piece of a lawsuit involving getting sued by another company for intellectual property theft.

This is more of a problem in bigger companies with the potential to be targets for massive lawsuits. I can't say much about smaller companies - I don't work in one.

It's a fine line between inspiration and referencing a previously successful solution and cribbing code from a 3rd party. I tend to think that most Internet example code is safe since it's usually demonstrating a mechanism. It's when you are pulling down sizeable chunks of code that you have no intention of rethinking or rewriting that you are most at risk (and that doesn't sound like the case here).

I'm mostly pointing out the tricky area, and the areas that are most likely to involve long and frustrating conversations with lawyers and business people who have no clue about what the work is actually like. Since these people will be looking for black and white, it's good to avoid the triggers for such conversations whenever possible.

  • +1 for your second point. You must be careful as not to take code that belongs to your employer, lest you want to get sued. I have an NDA with my current employer and would be violating it if I shared code this way. – jmq Apr 13 '11 at 17:28

More interesting to me than the particulars of using actual bits of code in your new projects, is the fact that you are building a conceptual 'vocabulary' for yourself, which consists of working code-units to solve various tasks. This is how expertise is grown, and years of cognitive science research supports that model of knowledge-acquisition. So even if you don't actually get to reuse the code verbatim in your new projects, there is much to like about the workflow you describe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.