How do you make code reusable? [closed]

See 10 tips on writing reusable code for some help.

  1. Keep the code DRY. Dry means “Don’t Repeat Yourself”.
  2. Make a class/method do just one thing.
  3. Write unit tests for your classes AND make it easy to test classes.
  4. Remove the business logic or main code away from any framework code
  5. Try to think more abstractly and use Interfaces and Abstract classes.
  6. Code for extension. Write code that can easily be extended in the future.
  7. Don’t write code that isn’t needed.
  8. Try to reduce coupling.
  9. Be more Modular
  10. Write code like your code is an External API

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)