Sunday 20 November 2011

What is the correct way to name a function? in C programming

What is the correct way to name a function?

Functions should generally begin with a verb and end with a noun. This practice follows the general convention used by the English language. Here are some examples of properly named functions:

PrintReports();
SpawnUtilityProgram();
ExitSystem();
InitializeDisk();

Notice that in all of these examples, a verb is used to begin the function name, and a noun is used to complete
the function name. If you were to read these in English, you might recognize these functions as

print the reports
spawn the utility program
exit the system
initialize the disk
Using the verb-noun convention (especially in English-language countries) makes your programs immediately
more readable and familiar to the programmer who is reading your code.

Cross Reference:

XIX.5: What is camel notation?
XIX.8: What is the correct way to use braces?
XIX.10: What is Hungarian notation, and should I use it?

No comments:

Post a Comment