Coding Standards A Presentation by Jordan Belone.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Chapter 1: Computer Systems
Communicating in Code: Layout and Style Programming Studio Spring 2012 Note: several examples in this lecture taken from The Practice of Programming by.
Coding Standards for Java An Introduction. Why Coding Standards are Important? Coding Standards lead to greater consistency within your code and the code.
IT151: Introduction to Programming
Communicating in Code: Layout and Style Programming Studio Spring 2009 Note: several examples in this lecture taken from The Practice of Programming by.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
Lecture 3: Topics If-then-else Operator precedence While loops Static methods Recursion.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
15-Jun-15 Beginning Style. 2 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don’t.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
More loops Linag, Chpt 3, pp The do-loop continue- condition ? loop-body statements next statement false true WHILE-LOOP continue- condition? loop-body.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
26-Jun-15 Beginning Style. 2 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don’t.
Chapter 2: Introduction to C++.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
EGR 2261 Unit 4 Control Structures I: Selection  Read Malik, Chapter 4.  Homework #4 and Lab #4 due next week.  Quiz next week.
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
CSC204 – Programming I Lecture 4 August 28, 2002.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 4: Control Structures I (Selection)
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 4: Control Structures I (Selection)
Java Coding Standards and Best Practices Coding Standards Introduction: After completing this chapter, you will able to keep your code up to standards.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Advanced Computer Science Lab Coding Style & Documentation.
Chapter 2: Java Fundamentals
A First Simple Program /* This is a simple Java program. Call this file "Example.java".*/ class Example { // Your program begins with a call to main().
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 4: Control Structures I (Selection)
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Code Conventions Tonga Institute of Higher Education.
Coding Conventions  Coding conventions are a set of guidelines for a specific software project that recommend programming style, practices and methods.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational and logical operators.
Chapter 2: Introduction to C++. Outline Basic “Hello World!!” Variables Data Types Illustration.
1 Chapter 2: Java Fundamentals cont’d Spring Lory Al Moakar.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
By: Travis Powell and Chad Herman. About CoffeeScript The Golden Rule: o "Its just JavaScript" One-to-One Compilage into equivalent JavaScript Passes.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
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
Information and Computer Sciences University of Hawaii, Manoa
Chapter 4: Control Structures I (Selection)
More on the Selection Structure
Communicating in Code: Layout and Style
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
Communicating in Code: Layout and Style
Conditional Execution
Communicating in Code: Layout and Style
Chapter 4: Control Structures I (Selection)
2.1 Parts of a C++ Program.
An Introduction to Java – Part I, language basics
CMSC 202 Java Primer 2.
Conditional Execution
Testing and Repetition
Homework Any Questions?.
Beginning Style 27-Feb-19.
Topics Introduction to Functions Defining and Calling a Function
Winter 2019 CISC101 4/8/2019 CISC101 Reminders
Class code for pythonroom.com cchsp2cs
Presentation transcript:

Coding Standards A Presentation by Jordan Belone

What are They? Rules - Must Guidelines - Should Physical Document

Open Source GNU Firefox ng_Style

Prominent Works -Kernighan and Plauger (1974) -Fortran and PL/I - Contains important points

Prominent Works (2) -Rob Pike -More recent (Published in 1999) - Regarded as “a business essential” and has been proven to save money -C/C++/Java

Kernighan Quotations "Where there are two bugs, there is likely to be a third.“ “Don't patch bad code - rewrite it." "Don't stop with your first draft."

Why Have Coding Standards? Software Maintenance Less Bugs Teamwork Team switching Cost

TYPES OF CONDING STANDARDS BY COMPANY BY LANGUAGE

CODING STANDARDS EXAMPLES

Common Practice - Indentation Identifies scope in some programming languages for the compiler Indentation of – Functions – Objects – Etc Unnecessary in Freeform programming Gives an indication of scope in freeform languages but doesn’t affect program

Example Compare To if (g < 17 && h < 22 || i < 60) { return true; } else {System.out.println (“incorrect”) ; return false; } if (g < 17 && h < 22 || i < 60) { return true; } else { System.out.println(“incorrect”); return false; } - Easier to Read - Easier to Understand - Easier to maintain

Common Practice -Commenting Code ALL PROGRAMMING LANGUAGES Comments should - Clearly demonstrate the function of the code, both to yourself and to other developers - Not too long Comments should NOT be - Every line (Exceptions for functional languages) - Overcomplicated

Common Practice - Whitespace Very important but often overlooked Makes the code easier to read Especially important with large programs, lack of whitespace can be very confusing

Example for(int i=0;i<40;i++) {system.out.println(i);} for( int i = 0 ; i < 40 ; i++ ) { system.out.println(i); }

Common Practice – Naming Variables Variable names are often thought to be less important but they are vital to understanding certain pieces of code. In the majority of programming languages, variables can be assigned almost any name.

Example If(a < h && z <o && t<e) { return true; } else { return false; } This code could do anything!

Example quotations from different coding standards Use spaces not TABs. Three character indent (four is more common; get agreement and enforce with a tool). No long lines. Limit the line length to a maximum of 120 characters. No trailing whitespace on any line. Put brace on a new line. Single space around keywords, e.g. if (. Single space around binary operators, e.g No space around unary operators, e.g. ++i No space before parentheses with functions/macros, e.g. fred( 42, 69 ) Single space after parentheses with functions/macros, e.g. fred( 42, 69 ) Single space after comma with functions/macros, e.g. fred( 42, 69 ) Layout lists with one item per line; this makes it easier to see changes in version control. One declaration per line. Function calls with more than two arguments should have the arguments aligned vertically. Avoid big functions and methods. Ditto for large classes and large files. Avoid deep nesting. Always use braces with if statements, while loops, etc. This makes changes shorter and clearer in version control.

SUMMARY EASE OF INFORMATION EXTRACTION LOOKING FORWARD