Coding Standards for Writing Functions
Whether its C programming language or C++ programming language or PHP, we should have a coding standard in place before starting with the code development. Coding standard is a predefined standard which should be followed during the code development which will improve the quality of the code.
The coding standards varies from organization to organization. Each organization define their own coding standard and follow them to achieve the desired code quality.
Here, we will define a coding standard for writing functions.
Coding Standards for Writing Functions
- A function name should be preceded by
fn
- The first character in the function name should be written in uppercase. Every subsequent word in the function name should start with an uppercase alphabet.
Example:
fnFactorial
fnItemDisplay - The function should begin with a header which describes about the function. It is written as follows:
/***************************************************** * Function: fnFactorial() * Description: Accepts an integer and finds the * factorial * Input Parameters: * int - Number for which factorial to be found * Returns: int - Factorial of the given integer ****************************************************/ int fnFactorial(int intNumber) { /*code to calculate factorial of a number*/ }
1 Response
[…] Also see: How does using functions make writing large programs easier? Coding Standards for Writing Functions […]