Software Documentation Section 5.5 ALBING’s Section 6.1.4 JIA’s Appendix B JIA’s.

Slides:



Advertisements
Similar presentations
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Advertisements

1 Java coding conventions Lecture 2. 2 Please read Not only on assignment 1, but always. 80% of the lifetime.
CS102--Object Oriented Programming
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
MIT-AITI Lecture 14: Exceptions Handling Errors with Exceptions Kenya 2005.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
Utilities (Part 3) Implementing static features 1.
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
JavaDoc COMP 302. JavaDoc javadoc: The program to generate java code documentation. Input: Java source files (.java)  Individual source files  Root.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES API documentation.
1 Documenting with Javadoc CS 3331 Fall 2009 How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
Computer Science 340 Software Design & Testing Design By Contract.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Writing JavaDocs Mimi Opkins CECS 274 Copyright (c) Pearson All rights reserved.
Program documentation using the Javadoc tool 1 Program documentation Using the Javadoc tool.
1 Documenting with Javadoc. 2 Motivation  Why document programs? To make it easy to understand, e.g., for reuse and maintenance  What to document? Interface:
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Javadoc: Advanced Features & Limitations Presented By: Wes Toland.
Exception Handling Unit-6. Introduction An exception is a problem that arises during the execution of a program. An exception can occur for many different.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
Everything Is an Object Manipulate objects with references The identifier you manipulate is actually a “reference” to an object. Like a television.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Documentation javadoc. Documentation not a programmer's first love lives in a separate file somewhere usually a deliverable on the schedule often not.
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Javadoc Dwight Deugo Nesa Matic
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
© 2004 Pearson Addison-Wesley. All rights reserved April 24, 2006 Exceptions (part 2) ComS 207: Programming I (in Java) Iowa State University, SPRING 2006.
Javadoc. Purpose of javadoc javadoc is a program that reads your Java program and produces great-looking documentation in HTML format Without any help,
CMSC 341 Java Packages, Classes, Variables, Expressions, Flow Control, and Exceptions.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Javadoc Summary. Javadoc comments Delemented by /** and */ Used to document – Classes – Methods – Fields Must be placed immediately above the feature.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
Java Doc Guideline R.SANTHANA GOPALAN. Java Doc Guideline Audience Internal Developers PQA - who write test plans PPT – who write the documentation Customers.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
1 Documenting with Javadoc CS 3331 Section and Appendix B of [Jia03] How to Write Doc Comments for the Javadoc TM Tool available from
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
Lecture 7 February 24, Javadoc version and author Tags These go in the comments before named classes. –Put your SS# on a separate line from the.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Winter 2006CISC121 - Prof. McLeod1 Stuff We had better discuss a midterm date… –27 Feb. to 3 March or –6 to 10 March.
1 Documenting with Javadoc How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
Throw, Throws & Try-Catch Statements Explanations and Pictures from: Reference:
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Variable Scope & Lifetime
Advanced Programing practices
Software Development Handing Errors and Creating Documentation
Introduction to javadoc
Exception Handling Chapter 9.
Java Programming Language
CSE 143 Java Exceptions 1/18/2019.
JavaDoc and Contracts Fall 2008.
Advanced Programing practices
Introduction to javadoc
Computer Science 340 Software Design & Testing
Presentation transcript:

Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s

Source Code Documentation HTML Basics: Ubiquitous problems Writing API documentation for a system is one of the most unpleasant jobs a developer will ever face Application programming interface The kind of job that could drive you to despair No documentation  no code “Informal” documentation isn’t standard As software evolves, “informal” documentation and code become out of sync! Eventually, documentation becomes unusable making code hard to understand and update!

JavaDoc javadoc utility makes writing and maintaining code documentation up-to-date easier! Ships with JDK Defines a set of specially formatted comments Can be added to document each package, class (& interfaces), method, and field Used to generate HTML documentation of classes or packages after parsing the comments HTML documentation of the API

JavaDoc comments IMMEDIATELY precede the feature it describes Consist of Description of the feature Copied as is to the documentation page List of tags Formatted by javadoc in a consistent style Used in classes, interfaces, methods and variables Have the following format: /** * Summary sentence. * More general information about the * program, class, method or variable which * follows the comment, using as many lines * as necessary. * * zero or more tags to specify more specific kinds * of information, such as parameters and return * values for a method */

