开发者

hints for naming methods

We all know that classes/objects should represent things while methods/messages should represent operations (verbs). But how to pick the right verb?

I've heard one "rule for method naming" is to imagine some completely different implementations and then simply pick name that is general for all of them.

EDIT: I also know that methods should be named as closest to domain as possible. (means after intention 开发者_开发问答not after implementation)

What others do you know?


I like to try to name things so that a given line of code would make as much grammatical and syntactic sense as possible, even to a non-programmer. (One of the reasons why I love lambda so much in my .NET code. It's like making new words from Latin roots, you just keep chaining things together.)

There's a pretty good article here on naming classes and methods when building a repository, for example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