Tonga Institute of Higher Education

Slides:



Advertisements
Similar presentations
Commenting and Naming Conventions
Advertisements

Unit 6 Assignment 2 Chris Boardley.
Coding Standards for Java An Introduction. Why Coding Standards are Important? Coding Standards lead to greater consistency within your code and the code.
Documentation 1 Comprehending the present – Investing in the future.
1 ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions.
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.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
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.
The Fundamentals of C++ Basic programming elements and concepts JPC and JWD © 2002 McGraw-Hill, Inc.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Agile Lab 2008a Armin B. Cremers, Günter Kniesel, Pascal Bihler, Tobias Rho, Marc Schmatz, Daniel Speicher Sommersemester 2008 R O O T S Coding standards.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
Good Programming Practices. 2 home back first prev next last What Will I Learn? List examples of good programming practices Accurately insert comments.
CSE 219 Computer Science III Testing. Testing vs. Debugging Testing: Create and use scenarios which reveal incorrect behaviors –Design of test cases:
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Computer Science 101 Introduction to Programming.
Chapter 2: Using Data.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Java Coding Standards and Best Practices Coding Standards Introduction: After completing this chapter, you will able to keep your code up to standards.
Working With Objects Tonga Institute of Higher Education.
AP Computer Science Programming Conventions. Why coding conventions? 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any.
Introduction to Web Programming. Introduction to PHP What is PHP? What is a PHP File? What is MySQL? Why PHP? Where to Start?
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
MavHome Software Development Guidelines G. Michael Youngblood Chief Scientist, MavHome The University of Texas at Arlington June 8, 2003.
Code Conventions Tonga Institute of Higher Education.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Writing Maintainable code Dr. Susan McKeever DT228/3 GUI Programming.
Coding Conventions  Coding conventions are a set of guidelines for a specific software project that recommend programming style, practices and methods.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Programming with Microsoft Visual Basic th Edition
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Dani Vainstein1 VBScript Session 8. Dani Vainstein2 What we learn last session? VBScript procedures. Sub procedures. Function Procedures. Getting data.
Working with Java.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
ICS103 Programming in C Lecture 4: Data Types, Operators & Expressions
Chapter 2: Input, Processing, and Output
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Introduction Java Chapter 3.
Coding Design, Style, Documentation and Optimization
PROGRAMMING METHODOLOGY
Software Testing and Maintenance Modifying Code
Variables in C Topics Naming Variables Declaring Variables
Tonga Institute of Higher Education
Unit-1 Introduction to Java
Variables in C Topics Naming Variables Declaring Variables
Unit 6 Assignment 2 Chris Boardley.
UMBC CMSC 104 – Section 01, Fall 2016
Tonga Institute of Higher Education
Beginning Style 27-Feb-19.
Tonga Institute of Higher Education
Topics Introduction to Functions Defining and Calling a Function
Methods.
Tutorial 10: Programming with javascript
Coding practices For IT and Computing students 2014.
Chapter 2: Input, Processing, and Output
Chap 2. Identifiers, Keywords, and Types
Variables in C Topics Naming Variables Declaring Variables
CSCE-221 C++ Coding Standard/Guidelines
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
The Fundamentals of C++
CS313T Advanced Programming language
Variables in C Topics Naming Variables Declaring Variables
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Tonga Institute of Higher Education Code Conventions Tonga Institute of Higher Education

What are Code Conventions? Code Conventions are guidelines on how to write code. They are rules for File Organization Code Width Indentation Declarations Naming Conventions Etc.

Why Have Code Conventions Code conventions are important to programmers for a number of reasons: Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly. 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software is maintained for its whole life by the original author. If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create. For code conventions to work, every person writing software must conform to the code conventions. Everyone.

What this means to you All homework must follow code conventions. Points will be deducted if you do not follow code conventions. I will not look at any code that does not follow code conventions.

File Organization Source Code should be written in the following order: Comment flowerbox. Options Statements Option Explicit, Option Strict, etc. Import statements Imports System.Text Class Statements Variables Methods

Code Width Avoid lines longer than 80 characters, since they're not handled well by many terminals and tools. When an expression will not fit on a single line, break it according to these general principles: Break after a comma. Break before an operator. Use the line-continuation sequence, which is a space followed by an underscore ( _), at the point at which you want the line to break.

Break after a comma myObject.myMethod(AReallyLongVariableName, _ Subsequent lines use 1 tab

Break before an operator Dim myString as String myString = “Hello, there! Welcome to Sony’s Online” _ & “Video Center” Break before An operator Subsequent lines use 1 tab Operator is first part of line

Indentation Indent all code contained within a statement Sub… End Sub Function… End Function If… End If

Indent all code within brackets This will help you debug your code Easy to see what is done in a class Easy to see what is done in a method Easy to see what is done in the body of the If statement

Declarations Initialize variables where they are declared. The only reason not to initialize a variable where it's declared is if the initial value depends on some computation occurring first.

Naming Conventions Do not use spaces in your names FindLastRecord RedrawMyForm Keep your names simple and descriptive Customer CheckInventory Each separate word in a name begins with a capital letter: Method names begin with a verb InitNameArray CloseDialog Class and Property names begin with a noun EmployeeName CarAccessory

Naming Conventions - 2 Constants All uppercase Words separated by underscores ("_"). Example MIN_WIDTH MAX_WIDTH GET_THE_CPU

Different Conventions for Different Companies Millions of people use code conventions Different companies have different standards The most important thing is to be consistent Find Microsoft’s recommendations here: Msdn.microsoft.com