简体   繁体   中英

Naming conventions for using GCD intensively

I just dived into the world of using dispatch_queue a little bit more intensively and was wondering if there are some naming conventions that should be used just for GCD objects, so that the code of the classes is then more easily divided into GCD and other Code . Or could it be that it is a bad idea to have separate naming conventions for GCD?

I'd suggest to simply stick to the usual Cocoa and CoreFoundation naming conventions. Extend them as needed.

Edit after comments:

First of all, you shouldn't start variables with an underscore as this is reserved for Apple. Instead, I recommend to postfix with underscore, like someVariable_ or prefix with something else (for example, a colleague of mine uses i_ for instance variables and g_ for globals).

Whether you want to add some kind of polish notation (like prefixing with q_ for queues) is entirely up to you, it's a matter of taste. I think it's more important that you can recognize what a variable is used for, like imageProcessingQueue_ instead of just queue_ .

The problem is that this is entirely subjective and cannot be answered in an "this is the ultimate truth" way. Common sense and forethought are important and laziness (abbreviated names or very generic terms like simply queue_ ) should be avoided.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM