Recently saw a joke, the effect is a passer-by to the telecommunications business Hall to pay the bill, to the salesperson said to charge 50 yuan, the salesperson asked a "How much?" Passers-by a thought now society really is different from the past, even the general salesperson are beginning to speak English, so it is not very fluent in the spoken language of "Fifty YUAN". The salesperson looked at him confused and said, "How much is the number?" "Passers-a This just suddenly dawned, originally is to ask my telephone number, but not how much money."
Perhaps the joke itself is not funny, but it shows a truth: we should try to express their ideas as accurately as possible, do not let others feel puzzled. The same principle applies to the software development process, which is applied to the process of writing code.
In the process of programming, we should make sure that each line of statements we write is accurate, so that others can see it, especially for variables and function naming. Influenced by school education, such as "int i,j;", "Char C;" Variables such as these are everywhere, seriously affecting the efficiency of the work.
In this article, I don't want to say anything about the rules, but it's a practical example to show the reader how to name variables and functions is appropriate. Here with the "School C language Textbook defects" in this article, the program code appears as an example, the code is modified according to the specification, as follows:
/***************************************************************
* All rights reserved (C) 2014,company name.
* * File name: example.c * Content Summary: Used to demonstrate how to make variables and functions of the canonical naming * other instructions: no * current version: V1.0 * Author: Zhou * Completion Date: 20140325 * * Modified record 1://Modify history, including modification date, version number, modifier and modified content etc. * Modified Date: * Version number: * Modified by: * Modified: *********** /#include <stdio.h> typedef sig Ned int INT32; Redefine data type typedef float float; Redefine data type FLOAT processfactorial (INT32 iinputvalue); function Declaration/********************************************************************** * Function Description: main function * input parameter : no * OUTPUT parameters: No * return value: No * other Description: No * Modified Date version number modify the content *------------------- -----------------------------------------------------------------------------------* 20140325 V1.0 Zhou Create **********************************/INT32 Main () {INT32 iinputvalue = 0;
FLOAT fresult = 0.0;
printf ("Input an integer number:");
scanf ("%d", &iinputvalue); Fresult = Processfactorial (Iinputvalue);
Call factorial function printf ("%d!=%10.0f\n", Iinputvalue, Fresult);
More wonderful content: Http://www.bianceng.cnhttp://www.bianceng.cn/Programming/project/return 0;
/********************************************************************** * Function Description: To find the factorial of a number * Input parameter: iinputvalue-input value * OUTPUT parameter: no * return value: The result of factorial results * Other notes: No * Modified date version number revision person repair Change Content *-----------------------------------------------------------------------------------------------------* 20140325 V1.0 Zhou Create **************************************************************** /FLOAT processfactorial (INT32 iinputvalue) {FLOAT fresult = 0.0;
First determine if the input value is less than 0 if (Iinputvalue < 0) {printf ("Iinputvalue < 0, dataerror!");
return-1;
{else {if (iinputvalue = 0 | | iinputvalue = = 1)//0 and 1 factorial is 1 {
Fresult = 1; else {fresult = processfactorial (iInputValue-1) *iinputvalue;
Execute recursive call} return (Fresult); }
}