如何调用一个只是为了让另一个方法名称更好听而存在的方法?
我想知道一个方法的正确术语,该方法存在的唯一原因是使方法调用更容易,使方法名称听起来/读起来更好。
就像这样:
public function translate($string)
{
return Zend_Registry::get('Zend_Translate')->translate($string);
}
我可以将其称为适配器,但这是为适配器设计模式保留的。
I would like to know the proper term for a method whose only reason of existence is to make a method call easier, make a method name sound/read better.
Like that:
public function translate($string)
{
return Zend_Registry::get('Zend_Translate')->translate($string);
}
I could call it an adapter but that's kind of reserved for the Adapter design pattern.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它称为外观设计模式。通常保留用于接口和系统,但没有理由不同样适用于各个功能。
嗯,所以也许它是一个适配器:)
就我个人而言,我尽量不要太担心什么正式定义(如果软件设计确实存在这样的东西),而更担心我使用的词语是否足以向某人传达我的意图还有谁在读书。如果你说适配器并且我们了解发生了什么,那就没问题了。
It's called the Facade design pattern. Usually reserved for interfaces and systems, but there's no reason why it doesn't equally apply to individual functions.
Hmm, so maybe it is an Adapter :)
Personally, I try not to worry too much about what formal definition (if such a thing truly exists for software design) and worry more whether the words I use sufficiently communicate my intent to someone else who's reading. If you say adapter and we understand what's going on, then that's all fine.
我将其称为辅助函数、便利函数或包装函数。
I'd call that a helper function, a convenience function, or a wrapper function.
我称它们为代理函数,但这只是我的说法。
I call them proxy functions, but that's just me.