Coding practices For IT and Computing students 2014.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
The Web Warrior Guide to Web Design Technologies
Coding Standards for Java An Introduction. Why Coding Standards are Important? Coding Standards lead to greater consistency within your code and the code.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Chapter 2: Introduction to C++.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 9: Creating Database Conventions & Standards MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design Study Guide (70-443)
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
The Ruby Programming Language
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
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.
CPS120: Introduction to Computer Science
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
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.
M-1 University of Washington Computer Programming I Program Style © 2000 UW CSE.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Best Practices for Variables
Code Conventions Tonga Institute of Higher Education.
Feb. 8, 2008 UHCO Graduate Course in MATLAB Core Programming Module Best Practices Core Grant Programming Module Best Practices (Coding Conventions) General.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Documentation and Style. Documentation and Comments  Programs should be self-documenting.  Use meaningful variable names.  Use indentation and white.
Programming with Microsoft Visual Basic th Edition
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 3: Using Variables.
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.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
HTML Introduction. Lecture 7 What we will cover…  Understanding the first html code…  Tags o two-sided tags o one-sided tags  Block level elements.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
INT213 – WEEK 1 ASP tags and comments Variables, Constants, and "Literals" Simple Output.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Web Database Programming Using PHP
Unit 2 Technology Systems
Retrieving Data Using the SQL SELECT Statement
Prepared By: Bobby Wan Microsoft Access Prepared By: Bobby Wan
Basic select statement
Web Database Programming Using PHP
ICS103 Programming in C Lecture 3: Introduction to C (2)
The Selection Structure
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.
Chapter 10 Programming Fundamentals with JavaScript
Coding Design, Style, Documentation and Optimization
Data Types, Identifiers, and Expressions
Introduction to Python
Winter 2018 CISC101 11/27/2018 CISC101 Reminders
Chapter 1: Computer Systems
PHP.
Testing and Repetition
CISC124 Labs start this week in JEFF 155.
Documentation and Style
Anatomy of a Java Program
Chapter 2: Introduction to C++.
Tonga Institute of Higher Education
Variables in C Topics Naming Variables Declaring Variables
Creating Maintainable code
Variables in C Topics Naming Variables Declaring Variables
Controlling Program Flow
Creating readable code
Presentation transcript:

Coding practices For IT and Computing students 2014

Introduction Superior coding techniques and programming practices are hallmarks of a professional programmer These slides cover: fundamental coding techniques to improve the readability and maintainability of code coding practices to enhance performance Assignments award marks for good programming Information adapted from Rob Caron Microsoft Corporation February 2000

Techniques: Naming A name should tell “what” instead of “how” GetNextStudent() instead of GetNextArrayElement() Use the verb-noun method for naming routines or functions that perform some operation on a given object, such as  CalculateInvoiceTotal()

Techniques: Naming Use Pascal naming for functions – start with a capital letter CalculateInvoiceTotal() Use Camel Case for variables – start with lower case documentFormatType Use upper case with underscores for constants NUM_DAYS_IN_WEEK

Techniques: Naming Hungarian and Leszynski/Reddick Prefixes or tags are used at the front of the variable to indicate type strUserName intOrderQuantity tblUsers qryGetOrders Mainly used by Microsoft but discouraged in their latest design guide

Techniques: Naming When naming tables, express the name in the singular form. Spaces are not allowed. Employee instead of Employees Avoid single-letter variable names, such as i, or j, other than for x,y,z coordinates Boolean variable names should contain Is which implies True/False values fileIsFound

Techniques: Naming Do not use literal numbers or literal strings, such as For dayCount = 1 To 7  Instead, use named constants, For dayCount = 1 To NUM_DAYS_IN_WEEK

Techniques: Comments Comment as you code Code which is obvious today probably won't be obvious six weeks from now (or even tomorrow) Comment anything that is not readily obvious in the code Comment code that consists of loops and logic branches Don’t put comments at the end of a line of code unless annotating variable declarations or ending a loop.

Techniques: Comments At the beginning of every module or file provide Name and version of the module. Purpose of the Module. Description of the Module (In brief). Original Author /* File: connection.php V1.1 By: Bob Date: 2012-03-04 This script connects to a database */

Techniques: Format Establish a standard size for an indent, such as 4 spaces Align sections of code using indentation If … Then … Else End If

Techniques: Format Align open and close braces vertically for (count = 0; count < 100; count++) { … } Or put open braces at the end of the line and close braces at the beginning of the line for (count = 0; count < 100; count++){

Techniques: Format When writing SQL statements, use all uppercase for keywords and mixed case for database elements, such as tables, columns, and views Put each major SQL clause on a separate line SELECT FirstName, LastName FROM Customers WHERE County = 'Hereford'

Practice: General Select data types to ensure the size of a variable is not excessively large Keep the scope of variables as small as possible Use variables and routines for one and only one purpose. Develop and use error-handling routines Treat compilation warnings as errors Use Select Case or Switch statements instead of repetitive checking of a common variable using If…Then statements

Practice: Data specific Never use SELECT *. Always be explicit in which columns to retrieve and retrieve only the columns that are required Verify the row count when performing DELETE operations Perform data validation at the client during data entry Avoid using functions in WHERE clauses