Software Development (CS2500)



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

CSE 308. Coding Conventions. Reference

Install Java Development Kit (JDK) 1.8

Official Android Coding Style Conventions

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

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

Java Code Conventions. September 12, 1997

Moving from CS 61A Scheme to CS 61B Java

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

Code convention document Argus-viewer

Dinopolis Java Coding Convention

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Some Scanner Class Methods

Java Coding Style Guide

Example of a Java program

General Software Development Standards and Guidelines Version 3.5

Lecture 5: Java Fundamentals III

A Coding Style Guide for Java WorkShop and Java Studio Programming

Introduction to Python

Javadoc like technical documentation for CAPRI

Installing Java (Windows) and Writing your First Program

Software documentation systems

ECE 341 Coding Standard

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Taxi Service Coding Policy. Version 1.2

3rd Edition, June standards/ecma-334.htm.

Computer Programming C++ Classes and Objects 15 th Lecture

Fundamentals of Java Programming

AP Computer Science Java Subset

JavaScript: Control Statements I

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

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

PHP Tutorial From beginner to master

Chapter 2: Elements of Java

Introduction to Computer Programming (CS 1323) Project 9

13 Classes & Objects with Constructors/Destructors

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

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

NEW YORK CITY COLLEGE OF TECHNOLOGY/CUNY Computer Systems Technology Department

LAB4 Making Classes and Objects

Object-Oriented Programming in Java

National Database System (NDS-32) Macro Programming Standards For Microsoft Word Annex - 8

Computer Programming I

PRI-(BASIC2) Preliminary Reference Information Mod date 3. Jun. 2015

Java Programming Fundamentals

1001ICT Introduction To Programming Lecture Notes

Functional Programming

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

Exploring Algorithms with Python

Introduction to Object-Oriented Programming

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Chapter 3. Input and output. 3.1 The System class

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Syllabus for CS 134 Java Programming

Adobe Conversion Settings in Word. Section 508: Why comply?

Java Program Coding Standards Programming for Information Technology

INFSCI 0017 Fundamentals of Object- Oriented Programming

Introduction to Java Lecture Notes. Ryan Dougherty

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Data Integration through XML/XSLT. Presenter: Xin Gu

ECE 122. Engineering Problem Solving with Java

ICT. PHP coding. Universityy. in any

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

Semantic Analysis: Types and Type Checking

C++ Programming Language

Going Above and Beyond

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class

Coding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

Pemrograman Dasar. Basic Elements Of Java

Iteration CHAPTER 6. Topic Summary

Chapter 2 Introduction to Java programming

Lecture 2 Notes: Flow of Control

Java CPD (I) Frans Coenen Department of Computer Science

Informatica e Sistemi in Tempo Reale

Web Development Naming Conventions

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

Software Engineering Techniques

Introduction to Programming System Design. CSCI 455x (4 Units)

Basic Java Syntax. Program Structure

Programming in Java Course Technology, a part of Cengage Learning.

North American Barcode Label Specifications and Description

6.170 Tutorial 3 - Ruby Basics

Programming Fundamentals I CS 110, Central Washington University. November 2015

6. Control Structures

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

10th Grade Language. Goal ISAT% Objective Description (with content limits) Vocabulary Words

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

Object Oriented Software Design

Android Studio Application Development

Computer Programming Tutorial

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Java Crash Course Part I

Bauer College of Business Writing Style Guide

7.1 Our Current Model

Transcription:

(CS2500) Lecture 15: JavaDoc and November 6, 2009

Outline Today we study: The documentation mechanism. Some important Java coding conventions. From now on you should use and make your code comply to the coding conventions.

Generating Documentation with is a tool for creating html documentation. Documentation is generated from comments in java programs. are formatted in special style called doc comments. The documentation is generated by the program. Unix Session $ LuvelyClass.java

Doc Doc comments start with /** and end in */. Additional lines should start with *. The comments may contain html tags. Java /** * This is an <strong>example</strong>. */

Doc First line of each doc is automatically included in documentation. It should provide a concise description of what is documented. Doc comments are subdivided into descriptions and tags. Description: Provide overview of functionality of presented code. Tag: Tags specify address specific information. Includes information about author, version,.

Tags Tags are used to specify content and markup. Tags are case-sensitive and should start with @. Java /** * Basic print method. * * @author Java Joe. * @param bar the thing to be printed. */ public void printstuff( int bar ) {. }

Kinds of Tags Block tags are of the form @ tag name. They should be placed in tag section following main description. Inline tags are of the form {@ tag name more }. Java /** * Friendly class. * More information {@link #hello here}. */ public class Hello { public static void hello( ) { System.out.prinln( "hello world." ); } }

Some Existing Tags @author: Author Entry. @param: Parameter Entry. Java /** * Compute length of a given list. * * @param list The given list. * @param <T> The type of the elements in the list. * @return The length of the list. */ int length( List<T> list ) @version: Version Entry. @return: Return Entry.

Hyperlinks Java /** * {@link package. class # member text } */

Proper Order Java /** * @param * @return * @exception * @author * @version * @see * @since * @serial * @deprecated */

Why bother? 80% of the lifetime cost of software goes to maintenance. Others will have to read your code. Improves readability of your luvely code. Shipped code should be well packaged and clean.

Why bother? 80% of the lifetime cost of software goes to maintenance. Others will have to read your code. Improves readability of your luvely code. Shipped code should be well packaged and clean.

Why bother? 80% of the lifetime cost of software goes to maintenance. Others will have to read your code. Improves READABILITY of your L U V E LY code. Shipped code should be well packaged and clean.

Why bother? 80% of the lifetime cost of software goes to maintenance. Others will have to read your code. Improves readability of your luvely code. Shipped code should be well packaged and clean.

