QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData

Similar documents
Documentation Requirements Computer Science 2334 Spring 2016

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine

CSCI 1060U Programming Workshop

What does this program print?

CS 251 Intermediate Programming Coding Standards

Queues. CITS2200 Data Structures and Algorithms. Topic 5

Coding Guidelines. Introduction. General Points. Avoid redundant initialization/assignment

CS 351 Design of Large Programs Coding Standards

11 Coding Standards CERTIFICATION OBJECTIVES. Use Sun Java Coding Standards

Java Programming Style Guide

Log4Delphi Coding Standards

Coding Standards for Java

APPENDIX A : Example Standard <--Prev page Next page -->

Chapter 2 Author Notes

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

Data Abstraction and Specification of ADTs

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Introduction to C# Applications

CSCI 2101 Java Style Guide

IT Web and Software Developer Software Development Standards

2.8. Decision Making: Equality and Relational Operators

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

CS106A, Stanford Handout #30. Coding Style

Objectives. Coding Standards. Why coding standards? Elements of Java Style. Understand motivation for coding standards

User Interface Programming OOP/Java Primer. Step 3 - documentation

Documenting Java Code. Javadoc: The Tool and the Legend

Appendix G C/C++ Notes. C/C++ Coding Style Guidelines Ray Mitchell 475

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Software and Programming 1

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Full file at

Beginning Style. 16-Nov-15

Pace University. Fundamental Concepts of CS121 1

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Supplement D: Expanded Guidelines on Programming Style and Documentation

YOLOP Language Reference Manual

Programming Syntax and Style. David Greenstein Monta Vista High School

Introduction to Java Applications

Basic Syntax - First Program 1

CS 152 Computer Programming Fundamentals Coding Standards

Coding Standards for C

Programming Assignment Comma Separated Values Reader Page 1

Computer Science C++ Placement Exam

Coding Standards for C

Expanded Guidelines on Programming Style and Documentation

C Coding Style Guide Version 0.4

CSE 11 Style Guidelines

JAVA PROGRAMMING LAB. ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations

The Java Language Rules And Tools 3

Coding Standard for ECE3090 August 24, 2005

Assignment Marking Criteria

Key Differences Between Python and Java

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output.

COMP 202 Java in one week

Index COPYRIGHTED MATERIAL

Lecture 5 Tao Wang 1

Java Coding style guide 1. Java. Coding Style Guide. (July 2015)

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

C Language, Token, Keywords, Constant, variable

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Software and Programming 1

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Google Java Style. 1 Introduction. Last changed: March 21, Introduction 1.1 Terminology notes 1.2 Guide notes

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

RTL Reference 1. JVM. 2. Lexical Conventions

PHP-FIG Home Blog PSRs Personnel Bylaws FAQs Get Involved PSR-2: Coding Style Guide

Introduction to C# Applications Pearson Education, Inc. All rights reserved.

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

Typescript on LLVM Language Reference Manual

LECTURE 02 INTRODUCTION TO C++

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Documenting Advanced Programming Techniques

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

Introduction to C Programming

The Java Language The Java Language Reference (2 nd ed.) is the defining document for the Java language. Most beginning programming students expect

Creating a C++ Program

PROGRAMMING STYLE. Fundamentals of Computer Science I

Java Notes. 10th ICSE. Saravanan Ganesh

BTE2313. Chapter 2: Introduction to C++ Programming

C++ Programming Style Guide

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

Write for your audience

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Computer Programming : C++

INTRODUCTION 1 AND REVIEW

CSCI 262 C++ Style Guide

CS112 Lecture: Working with Numbers

CMSC 201 Fall 2018 Python Coding Standards

13.1 End Marks Using Periods Rule Use a period to end a declarative sentence a statement of fact or opinion.

SOFT 161. Class Meeting 1.6

COMP 110 Project 1 Programming Project Warm-Up Exercise

Functions. Lab 4. Introduction: A function : is a collection of statements that are grouped together to perform an operation.

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Transcription:

