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