Coding Conventions  Coding conventions are a set of guidelines for a specific software project that recommend programming style, practices and methods.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
Coding Standards for Java An Introduction. Why Coding Standards are Important? Coding Standards lead to greater consistency within your code and the code.
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
Coding Standards A Presentation by Jordan Belone.
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 Doing C with Style.
1 Introduction to Software Engineering Lecture 42 – Communication Skills.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Chapter 3 Getting Started with C++
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Java Language and SW Dev’t
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
How to think through your program [ principles of good program design ] Rachel Denison MATLAB for Cognitive Neuroscience ICN, 13 December 2007.
Good Programming Practices. 2 home back first prev next last What Will I Learn? List examples of good programming practices Accurately insert comments.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
The Java Programming Language
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Style Guidelines. Why do we need style?  Good programming style helps promote the readability, clarity and comprehensibility of your code.
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
Advanced Computer Science Lab Coding Style & Documentation.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
Code Conventions Tonga Institute of Higher Education.
Lecture 6: Writing the Project Documentation Part IV.
Writing Maintainable code Dr. Susan McKeever DT228/3 GUI Programming.
Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Variables. Some Rules of Variable Naming Convention : Variable names are case-sensitive. A variable’s name can be any legal identifier. It can contain.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 10th, 2009 Introduction to Programming.
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Today… Style, Cont. – Naming Things! Methods and Functions Aside - Python Help System Punctuation Winter 2016CISC101 - Prof. McLeod1.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Dani Vainstein1 VBScript Session 8. Dani Vainstein2 What we learn last session? VBScript procedures. Sub procedures. Function Procedures. Getting data.
Click to edit Master subtitle style 03/02/11 Web And Coding Club IIT Bombay PHP (pre hypertext processor) By: Saurabh Goyal Apekshit Sharma.
Working with Java.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Coding Design, Style, Documentation and Optimization
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CMSC 104, Section 4 Richard Chang
Programming Vocabulary.
Lesson 4 Best Practices.
Top Tips for Better TSQL Stored Procedures
Variables ICS2O.
Variables in C Topics Naming Variables Declaring Variables
Unit-1 Introduction to Java
Chapter 1: Computer Systems
Variables in C Topics Naming Variables Declaring Variables
Writing Functions.
The lifespan of a variable
Documentation and Style
Topics Introduction to Functions Defining and Calling a Function
Chap 2. Identifiers, Keywords, and Types
Tonga Institute of Higher Education
Chapter 2 Primitive Data Types and Operations
Variables in C Topics Naming Variables Declaring Variables
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CSCE-221 C++ Coding Standard/Guidelines
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Pseudocode For Program Design.
Chapter 9: Implementation
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Coding Conventions  Coding conventions are a set of guidelines for a specific software project that recommend programming style, practices and methods.

File organization  Common well-structured folder hierarchy  Folder templates  Restrict user-creation folders to specific subfolders  Do not create overlapping categories  Many times file organization is dictated by the IDE or repository

Indentation  Examples of nesting rules:  Number of spaces indented after a function header  Number of spaces indented in a nesting  Increased readability is the goal

Comments  Types of comments  Descriptive blocks  Inline comments  Class comments (Descriptive block)  Method comments (Descriptive block)  Variable comments (Inline)  Comment while coding  Avoid obvious comments  Leave descriptive comments

Declarations  One or multiple declarations per line  Scope rules - modifiers

Statements  Forbidden statements (goto!)  Multiple criteria rules (use switch instead of nested ifs for >2 criteria)  Maximum levels of nesting  Preferred use (should use if then else instead of ternary operator)  Line length limits

White space  Line spacing  Spaces between keywords

Naming Conventions  Identifiers must be descriptive  Use underscore to separate words  Each word starts with a capital letter  camelCase: First letter of each word is capitalized, except the first word  Some developers prefer to use underscores for procedural functions, and class names, but use camelCase for class method names

Naming Conventions  Consistent temporary names  Capitalize SQL special words  SELECT id, username FROM user;

Grouping Conventions  More often than not, certain tasks require a few lines of code.  It is a good idea to keep these tasks within separate blocks of code, with some spaces between them.

Grouping Conventions  // get list of forums  $forums = array();  $r = mysql_query("SELECT id, name, description FROM forums");  while ($d = mysql_fetch_assoc($r)) {  $forums []= $d;  }   // load the templates  load_template('header');  load_template('forum_list',$forums);  load_template('footer');

Separate Code and Data  Rules should be enforced to separate code from data  This is the root cause of every buffer overrun/overflow exploit

Duplicate Code  DRY stands for Don't Repeat Yourself.  Also known as DIE: Duplication is Evil.  The principle states: "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."