Naming Conventions Rules Classes Use nouns Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML) Begin with upper case letters Methods Use verbs Begin with lower case letters Instance Variables Constants Files Classes & Interfaces Use nouns, plurals for collection classes Begin with lower case letters Dos not start with underscore _ or dollar sign $ characters, even though both are allowed One-character variable names should be avoided except for common temporary variables All characters in upper case Words are separated by underscores ("_") File names should be the same as the (principal) class stored in the file No space between a method name and the parenthesis "(" starting its parameter list Open brace "{" appears at the end of the same line as the declaration statement Closing brace "" starts a line by itself indented to match its corresponding opening statement, except when it is a null statement the "" should appear immediately after the "{" The internal statements are indented by 2 spaces Example QueueBlock, ReversalADT, LinkedList,CustomerAccount, not MaintainCustomerData examine, delete, isempty, tostring items, firstaction, list Common temporary variables names Integers: i, j, k, m, and n Characters : c, d, and e private static final int MAX_SEQUENCE public class QueueBlock { protected Object [] items; public int iszero (){return 0; 1

Methods A method should either appear on a single line, as is shown for iszero in the example above, or surrounding its statements in the same way as a class Note that the opening brace ends the first line of the method's code, and the closing brace is on its own line flush with the left side of the first line (not, for example, at the end of the fifth line) This has two advantages: o separates the text of the method "declaration" from its internal statements, o allows the reader to determine where a method ends by looking down for a brace with the same level of indentation The internal statements are indented by 2 spaces public String tostring () { int i; String s=""; for (i=first; i<=last; i++) { s = s+items[i]tostring()+'\n'; return s; Iteration Statements An iteration statement should be formatted in the same way as a method If an iteration statement has only one clause but it is too long to appear on a single line, it should be indented on the following line for (i=first; i<=last; i++) { s = s+items[i]tostring()+'\n'; OR while (!CharacterisSpace(ccharValue())) { qinsert(c); c = new Character((char) Systeminread()); OR while (CharacterisSpace(ccharValue())) { c = new Character((char) Systeminread()); 2

Selection Statements Rules for iteration statement apply to the if part and the else part (or to the switch part and to each case) The example illustrates a case where one part appears on a single line and the other part is broken around a block of statements Braces and semicolons should always be included Write if statements in their simplest form (Warning: Checkstyle s error message for this is Conditional logic can be removed ) Indentation All code and documentation should not be longer than 80 characters per line o Some editors will wrap lines of text without inserting carriage-return characters o When the code is then viewed on a non-wrapping editor, paragraphs will appear as a single line o Also text entered in a wider window will format differently on an 80 character window When an expression will not fit on a single line, break it according to these general principles: o Break after a comma o Break before an operator o Prefer higher-level breaks to lower-level breaks o Align the new line with the beginning of the expression at the same level on the previous line o If the above rules lead to confusing code or to code that's squished up against the right margin, just indent 8 spaces instead Spacing Two blank lines should always be used in the following circumstances: o Between sections of a source file o Between class and interface definitions 3 if (!isfull()) { last++; items[last] = a; else throw new ExceptionFull("enqueuing to full queue"); if (!isempty()) { list = listsucc; Not: if (foo) { return true; else { return false; Instead: return (foo);

Spacing One blank line should always be used in the following circumstances: o Between methods o Between the local variables in a method and its first statement o Before a block or single-line comment o Between logical sections inside a method to improve readability Classes o All classes and their fields (both class and instance variables) and methods should be preceded by javadoc comments /** * A basic recursive (linked) list * @author your name (and any * authors of included or modified * code) * @version the date Documentation Methods Instance Variables Documentation for methods should include: A sentence description of the method s purpose, terminated with a full stop a @return statement whenever the return type is not void a @param statement for each parameter passed to the method an @exception statement for any exception thrown Documentation for instance variable should include the use of the instance variable /** * examine the first item in the list * @return the first item in the list protected Object examine (){ if (!isempty()) return listitem; /** contains the user password private String password; Block Used to provide descriptions of files, methods, data structures and algorithms / * * Here is a block comment 4

Documentation Single-line Trailing comments End-of-line May be used at the beginning of each file, before each method and other places, such as within methods Block comments inside a function or method should be indented to the same level as the code they describe Short comments can appear on a single line indented to the level of the code that follows If a comment can't be written in a single line, it should follow the block comment format A single-line comment should be preceded by a blank line Very short comments can appear on the same line as the code they describe Should be shifted far enough to separate them from the statements If more than one short comment appears in a chunk of code, they should all be indented to the same tab setting The // comment delimiter can comment out a complete line or only a partial line Do not use on consecutive multiple lines for text comments Can be used in consecutive multiple lines for commenting out sections of code public void method1(){ if (condition) { /* short comment here if (b!= 0) { return 0; /* trailing comment 1 else { return 10; /* trailing comment 2 While (b <0) do{ //comment 1 b++ //comment 2 o Indicates that the rule is checked by Checkstyle but needs to be corrected manually Indicates that the rule is checked by Checkstyle and can be automatically corrected using Eclipse Formatter Material taken and modified from: Code Conventions for the Java Programming Language (http://javasuncom/docs/codeconv/) CITS1220 and CITS2200 Java Programming Conventions 5