开发者

iOS - Abbreviating XXXViewController to XXXVC bad or ok?

开发者 https://www.devze.com 2023-03-26 22:43 出处:网络
Since every view controller ends with \"ViewCo开发者_StackOverflow中文版ntroller\" would it be evil to simply abbreviate it as \"VC\"? I know the Apple Docs say not to abbreviate things and make the n

Since every view controller ends with "ViewCo开发者_StackOverflow中文版ntroller" would it be evil to simply abbreviate it as "VC"? I know the Apple Docs say not to abbreviate things and make the names meaningful but isn't this something that's just obvious what it is? I find it lengthy and verbose to type ViewController after every single one. Also, xcode 4 automatically names the nib file the same as the header and class files. Do you remove the "Controller" part of it?

What are your naming conventions and why did you choose to do it that way?

Thanks


If you're using Xcode, you shouldn't have to type the full name every time. Auto-complete handles that for you.

In general, avoiding abbreviation makes your code more readable and easier to maintain. Sure you know what VC means, but someone else 3 years from now might not understand what you were doing.

In this specific case, it may not make tons of sense, but naming conventions are conventions. We follow them in most cases to make our lives (and others) easier in the future.

Always imagine that the person who will eventually maintain your code is a big mean guy with a hair-trigger temper who knows where you live.


Despite what people seem to say Apple has excellent documentation. They have even gone so far as to provide a Coding Guidelines document.

This not only provides some good examples for you to use, but also helps to understand the way name, conventions and abbreviations are used in the Frameworks.

0

精彩评论

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