|
|
< Previous PageNext Page > |
Basic I/O Kit C++ naming conventions are defined in the document I/O Kit Device Driver Design Guidelines. This section refines those conventions in ways that should make them more useful to you as a programmer.
Basic Conventions
Additional Guidelines
The primary conventions are as follows:
Use the Java-style reverse DNS naming convention, substituting underscores for periods. For example, com_apple_foo
.
Avoid the following reserved prefixes:
OS
os
IO
io
Apple
apple
AAPL
aapl
This ensures that you will not collide with classes created by other companies or with future classes added to the operating system by Apple. It does not protect you from other projects created within your company, however, and for this reason, some additional guidelines are suggested.
These additional guidelines are intended to minimize the chance of accidentally breaking your own software and to improve readability of code by developers. This is particularly of importance for open source projects.
Begin each function name within a class with the name of the class. For example, if the class is com_apple_iokit_pickle
, and the function would be eat
, you should name the function pickle_eat
. This makes it easier to see class associations, particularly when called from other files.
Name classes based on project names. For example, if you are working on project Schlassen, and one of its classes was pickle
, you would name the class com_apple_driver_schlassen_pickle
.
Name families based on project names. For example, if you are working on project Schlassen, and one of its classes was pickle
, you would name the class com_apple_iokit_schlassen_pickle
.
Name classes hierarchically if your organization is large. For example, if Apple’s marketing department were working on the Schlassen project, then they might name the class com_apple_driver_marketing_schlassen_pickle
. If they had another project that was in the BSD layer that interfaced with this one, then that BSD extension’s class could be com_apple_bsd_marketing_schlassen_pickle
.
If you anticipate that the last part of the class name may be the same as the last part of another class name, consider beginning each function name with a larger portion of the class name. For example, you might have bsd_pickle_eat
and driver_pickle_eat
.
These are only suggested guidelines. Your company or organization should adopt its own set of guidelines within the constraints of the basic conventions described in the previous section. These guidelines should provide a good starting point.
< Previous PageNext Page > |
Last updated: 2006-11-07
|
Get information on Apple products.
Visit the Apple Store online or at retail locations. 1-800-MY-APPLE Copyright © 2007 Apple Inc. All rights reserved. | Terms of use | Privacy Notice |