用于Java中的适配器模式 [英] Use for the adapter pattern in 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屋!