Welcome, Guest! Log In | Create Account

Do not remove parameter names

From cpwiki

Jump to: navigation, search

Many take the opportunity to remove the names of parameters in prototypes, such as this:

void Allocate(char[], char[], char[], char*);
void DisplayName(char*);

However, this approach has several drawbacks:

  • Anyone had who reads the prototype will have no idea what kind of parameters it takes.
  • Some tools, such as Microsoft's IntelliSense parses the prototypes to give additional information about the function the programmer is trying to call. Hence, when the names of the parameters is missing from the prototypes, IntelliSense cannot display what parameters the function takes, not being very helpful to the programmer.
  • Typically, when a function header changes, so must the prototype. A typical resolution to this problem is to copy the function head and paste it and use it as a prototype, as well. If then the programmer proceeds to strip the names of the parameters, that incurs extra work.

Therefore, it is not recommended to strip the names of parameters from the function prototypes.
A correct example of how the prototypes should look like this this case is:

void Allocate(char lastName[], char firstName[], char middleName[], char* ptrName);
void DisplayName(char* ptrName);


Examples:

Image:Bad_Intellisense.jpg
Picture: Not very helpful...

Image:Intellisense_Much_More_Helpful.jpg
Picture: IntelliSense is much more helpful now...