开发者

How do you call a method that only exists to make another method name nicer?

I would like to know the proper term for a method whose only reason of开发者_Go百科 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.


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.

Adapter and Facade are both wrappers; but they are different kinds of wrappers. The intent of Facade is to produce a simpler interface, and the intent of Adapter is to design to an existing interface

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