JavaDoc comments Must be provided for every public class or interface Must be provided for each public method or constructor

JavaDoc name Name one of the authors of this class Use multiple tags if there are multiple authors Used in: Class, Interface, Method Jane Smith, lab release Indicate the version of the software containing this class Used in: Class, Interface

JavaDoc target Point the reader at something else relevant to read, like another class or a specific method Inserts a link pointing to the target Used in: text Marks the entity as deprecated and points the reader to what they should use instead via tag Used in: All

@see tag Points to another package, class, method, field or even URL javadoc creates a link The syntax for the text depends upon what you're pointing package  Link to classname  Link to classname in the current package.classname  Link to classname in another #method  Link to method in the current #method(type)  Link to method with classname#method  Link to method in another class Method in a class in a different text  Link to URL

Examples //same class #field #method(Type, Type,...) //same package @see Class#method(Type,...) //different package package.Class#Constructor( package.Class#method(Type, Type,...) Java Spec

JavaDoc short description of parameter Describe the named parameter to this method Skip this tag if the method has no parameters Used in: Method size number of elements in the text Describe the value returned by this method Skip this tag if the method has no return value Appears tag(s) Used in: Method

Example /** * Validates a chess move. * John Doofus theFromLoc Location of piece being moved theRank Rank of piece being moved theToLoc Location of destination square true if a valid chess move or false if invalid */ boolean isValidMove(int theFromLoc, int theRank, int theToLoc) {... }

JavaDoc description of circumstances under which exception is thrown Describes the named uncaught “checked” or explicitly thrown “checked”/”unchecked” exception Skip this tag if the method throws no exceptions Should tags If method throws more than one exception they should appear in alphabetical order by exception name Used in FileNotFoundException raised if the user does not specify a valid file name

Checked vs. Unchecked You only advertise (via throws on method header) (or catch) and for (P.S. throws on method header  exception is not handled in the method but forwarded to the invoker) checked exceptions explicitly thrown unchecked ones Unchecked exceptions : beyond your control ( Error ) or result from a condition that you should not have allowed in the first place ( RuntimeException ) are subclasses of RuntimeException (e.g. ArrayIndexOutOfBoundException ) Error (e.g. OutOfMemoryError ) The Java compiler checks all exception handling, except exceptions represented by (subclasses of) Error and RuntimeException

Checked vs. Unchecked Checked exceptions: represent invalid conditions in areas outside the immediate control of the program E.g. database problems, network outages, or absent files are subclasses of Exception (except RuntimeException ) the compiler will confirm at compile time that the method includes code that might throw an exception must be caught or forwarded (advertised) This can be done in a try... catch statement or by defining the exception in the method definition (via throws )

Class Hierarchy [ java.lang.Object | +--java.lang.Throwable | +--java.lang. Exception | | | +--java.lang.ClassNotFoundException | | | +--java.io.IOException | | | | | +--java.io.FileNotFoundException | | | +--java.lang. RuntimeException | | | +--java.lang.NullPointerException | +--java.lang.ArithmeticException | +--java.lang.IllegalArgumentException | +--java.lang.IndexOutOfBoundsException | | | +--java.lang.ArrayIndexOutOfBoundsException | +--java.lang. Error | +--java.lang.VirtualMachineError | +--java.lang.OutOfMemoryError

Tag summary ooldocs/win32/javadoc.html ooldocs/win32/javadoc.html itingdoccomments/ itingdoccomments/

Minimum Requirements Class Field (followed by @deprecated (followed by sometimes)

Running JavaDoc javadoc [options] [packages] [filesnames] Can list one or packages No wildcards (i.e. *) Can list one or more java files Can use wildcards

javadoc Command-line Options -public Only public classes, members and methods are documented For API users -protected Public and protected Most common (default) -package Public, protected and package -private All For internal use -version Causes tag to be included in the documentation -d directory Location of output HTML documentation Same directory as source by default -author Causes tag to be included in the documentation -nodeprecated Deprecated methods and classes won’t be documented

Result Documentation Class Stack javadoc *.java javadoc –version –author –private - nodeprecated *.java

JavaDoc using Eclipse Code formatter Highlight code Source > Format JavaDoc comment generator Select the project or file in Package Explorer Project > Generate Javadoc … Follow wizard