aLec35_ProgrammingStyle - EE319K Lecture 35.1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
EE319K Lecture 35.1 by Jonathan W. Valvano Self-Documenting Code Naming convention Names should have meaning. Avoid ambiguities. Give hints about the type. Use the same name to refer to the same type of object. Use a prefix to identify public objects. Use upper and lower case to specify the scope of an object. Use capitalization to delimit words. An object's properties (public/private, local/global, constant/variable) are always perfectly clear at the place where the object is defined. The importance of the naming policy is to extend that clarity also to the places where the object is used. type examples constants SAFE_TO_RUN START_OF_RAM PORTA local variables maxTemperature lastCharTyped errorCnt private global variable MaxTemperature LastCharTyped ErrorCnt public global variable DAC_MaxTemperature Key_LastCharTyped Network_ErrorCnt private function ClearTime wrapPointer InChar public function Timer_ClearTime RxFifo_Put Key_InChar Examples of names. C language Style Guidelines Code File Structure, the *.c file Opening comments in the code file. Intended to be read by co-worker first line should contain the file name. the overall purpose of the software module, the names of the programmers, the creation (optional) and last update dates, the hardware/software configuration required to use the module, any copyright information.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE319K Lecture 35.2 by Jonathan W. Valvano Including .h files. will help us draw a call-graph avoid having one header file include other header files only those files that are absolutely necessary #define statements . they will be private client does not need to use struct union enum statements. create the necessary data structures they will be private. Global variables and constants. If static then it will be private If no static then it will be public The scope of a variable includes all the software in the system that can access it. In general, we wish to minimize the scope of our data. char publicGlob;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

aLec35_ProgrammingStyle - EE319K Lecture 35.1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online