When using a framework, it is best to keep it distant - as far as possible from the internal logic of the application. This makes it easier to maintain, tes,t and upgrade the application’s codebase and the framework independently.
Some techniques to do this:
- Use abstraction layers to separate framework from code. This allows the code to be written without knowing anything about the framework.
- Use dependency injection to separate the application from the framework. This is done to allow the application to run without instantiating framework objects directly.
- Avoid using framework-specific libraries or classes to allow easy switching to other frameworks