DEV Community

Discussion on: Why The Dependency Inversion Principle Is Worth Using

Collapse
 
thunderclap1030 profile image
Dat Pham

I think in section what if we want to add credit card payment? We might modify our code like this

not violates the Dependency Inversion a instead of it violates the Interface Segregation Principle and Open/Closed Principle 🤔

According to with example, you break down "Payment" interfaces into more granular and specific ones. Clients should implement only those methods that they really need and don't depend on methods they do not use. So that mean you already resolve problem with Interface Segregation Principle