Comments (26)
I think it makes sense to prefer three letter prefixes. As Apple basically has freedom to use any two letter prefix they need. I don't know of any three letter class prefix for an Apple class (Mac or iOS). I was actually pondering this not to long ago. Having worked with Apple SDKs since 2005, I believe you will future proof your class names if you choose three letters for a prefix. Just my thoughts.
from objective-c-style-guide.
I agree on the three letters, it's safer.
If we had to pick one with three letters I propose RWV
, the V
in honour of Mrs Wenderlich :)
from objective-c-style-guide.
I don't see any benefit to using 3 character prefix. It feels like extra typing for little effect.
Just about every open source lib out there uses 2 characters prefix and I feel that's good enough.
from objective-c-style-guide.
Just about every open source lib out there uses 2 characters prefix and I feel that's good enough.
That is quite true, the majority do - however they are all putting themselves at risk of colliding with a future Apple class name. It's a pretty small risk, but it does exist.
However β¦ putting this is context, we are writing a code style purely for the Ray Wenderlich site. These are not long-lived open source projects, they are little apps. I'd be happy to use a RW
prefix, and if, in the highly unlikely event, it does collide in the future, we can change it.
- Colin E.
from objective-c-style-guide.
Unless apple decides to release a new API and pounce on the two letters. I think we would be safer with three, it is extra typing but less than having to go back later.
Tony
Sent from my iPhone
On Jan 15, 2014, at 8:38 AM, Marin Todorov [email protected] wrote:
I don't see any benefit to using 3 character prefix. It feels like extra typing for little effect.
Just about every open source lib out there uses 2 characters prefix and I feel that's good enough.β
Reply to this email directly or view it on GitHub.
from objective-c-style-guide.
@tdahbura: That's my main issue with a two-letter prefix too. Everything could be fine now, but if they release a new framework with two-letter prefix, the chance of a collision becomes pretty significant. Even if the actual class names are different, it's probably a bad idea to use the same prefix that Apple uses in their frameworks.
from objective-c-style-guide.
Guys ... this style guide is not a style guide for ObjC for reusable classes. Please note that!
It's a guide style aimed at online tutorials/ our books. If the case was this style was aimed at creating reusable classes I could see a benefit in making 100% of not clashing with Apple's namespaces, but since it's not - there isn't any such benefit.
from objective-c-style-guide.
I read the links above and found this as well: Programming with Objective-C: Customizing Existing Classes. They are strongly suggesting using three letters. @icanzilb I see your point, but I consider Apple an authority on Obj-C, since they basically own/dictate it's use. If you are teaching/educating someone on how to name classes, they should use Apple's suggested conventions. Per Apple, it is a best practice. Is it worth it to go against Apple just to save one/two capital letters?
from objective-c-style-guide.
+1 @icanzilb. I see the benefit of a 3-letter prefix, but given the scope and purpose of this guide I think it is not an issue.
from objective-c-style-guide.
@cbess I'm always for teaching things that people would use. Teaching people something they'll discard themselves is of no good for anybody. For example - Apple telling people to use 3char prefixes - check how many people do that.
from objective-c-style-guide.
@icanzilb True, but in my opinion that doesn't justify teaching it the non-preferred way.
from objective-c-style-guide.
everybody on the Internet is entitled to one aren't they π
from objective-c-style-guide.
@icanzilb Appealing to majority doesn't really justify "accuracy or correctness", because everyone could be wrong. Hence, having an authority. And since Apple has given thier two cents on the subject I think it is best to honor/heed their advice. You assume folks will discard it. This probably happens because they think it is arbitrary, not suggested by Apple. And maybe you (this guide) can help people know the "best" way to code.
from objective-c-style-guide.
I've heard that iOS 8 is coming with a new Reality Warping framework.
from objective-c-style-guide.
@ColinEberhardt Haha, it might! And it'll be magical (probably).
from objective-c-style-guide.
@raywenderlich proposed the RW prefix, so I'm interested to see what his thoughts are on what a three letter prefix should consist of.
from objective-c-style-guide.
I prefer and use 3 in my projects.
from objective-c-style-guide.
@ColinEberhardt are you sure it's not Reality Distortion?
from objective-c-style-guide.
@cbess I totally understand your point and think agree would make sense for open source projects and areas where you really wanted to make sure your code would last a long time without changing. But the fact of the matter is for our sites/books and the rapid release cycle of iOS, they're most likely out of date within a year anyway and doubtful if the code even runs without warnings :P
I think it would be best to stay with RW, as it's really the prefix that makes the best sense for our site - and in the unlikely event it gets snagged by Apple, we'll change it. Maybe we could put a little note somewhere that says "for your own projects, consider using a 3-char prefix".
from objective-c-style-guide.
@rwenderlich Understood. If its a point of convenience, then by all means use two (RW
), but if correctness is the aim, then three letters (RAY
) would be more considerate of Apple's best practices. And I think the note should use the same language as Apple, which is along the lines of "prefers", "insists", "commands", etc :) If it matters or helps anyone else, our teams (at Bottle Rocket Apps) have started changing our class prefixes from BR
to BRA
.
from objective-c-style-guide.
My one additional point on this is we are viewed by the readers of our stuff as best practices folks. Even in our tutorials we strive to teach "the right" way. Nothing is worse in my opinion than reading tutorials or books where the author's code would not stand up to a code review scrutiny. How many Java books out there that show System.exit() calls in exception handlers for web services modules?
Apple has indicated they reserve two letters...we can always put footnotes on it but the "correct" or Apple way is not to use two letters.
My projects have switched to three letters awhile ago.
I prefer our style guide to be what we do versus do what I say not what I do.
Just two more cents...
You guys should see the curly brace argument on one of my projects!
Sent from my iPad
On Jan 15, 2014, at 6:52 PM, "C. Bess" [email protected] wrote:
@rwenderlich Understood. If its a point of convenience, then by all means use two (RW), but if correctness is the aim, then three letters (RAY) would be more considerate of Apple's best practices. And I think the note should use the same language as Apple, which is along the lines of "prefers", "insists", "commands", etc :) If it matters or helps anyone else, our teams (at Bottle Rocket Apps) have started changing our class prefixes from BR to BRA.
β
Reply to this email directly or view it on GitHub.
from objective-c-style-guide.
Hm... good point Tony, I suppose I could be convinced on this. If we were to use a 3-letter prefix, what would it be though? Here are a few ideas:
RWC
for raywenderlich.com
RWT
for raywenderlich.com team/tutorial
RAY
not a huge fan of that one, but possibly
RTT
for raywenderlich.com tutorial team
from objective-c-style-guide.
I'd vote for RWT, where the T stands for Team. RWC is fine, too, but since a lot of people refer to the website simply by your initials, I think it's important to have RW in there.
from objective-c-style-guide.
+1 @tdahbura. I agree with @scott90. @rwenderlich, I'm not a big fan of RAY
either, I think RWT
is most fitting.
from objective-c-style-guide.
I will update the style guide to use three letters (RWT).
from objective-c-style-guide.
I like RWT.
Sent from my iPad
On Jan 15, 2014, at 9:26 PM, rwenderlich [email protected] wrote:
Hm... good point Tony, I suppose I could be convinced on this. If we were to use a 3-letter prefix, what would it be though? Here are a few ideas:
RWC for raywenderlich.com
RWT for raywenderlich.com team/tutorial
RAY not a huge fan of that one, but possibly
RTT for raywenderlich.com tutorial teamβ
Reply to this email directly or view it on GitHub.
from objective-c-style-guide.
Related Issues (20)
- Init section contradicts Golden path section HOT 2
- Can we lint to enforce some of this style guide? HOT 6
- English should be used, really? HOT 7
- What's the point on using properties instead of instance variables? HOT 8
- Direct access to properties. HOT 5
- License for this guide? HOT 1
- Not linking to Official Apple Style Guide HOT 1
- RWT prefix typo in constant definition HOT 1
- What is the recommended line width for Objective-C?
- Use style guide principles in examples
- arrayCount should be named something else HOT 4
- Contradiction between Init Methods and Golden Path
- Error handling
- I want make new branch for Korean ver.
- Google style guide URL is broken HOT 2
- Should self keyword should be used in init methods ?
- How do I indent something like this??? HOT 3
- Xcode behavior regarding indenting block
- ε ³δΊζδΈΎ(Enumerated Types)ηζ³ζ³
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objective-c-style-guide.