Guidelines for a Language- Independent Convention Identify global variables –Use g_prefix –Exp: g_RunningTotal Identify module variables –Use m_prefix.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 C++ Syntax and Semantics The Development Process.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Software Engineering Variables. The data literacy test Count 1.0 if you know what the concept means. Count 0.5 if you believe you know what the concept.
Variables and Powerful Naming Ryan Ruzich. Naming Considerations The most important consideration in naming a variable is that the name fully and accurately.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Chapter3: Language Translation issues
Naming Programming Studio Spring 2008 Lecture 2. Purpose of Coding.
Chapter 2: Introduction to C++.
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
General Issues in Using Variables
Reference Materials: Dictionary, thesaurus and glossary
COMPUTER SCIENCE I C++ INTRODUCTION
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
ECE 103 Engineering Programming Chapter 10 Variables, AKA Objects Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
First Steps in Modularization Simple Program Design Third Edition A Step-by-Step Approach 8.
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Basic Semantics Associating meaning with language entities.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Program style. Global area Place comment s at beginning of the program: 1.purpose 2.author 3.the date the program was written 4.the data and description.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Programming Languages and Paradigms Imperative Programming.
Engineering Computing I Chapter 4 Functions and Program Structure.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Basic Program Construction
Best Practices for Variables
Using Variables Chapter Outline 2  Variable Initialization  Scope  Persistence  Using Each Variable for Single Purpose  Variable Names.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Communicating in Code: Naming Programming Studio Spring 2009.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 3: Using Variables.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
Revision Lecture
ICS103 Programming in C Lecture 3: Introduction to C (2)
Data types and variables
Chapter 2: Introduction to C++
2.1 Parts of a C++ Program.
Chapter 1: Computer Systems
Chapter 09 – Part II Using Variables
Chapter 2: Introduction to C++.
Coding practices For IT and Computing students 2014.
Primitive Types and Expressions
C – Programming Language
Brent M. Dingle Texas A&M University Chapter 5 – Section 1
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Guidelines for a Language- Independent Convention Identify global variables –Use g_prefix –Exp: g_RunningTotal Identify module variables –Use m_prefix –Exp: m_Compute Identify type definitions –Use suffix _t –Exp: Color_t

Guidelines for a Language- Independent Convention Identify named constants –Use suffix _c –Exp: MaxRecs_c Identify enumerated types –Use suffix _e –Exp: Color_e Format names to enhance readability –Exp: GYMNASTICPOINTTOTAL is less readable than GymnasticPointTotal

Guidelines for Language- Specific Conventions C Conventions: –c and ch are character variables –i and j are integer indexes –n is a number of something –p is a pointer –s is a string –Preprocessor macros are typed in ALL_CAPS –Variable and routine names are in lower­_case –The underscore (_) is used as a separator

General Abbreviations Guidelines Use standard abbreviations (as in dictionary) Remove all non-leading vowels (Computer becomes Cmptr, Screen becomes Scrn) Use the first letter or first few letters of the word Truncate after the first, second, or third letter Keep the first and last letters Use every significant word in the name Remove useless suffixes – ing, ed, etc Keep the most noticeable sound in each syllable

Comments on Abbreviations Don’t abbreviate by removing one character from a word Abbreviate consistently Create names that you can pronounce Avoid combinations that result in mis- pronunciation Use a thesaurus to resolve naming collisions Document short names with translation tables

General Issues in Using Variables Scope –It refers to what extent your variables are known be can be referenced throughout a program –A variable can be visible in a function, a routine, or in the whole program –Some guidelines: Minimize scope Keep references to a variable together

General Issues in Using Variables Persistence –It is the life span of a piece of data –Exp: new() in Pascal persists until dispose(), local persists in that particular function Binding Time –Bind the variables at the latest –Exp: Use TestID = MAX instead of TestID = 100

General Issues in Using Variables Using each variable for exactly one purpose –Use each variable for one purpose only –Avoid variables with hidden meanings Exp: PageCount is number of pages; but if the value is -1, it indicates an error msg –Make sure all declared variables are used