Most Importantly Follow the conventions of your company and the person whose code you re modifying.

should consist of sections which are separated by blank lines and comments. longer than 2000 lines should be avoided. Javadoc comments should be used to document the classes/interfaces, attributes, and methods. The import statements always go to the top of the file. If you need more than one import from a package, use the * notation: Java Coding Convention import java.util.*; Don t Try This at Home import java.util.treemap; import java.util.random;

Class and Interfaces: Structure.1 package statement..2 import statements..3 class-related comments..4 Class variables in increasing order of visibility: public, protected, and private..5 Instance variables in increasing order of visibility..6 Constructors..7. Implementation comments should be used where apropriate.

Java Coding Convention class Example { // Opening brace here.. } // Closing brace here.

Use four spaces as the unit for indentation. Use eight spaces if that improves readability. Avoid lines that are longer than 80 characters. Use the following rules for wrapping lines if they re too long: Break after a comma; Break before an operator; Prefer higher-level breaks to lower-level breaks; Align text with broken expression on previous line. Compound statements (blocks): The enclosed statements should be indented one more level. Opening brace: at end of line that begins block. Closing brace: indented at same level as line at start of block.

Breaking Method Calls Java Coding Convention call1( longexpr1, longexpr2, longexpr3, longexpr2, longexpr3 ); int var = call2( longexpr1, call3( longexpr2, longexpr3, longexpr2, longexpr3 ) ); Don t Try This at Home int var = call2( longexpr1, call3( longexpr2, longexpr3, longexpr2, longexpr3 ) ); int var = call2( longexpr1, call3( longexpr2, longexpr3, longexpr2, longexpr3 ) );

Breaking Arithmetic Expressions Java Coding Convention longvariable = longexpr1 + (longexpr2 - longexpr3) / longexpr5; Don t Try This at Home longvariable = longexpr1 + (longexpr2 - longexpr3) / longexpr4;

Further Examples Java Coding Convention if ((condition1 && condition2) (condition3 && condition4)) { // Stuff } Don t Try This at Home if ((condition1 && condition2) (condition3 && condition4)) { // Stuff }

Further Examples Java Coding Convention var1 = (condition)? thisstuff : thatstuff; var2 = (condition)? thisstuff : thatstuff; // Clearer! var3 = (condition)? thisstuff : thatstuff; // Also impossible to miss!

Don t Try This at Home public int answer( ) { /* Temporarily commented out for testing. /* * This gives you the answer. */ */ return 42; } Java public int answer( ) { /* Temporarily commented out for testing. // // This gives you the answer. // */

Don t Try This at Home public int answer( ) { /* Temporarily commented out for testing. /* * This gives you the answer. */ */ return 42; } Java public int answer( ) { /* Temporarily commented out for testing. // // This gives you the answer. // */

Prefer having one declaration per line. Java Coding Convention int one; // Comment about purpose of one. int two; // Comment about purpose of two. Don t Try This at Home int one, many[]; // Allowed, but don't do this. Variable declarations should be aimed at minimising scope [Bloch, 2008, Item 29].

One Statement Per Line There should be no more than one statement per line. Don t Try This at Home thisvar ++; thatvar --; Avoid the use of the comma operator. Don t Try This at Home thisvar ++, thatvar --;

The return Statement Avoid parentheses for return statements (unless this is clearer). Java Coding Convention return; // Allowed but not for this course.. return myluvelycomputation( );. return (condition? thisvalue : thatvalue);

The if Statement Always use braces for if statements. Java Coding Convention if (condition1) { } if (condition2) { } else { } if (condition3) { } else if (condition4) { }

The for Statement Use braces for for statements with non-empty body. Java Coding Convention for ( initialisation; condition; update ) { } For for statements with empty body add semicolon as follows. Java Coding Convention for ( initialisation; condition; update ) ; // empty body

The while Statement Use braces for while statements with non-empty body. Java Coding Convention while ( condition ) { } For while statements with empty body add semicolon as follows. Java Coding Convention while ( condition ) ; // empty body

The do-while Statement Java Coding Convention do { } while ( condition );

Adding white space generally improves readability. Add a blank line for the following: Between method definitions. Between local variable declarations and statements in a block. Before a block. Between logical sections inside a method to improve readability.

Blank Spaces Blank spaces should be used in the following circumstances: A keyword followed by a parenthesis: Java Coding Convention while (condition) { } A parenthesis followed by a brace: Java Coding Convention while (condition) { } After commas in argument lists. Before and after binary operators (except.): Java Coding Convention

Classes: Class names should be nouns in mixed case. First letter in each internal word should be upper case. Use whole words and avoid non-obvious acronyms. Interfaces: Ideally interfaces should be mixed case adjectives ending in able. : Method names should be verbs in mixed case. The first letter should be lower case. First letter of remaining words should be upper case. Constants: Class constants should be upper case with words separated with underscores. Variables: Variables should be short, yet meaningful nouns. The naming scheme is the same as for methods.

should be short. Break methods in sub-method calls when they become longer than, say, 40 lines.

Other Coding Practice To be announced.

Acknowledgements The section about is partially based on [Lewis and Loftus, 2009, Appendix I]. More information about may be found at http://java.sun.com/j2se//writingdoccomments. The section about coding conventions is based on [Sun, 1997]. Joshua Bloch. Effective Java. Addison-Wesley, 2008. John Lewis and William Loftus. Java Software Solutions Foundations of Program Design. Pearson International, 2009. Sun. Java code conventions, 1997. This document is freely available from http://java.sun.com/docs/codeconv.

Study the notes, study Pages 80 87 of the book, and carry out the exercises on Pages 92 and 93 of the Book.