CSE 308. Coding Conventions. Reference



Similar documents
Software Development (CS2500)

Taxi Service Coding Policy. Version 1.2

CS 241 Data Organization Coding Standards

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

Project 4 DB A Simple database program

Official Android Coding Style Conventions

Install Java Development Kit (JDK) 1.8

Java CPD (I) Frans Coenen Department of Computer Science

C Coding Style Guide. Technotes, HowTo Series. 1 About the C# Coding Style Guide. 2 File Organization. Version 0.3. Contents

Moving from CS 61A Scheme to CS 61B Java

Java Code Conventions. September 12, 1997

Some Scanner Class Methods

Dinopolis Java Coding Convention

Fundamentals of Java Programming

ICT. PHP coding. Universityy. in any

Code convention document Argus-viewer

Software documentation systems

AP Computer Science Java Subset

13 File Output and Input

Lecture 5: Java Fundamentals III

egovernment Authority [Sharmila Naveen] [07/04/2010]

Java Program Coding Standards Programming for Information Technology

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Building a Multi-Threaded Web Server

Module developer s tutorial

LAB4 Making Classes and Objects

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Syllabus for CS 134 Java Programming

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

CS 111 Classes I 1. Software Organization View to this point:

Java Coding Style Guide

Java Application Developer Certificate Program Competencies

ECE 122. Engineering Problem Solving with Java

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

ECE 341 Coding Standard

CS170 Lab 11 Abstract Data Types & Objects

10CS73:Web Programming

Introduction to Object-Oriented Programming

Using Files as Input/Output in Java 5.0 Applications

SPSS for Windows importing and exporting data

A Coding Style Guide for Java WorkShop and Java Studio Programming

Chapter 14: Links. Types of Links. 1 Chapter 14: Links

IRA EXAMPLES. This topic has two examples showing the calculation of the future value an IRA (Individual Retirement Account).

PA2: Word Cloud (100 Points)

Creating a Simple Macro

Overview of Web Services API

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Object-Oriented Programming in Java

Software Engineering Techniques

Using ilove SharePoint Web Services Workflow Action

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

Auto-Generating Documentation & Source Code

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Java Classes. GEEN163 Introduction to Computer Programming

RMI Client Application Programming Interface

Installing Java (Windows) and Writing your First Program

App Building Guidelines

Taking Advantage of Digi s Advanced Web Server s Repeat Group Feature

Specialized Programme on Web Application Development using Open Source Tools

Unit Testing & JUnit

1 Using CWEB with Microsoft Visual C++ CWEB INTRODUCTION 1

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

The Rules 1. One level of indentation per method 2. Don t use the ELSE keyword 3. Wrap all primitives and Strings

JavaScript: Control Statements I

Effective feedback from quality tools during development

Access Queries (Office 2003)

Data Domain Profiling and Data Masking for Hadoop

Statically Checking API Protocol Conformance with Mined Multi-Object Specifications Companion Report

Basic Java Syntax. Program Structure

Listeners. Formats. Free Form. Formatted

Oracle Database: SQL and PL/SQL Fundamentals

Import Filter Editor User s Guide

2 Getting Started with jgrasp 2.0

10 Java API, Exceptions, and Collections

Map Reduce Workflows

Introduction to Java Lecture Notes. Ryan Dougherty

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

To Java SE 8, and Beyond (Plan B)

J a v a Quiz (Unit 3, Test 0 Practice)

AP Computer Science A 2011 Free-Response Questions

Introduction to Java. CS 3: Computer Programming in Java

Web Development in Java

A QUICK OVERVIEW OF THE OMNeT++ IDE

II. PREVIOUS RELATED WORK

Conditionals (with solutions)

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

What's New in ADP Reporting?

The following program is aiming to extract from a simple text file an analysis of the content such as:

Introduction to Computer Programming (CS 1323) Project 9

Securing Adobe connect Server and CQ Server

Transcription:

CSE 308 Coding Conventions Reference Java Coding Conventions googlestyleguide.googlecode.com/svn/trunk/javaguide.html Java Naming Conventions www.ibm.com/developerworks/library/ws-tipnamingconv.html 2 1

Why Do We Need Coding Conventions? Reduce software maintenance Improve readability of the SW Easier code walkthroughs and design reviews 3 Comments Comments will be Implementation - /* */ Javadoc - /** */ Implementation comments are for commenting out code or describing particular implementation issues Comments should provide only info that is not available in the code (don t document trivial issues) Don t use special characters, boxes, etc. Block comments should be indented to the same level as the code Trailing comments (same line) should be shifted away from code Source files for classes should start with a comment that includes class name, version (i.e., build), date, and copyright notice 4 2

Indentation Appearance 2 spaces is recommended (4 is OK) Use the formatting feature of your IDE (tailor your settings) Helpful to use the IDE format feature regularly as you are coding it helps you see errors 5 Rules: Line Wraps Break after a, X = a Break before an operator +b; Line wrapping indent at least 4 spaces 6 3

Class Statement Organization Static variables in the order of: public protected private Instance variables (same order as static variables) Constructors Methods group by functionality (make reading code easier) 7 Declarations Declarations at the beginning of a block One declaration per line You can either use a space or a tab between the type and the identifier int level //authorization level int level //authorization level No space between a method name and the ( { at the end of the line { when there is a null Helpful if identifier names line up on multiple lines 8 4

Declarations Some logical ordering No C++ array declarations String[] args, not String args[] 9 Annotations Annotations applying to a class, method or constructor appear immediately after the documentation block Each annotation is listed on a line of its own (that is, one annotation per line) These line breaks do not constitute line-wrapping @Override @Nullable public String getnameifpresent() {... 10 5

Statements One statement per line Return should not use () return myobject; 11 If Examples if (condition) { Always use { in your if if (condition) { else { 12 6

Examples Iteration while (condition) { do { while (condition); Always use { in your iteration for (initialization, condition, update) { 13 Blank Lines Between methods Between local variables in a method and the first statement Between logical sections Beware of using too many blank lines remember your module should be readable on a screen 14 7

Naming Conventions Packages lower case (not CC) Classes should be nouns in upper camel case First letter of each internal word is capitalized Use whole words avoid acronyms and abbreviations Methods should be verbs in lower camel case Variables lower camel case Don t use _ or $ Constants all uppercase 15 Ambler Name Suggestions Use full descriptors (e.g., firstname) Use domain terminology Use abbreviations sparingly Avoid long names (e.g., 15 character max) Avoid names that are too similar Don t use CS terminology or type (e.g.,...list) in the name 16 8

Worthless Documentation /** * Represents a command history */ public class CommandHistory { /** * Get the command history for a given user */ public static CommandHistory getcommandhistory(string user) { 17 Javadoc Theme: Include your code documentation in the code and then extract it to an html file Principles Javadoc comments are a special form of java comments Classes, methods, and fields are documented immediately above the feature it documents Comments include tags (starting with a @), such as @author and @param Comments can include html tags, such as <code>, <em>, and <br> Javadoc output (html) is generated by your IDE or by a command Javadoc will not be evaluated during code reviews 18 9

Block Tags Include block tags in the following order: @param (classes, interfaces, methods and constructors only) @return (methods only) @exception (@throws is a synonym added in Javadoc 1.2) @author (classes and interfaces only, required) @version (classes and interfaces only, required. @see @since @serial (or @serialfield or @serialdata) 19 Structure One class per file 20 10