什么是适配器类? [英] What is an adapter class?

查看:742
本文介绍了什么是适配器类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用谷歌搜索并调查,但我仍需要澄清:适配器类和控制器类是否类似?如果没有,他们会以何种方式区别?

I googled and investigated, but I still need some clarification: Are an adapter class and a controller class similar? If not, in what way they do differ?

请解释。

推荐答案

Adapter是一种提供接口或抽象类的默认(通常为空)实现的模式。例如 MouseAdapter 提供 MouseListener 接口的空实现。它很有用,因为通常你并不真正使用接口声明的所有方法,因此直接实现接口非常冗长。

Adapter is a pattern that provides default (often empty) implementation of interface or abstract class. For example MouseAdapter provides empty implementation of MouseListener interface. It is useful because very often you do not really use all methods declared by interface, so implementing the interface directly is very verbose.

控制器是MVC - 模型 - 视图 - 控制器模式的一部分。与适配器没有直接关系。

Controller is a part of MVC - Model-View-Controller pattern. No direct relation with Adapter.

这篇关于什么是适配器类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