1 view
Which design patterns have you used in real-world work, and in what situations?
Asked at
AI answer
I’ve used different patterns depending on the task:
- Dependency Injection — to pass dependencies to services explicitly and simplify testing.
- Repository — to separate business logic from data-storage details.
- Strategy — when an operation needs to be performed in different ways, for example, choosing a calculation or payment method.
- Factory — to centralize the creation of objects with different configurations.
- Adapter — to adapt a third-party library’s interface to the application’s interface.
- Observer / events — to trigger side effects, such as notifications, without coupling them directly to the main logic.
I try to use a pattern when it solves a specific problem, rather than adding abstractions for the sake of the pattern itself.
Also asked at AutoSpot
- Tell us about yourself as a developer — experience, stack, projects.
- What are your salary expectations?
- Do you have experience writing and working with native SQL queries or similar low-level commands to a database?
- What AI tools do you use and for what tasks?
- What do you know about indexes? How can you determine which indexes are used in a query, and how can you tell which indexes are unnecessary or missing?
Similar questions
- How would you improve the way the status value is stored and handled?
- Which versions of PHP have you mainly worked with?
- Have you ever written tests (Codeception, unit tests)?
- Which design pattern is best to apply when creating an object considering different implementation conditions?
- What is the time and space complexity of your implementation?