Difference between object adapter pattern and class adapter pattern

前端 未结 5 1500
滥情空心
滥情空心 2020-12-13 09:50

How to decide when to use object adapter and when to use class adapter?

Problem statement: To create social networking web site and provide import functionality from

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 10:37

    https://www.journaldev.com/1487/adapter-design-pattern-java Adapter design pattern is one of the structural design pattern and its used so that two unrelated interfaces can work together. The object that joins these unrelated interface is called an Adapter. - Two Way Adapter Pattern While implementing Adapter pattern, there are two approaches – class adapter and object adapter – however both these approaches produce same result.

    Class Adapter – This form uses java inheritance and extends the source interface, in our case Socket class. Object Adapter – This form uses Java Composition and adapter contains the source object.

提交回复
热议问题