Chapter 6: Code Composition

Anatoly Volkhover

Apply SOLID principles to test if your architecture is compliant. Mentor your team to fully understand SOLID; those principles apply to almost everything in the software development. Refactor the code at the earliest signs of violation of any of the SOLID principles.

  • Elijah Wilson says:

    One question I have after reading this chapter is who should be responsible for defining the parameter interface in regards to ISP?

    So should the two interfaces, Checkout & Delivery, be defined next to the “checkout” and “deliver” functions? Or should they be defined next to the ProductCheckoutService and ProductDeliveryService? Supposing that the “checkout” and “deliver” functions are in a module separate from the services?

    My first thought is that these interfaces should be defined in the same module as “checkout” and “deliver”. But depending on the programming language, there might be circular dependency issues when trying to implement the aforementioned services.

    • anatoly says:

      Hi Elijah,

      Good question. One design pattern that could be a bit excessive but will never fail you is to always define a “pure” interface, which is then imported by both the implementation and by the consumers. Of course, this is subject to the limitations imposed by the programming language. If the language does not support “pure” interfaces, then you need to figure out the logical dependencies in your code, i.e. between the consumer and the implementation modules, which one is safer to break when the other one changes. The interface belongs to the “side” which you want to protect from the breaking

  • >