Java Program Coding Standards Programming for Information Technology

Similar documents
Identifiers and Variables

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CS 251 Intermediate Programming Coding Standards

CS 152 Computer Programming Fundamentals Coding Standards

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

CMSC 202. Exceptions

Notes on Chapter Three

Datatypes, Variables, and Operations

Java Identifiers, Data Types & Variables

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

Pace University. Fundamental Concepts of CS121 1

Algorithms and Programming I. Lecture#12 Spring 2015

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

CSCI 2101 Java Style Guide

This exam is open book. Each question is worth 3 points.

PROGRAMMING STYLE. Fundamentals of Computer Science I

Object Declaration. <class name>: the name of the class to which the object belongs <object name>: the name of the object (any valid identifier)

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

McGill University School of Computer Science COMP-202A Introduction to Computing 1

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

C++ Programming Style Guide

Reviewing all Topics this term

For the purposes of this course, the following coding guidelines are in effect.

CS 211 Programming Practicum Fall 2018

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

About this exam review

! Two questions when we design an OO system : ! Our Initial goal: learn to design and implement simple objects.

Topics. Chapter 5. Equality Operators

CSE 11 Style Guidelines

public class Foo { private int var; public int Method1() { // var accessible anywhere here } public int MethodN() {

Sun שיטת הגמל: "isodd" "is_odd" Sun. תוכנה 1 בשפת Java אוניברסיטת תל אביב

CSE 142/143 Unofficial Style Guide

Java Programming Style Guide

Introduction to Programming Using Java (98-388)

CS 351 Design of Large Programs Coding Standards

Welcome to Python 3. Some history

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

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

Loops. CSE 114, Computer Science 1 Stony Brook University

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

Fundamental of Programming (C)

Functions. x y z. f (x, y, z) Take in input arguments (zero or more) Perform some computation - May have side-effects (such as drawing)

Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Chapter 4 Defining Classes I

Fundamentals of Programming Session 13

A Foundation for Programming

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

Assignment Marking Criteria

Key Differences Between Python and Java

Lec 3. Compilers, Debugging, Hello World, and Variables

Advanced Computer Programming

Lecture 02, Fall 2018 Friday September 7

CS 61B Data Structures and Programming Methodology. June David Sun

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Looping. Arizona State University 1

Basics of Java Programming

Array. Prepared By - Rifat Shahriyar

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11

EC 413 Computer Organization

CS121/IS223. Object Reference Variables. Dr Olly Gotel

COS 126 General Computer Science Fall Programming Exam 2

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

FORM 2 (Please put your name and form # on the scantron!!!!)

Lecture 6. Instructor: Craig Duckett

Tips from the experts: How to waste a lot of time on this assignment

Exceptions and Design

CE221 Programming in C++ Part 1 Introduction

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

Loops. Repeat after me

EE 422C HW 6 Multithreaded Programming

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

G52PGP. Lecture oo3 Java (A real object oriented language)

Conditionals, Loops, and Style

C02: Overview of Software Development and Java

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

CSCI 262 C++ Style Guide

Week 6 CS 302. Jim Williams, PhD

BLM2031 Structured Programming. Zeyneb KURT

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 5A Introduction to Programming I (C) Homework 4

Final Exam. COMP Summer I June 26, points

Announcements. 1. Forms to return today after class:

class objects instances Fields Constructors Methods static

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Documentation Requirements Computer Science 2334 Spring 2016

Final Project. This assignment demonstrates your understanding of the concepts from the CMIS 141 class.

Lecture 7 Tao Wang 1

11 Coding Standards CERTIFICATION OBJECTIVES. Use Sun Java Coding Standards

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Software and Programming 1

CS 142 Style Guide Grading and Details

Repetition Structures

COMP-202: Foundations of Programming. Lecture 5: Arrays, Reference Type, and Methods Sandeep Manjanna, Summer 2015

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

All about flow control

Lab5. Wooseok Kim

Transcription:

Java Program Coding Standards 4002-217-9 Programming for Information Technology Coding Standards: You are expected to follow the standards listed in this document when producing code for this class. Whether you agree with the use of standards or not, most companies are starting to apply them, so you might as well get used to dealing with them. Naming Conventions: 1. Names used for classes, methods and variables are expected to be meaningful. 2. Do not use names that differ only in case. (Example: SQLStatement vs. SqlStatement) 3. We are following the Sun naming conventions used in their Java development: Class names are always capitalized. (Example: public class Ticket ) Method names always are lowercase for the first word, but all other words are capitalized. (Example: mortgageescrowcalculation() would be a valid method name.) Underscores are not used to separate words in a name. (Exception: constant_names) Only the first character of an embedded acronym is capitalized. (Example: selectsqlstatement) Exception: when the acronym is the first word in a name, it s all lowercase. (Example: xmldata) Constant names should be all uppercase. Constant names are the only place in Java where underscores are used as part of the name. (Example: static final float MINIMUM_RADIUS = 6.7f;) 1

Names for exceptions should have each word capitalized. The exception name must end with the word Exception. (Example: InvalidDataException) Comments: 1. You are expected to comment your code. Some percentage of each project s grade will be based on the documentation provided. 2. Each file should have a header associated with it. This header will contain the following information: (1) Author and course section, (2) Purpose of the file, (3) Caveats: any restrictions on the classes use or known errors. The name of the author and the course section should appear as the first item in the header. (Exception: It is not necessary to put a class header with an inner class. However, there should be a comment about the purpose of the inner class, unless it s blindingly obvious.) 3. Each class should have a header associated with it. This header should describe the purpose of the class. The header should appear ahead of the class definition. 4. If command line arguments are used, this information should appear in a comment that appears ahead of the main method in the class. 5. Sections of code where you are doing something clever, unusual, or where you are making use of some obscure feature need to be commented. 6. Don t comment the obvious. (Example: j++; // increment j ) Miscellaneous: 1. Use indentation to indicate the scope of methods and various control structure, like loops, and if statements. 2. I expect that any work submitted for grading has been tested fully. You will lose a significant number of points if your program fails to compile or fails with a stack trace during a run. 3. You are expected to use the SDK1.6 and an editor as your development environment. 2

4. Labs are required to be individual projects. Group efforts are absolutely forbidden. 5. The book The Elements of Java Style by Allan Vermeulen, et al. Cambridge Press 2000, has a very good discussion of coding and documentation standards. It s only 128 pages long and gives different rules along with examples. 3

Coding Example: This program shows the way code should be written for this course: // Author: A.T. Hun 4002-217-01 // Date: June 24, 2008 // Description: This program accepts one number as a command line argument and prints // the Fibinocci sequence that contains the requested number of elements. // // Caveats: Invalid values will be ignored. (i.e. negative numbers or text strings.) // The program will not accept a value greater then 45. // If more than 1 argument is entered, all arguments after the first are ignored // This class generates a Fibinocci sequence with the requested number of terms class FibSequence { private int maxiterations; // Constructor public FibSequence(String arg){ // convert the value from a String to a number if possible int iterations = 0; try { Integer argvalue = new Integer(arg); iterations = argvalue.intvalue(); catch(numberformatexception nfe) { // not a number - exit System.exit(2); Header comments expected for each class // see if the number is <= 45 and > 0 - exit otherwise if(iterations > 45 iterations <= 0) { System.exit(3); maxiterations = iterations; // This method is called recursively to calculate // and print out the Fibonacci sequence public void calc(int firstvalue, int secondvalue, int counter) { if(counter > maxiterations) return; // end of recursion // calculate and print the next term in sequence int nextterm = firstvalue + secondvalue; System.out.println(nextTerm); Method comments expected for each method in the class // call fibo to get next term counter++; calc(secondvalue, nextterm, counter); 4

// This class tests the Sequence class by accepting a command line argument of the // number of terms from the sequence and then calls the calc method of the Sequence class to // generate the required list of terms. public class SequenceTest { // Command line usage: java SequenceTest numberofelements // Example: java SequenceTest 12 public static void main(string[] args) { // test for at least 1 argument entered if(args.length <= 0) { // no arguments entered - exit System.exit(1); // create the sequence object and initialize FibSequence seq = new FibSequence(args[0]); // call the recursive routine to calculate the values and // print them out System.out.println("1\n1"); // print first two terms int count = 3; // first two terms are fixed seq.calc(1,1,count); 5