Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

this is a general question about programming, I hate using other people's code and I find myself coding things in my own way, even the simplest things like a web template, a PHP calendar, or a news module. Is there anything wrong with that ? Should I change and get in the habit of re-using other people's free code.


migration rejected from Jul 18 '13 at 11:24

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too broad by gnat, Dan Pichelman, MichaelT, Kilian Foth, GlenH7 Jul 18 '13 at 11:24

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

possible duplicate of What counts as reinventing the wheel? – GlenH7 Jul 18 '13 at 11:24

I would rewrite instead of reuse for the following reasons:

  1. It's core functionality, and I should have complete understanding and control of what goes into it.
  2. I only want a little bit of the functionality, and I don't want to pay for a learning curve for the whole thing.
  3. I don't understand how it works, and I have the space and time to figure it out.
  4. I can't find a library or framework that actually does what I need without stretching it beyond the intended use.

First of all, if you do not want to use other peoples code, you cannot by definition be a part of a team. This is a great hinderance as most non-trivial software projects are lifted by teams.

Then, if you want to do everything yourself, it takes longer (yes, it does) and you do not get the insight of others and at some point the maintenance burden gets too large for you to perform.

Hence, strongly reconsider your position. The view is better when you stand on the shoulders of others.


I have been taught in school that you should reuse unless you are in of the following categories:

  1. You are trying to learn how something works
  2. You can do it better
  3. You are not allowed to use an existing module

The first simply means, if you do not know how a parser works and what the challenges it overcomes, then write one yourself. This works for any technology that acts as a glue and for simple projects (like a calendar).

If you have come up with an algorithm that runs faster in the case that you'll most likely need it, then write your own. For example, if your calendar needs to cover multiple calendar types (think lunar and Gregorian), and you cannot find one already, then do it yourself. You should market the solution since other people will probably have the same problem.

Your company may not allow you to use a particular module based on the licence or other policy. In this case you can only really write your own library/system.

@jprete raises a good point in that core functionality should be implemented yourself. I argue that if there is a library/system that already exists that completes your core function, then your system may work better as glue that binds together multiple systems to enhance their behavior.

In all cases, you must make a conscious decision on whether you will write the functionality yourself or use a third-party library, and be able to argue your decision. Each project is unique and will force you to chose differently. Even the same project with different team members may imply a different choice.

Hope that helps.


This partly depends on what the piece of code does.

You should never write your own security code unless you know very well what you're doing, and you can get reviews by other people who are very experienced in security software and how to attack it. There's too many ways you can screw up and not realize it, even if you're very competent in general.


There is nothing wrong about hating using someone else's code in general. In most cases, the source code you find on the internet may not be very good. It doesn't match the standards, is not tested, is not readable, etc., which is especially true in PHP, where too many people writing code are inexperienced.

Creating a news module is not very hard. Finding an usable one, then finding how to use it (with no documentation available) may be much longer and difficult. Later, when your customer will ask you to make a small modification, if it's not your code, it will take you much longer, or will even be impossible to do.

On the other hand, don't rewrite just for rewriting. If you implement your own date-time methods instead of using ones already implemented in PHP, there will be a problem. If you invent your own cryptography algorithm for storing sensitive data instead of using existing ones, chances are that security issues will arise very quickly.

To conclude, it's ok if you write your own code because the code you can find suck from your point of view or require too much effort to work with. It's not ok if you write your own code just because you don't want to reuse.

In all cases, don't fall into the reuse syndrome: it's not because something was already written than you must reuse it at all costs. Some companies promote this approach (and in general tell you that the future of a developer consists of drag-dropping reusable blocks to create commercial products), but this approach of software development is neither realistic, nor serious.


Would not say this is the case for everything, but if you are spending time writing your own calendar control, then you probably are wasting some valuable time. There are loads of good calendars out there written by people who do nothing but make calendar controls all day for people to use, pretty much drag and drop. Unless you are one of those people, why not drag and drop the stuff that is not central to your application. There is always more to do that cannot be drag and dropped, so focussing on those things might make you significantly more productive.