views:

43

answers:

2

I cant find a good answer for this question!

Thanks in advance!

A: 

I would say when you cannot guarantee that the code your reusing will perform the functions as required.

Preet Sangha
+1  A: 

There are lots of possible reasons:

  1. When it's illegal to use (kudos to Mitch Wheat), say the license doesn't fit (Eclipse can't ship with GPL'd code even though both are open source).
  2. If there is a much better solution today (i.e. the old code should be lead behind the house and shot dead).
  3. When you don't understand it. That's often a sign that there's something wrong
  4. When it has known bugs
  5. It's old code and refactoring the application to make the code reusable is too risky.
  6. If that would introduce unwanted dependencies into your code. Say you want to reuse code that can access a database under certain circumstances. To reuse the code, you must add the DB driver classes to your new code even through they are not needed.
  7. If you don't have unit tests that make sure the reuse is appropriate
  8. When you don't know what you're doing (as in junior developer)
Aaron Digulla