Pregunta

My idea is that adapter design pattern improves both modifiability and locality of a system. Because with adapter pattern, we can simply change code easily on the interface. However, how exactly does it help the locality of a system? Thanks!

¿Fue útil?

Solución

Maybe you are mistunderstanding the Adapter pattern. Having components with interfaces is good OOP aproach, usually defined as low coupling and high cohesion principles. As wikipedia says : An adapter helps two incompatible interfaces to work together.

About locality : The adapter allows two interfaces communicate. It is used usually when you cant change any of the interfaces. For example you have TV and Control TV from different companies and you cant really change what the both products have. But you can add your own interface to the TV, which change the control signal messages to the ones the TV expect. Locality (almost the same as High Cohesion as far as I know) stays the same. You still have two independent interfaces and you are using them. You dont bind these two component together and that is what you want.

(btw : In this situation Locality CANNOT be improved, so do somehthing new and let the locality stays the same is the best you can do for it)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top