Patterns
Design Patterns
https://refactoring.guru/design-patterns/ (opens in a new tab)
Dependency Injection
https://javaee.github.io/tutorial/injection002.html (opens in a new tab)
- inject a managed object(dependency) into another managed object(dependent) by a container
- container automatically makes the injection at run time at the injection point
- injector may have different life span (request vs session)
For none DI like below, the downside is that:
- You can’t easily swap out the implementation for another one if you want to
- The dependency has to be known before runtime
import axios from 'axios'
export default {
async index() {
const result = await axios.get('...')
return result.data
}
}Repository vs DAO
https://www.baeldung.com/java-dao-vs-repository (opens in a new tab)