用于Java中的适配器模式 [英] Use for the adapter pattern in Java

查看:81
本文介绍了用于Java中的适配器模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习适配器和立面设计模式,以适应即将到来的初级开发角色,因为我期待被问到我对于使用它的模式和时间的了解。虽然这种模式本身似乎很直接 - 我正在努力想到一个实际的用途,我可以在个人项目中使用它。



所以,任何人都可以建议一个想法在一个小的个人项目中使用它?



该模式是否显示在Java API中的任何地方?

解决方案

对于在 Java API 中使用设计模式,请查看这个问题。



报价维基百科


在计算机编程中,适配器
模式(通常称为
包装器模式或简称包装)
是将
的一个接口转换为
兼容界面的设计模式。


所以你很少使用它。它只是调整两个不兼容的接口。



请记住,当您不需要设计模式时,只需不要使用它。只是因为它是写在大书中,并不意味着它可以满足您的所有需求,您必须盲目遵循。


I've been learning the adapter and facade design patterns for an upcoming junior development role i'm applying for, as i'm expecting to be asked what i know about the pattern and times i've used it. While the pattern itself seems straight forward - i'm struggling to think of a practical use i could use it for in a personal project.

So can anyone suggest an idea for a use for it within a small personal project?

Also does the pattern appear anywhere within the Java API?

解决方案

For uses in Java API of design patterns, look at this question.

Quoting Wikipedia:

In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface.

So you will use it quite rarely. It is just adapting two incompatible interfaces.

And remember when you don't need a design pattern, just don't use it. Only because it is written in the big books, it doesn't mean it serves all your needs and you must follow it blindly.

这篇关于用于Java中的适配器模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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