Magento 2 Certification Questions List | Use dependency inside classes

You are implementing customization of the sales management within a module MyCompany_MySalesProcess. You have created several event observers to add custom functionality. Each observer is a separate class, but they require some common functionality.

How do you implement the common functionality in the event observers, keeping maintainability and testability in mind?

Question from https://u.magento.com/free-study-guide

Answer:
  • You create a regular class implementing the common functionality as public methods and use constructor injection to make them available to the observers.
Prepear for Magento 2 certefication with our interactive quiz