CS 2112 Lab: Javadoc and Debugging CS 2112 Lab: Javadoc and - - PowerPoint PPT Presentation

cs 2112 lab javadoc and debugging
SMART_READER_LITE
LIVE PREVIEW

CS 2112 Lab: Javadoc and Debugging CS 2112 Lab: Javadoc and - - PowerPoint PPT Presentation

CS 2112 Lab: Javadoc and Debugging CS 2112 Lab: Javadoc and Debugging Javadoc Overview Javadoc Overview Javadoc is a tool for creating html documentation The documentation is generated from comments It produces actual html web pages


slide-1
SLIDE 1

CS 2112 Lab: Javadoc and Debugging

CS 2112 Lab: Javadoc and Debugging

slide-2
SLIDE 2

Javadoc Overview

Javadoc Overview

◮ Javadoc is a tool for creating html documentation ◮ The documentation is generated from comments ◮ It produces actual html web pages ◮ Helps keep documentation consistent with the code

CS 2112 Lab: Javadoc and Debugging

slide-3
SLIDE 3

Doc Comments

Doc Comments

◮ Doc comments start with /** and end with */. ◮ The /** and */ should be on their own lines ◮ Additional lines need to start with a *. ◮ Comments can have html tags.

1

/**

2

* This is a javadoc comment

3

*/

CS 2112 Lab: Javadoc and Debugging

slide-4
SLIDE 4

Tags

Javadoc Tags

◮ Use tags to help Javadoc parse your comments. ◮ Tags start with a @ and are case sensitive. ◮ It must be at the beginning of the line

1

/**

2

* Prints the kth element of the list

3

*

4

* @author Alexander Lee

5

* @param list The list who’s element is to be printed

6

* @param k The index of the item to be printed

7

*/

8

public void printK(List list , int k) {

9 10

}

CS 2112 Lab: Javadoc and Debugging

slide-5
SLIDE 5

Javadoc Links

Javadoc Links

◮ @link package.class#member label ◮ This tag inserts a link that points to the documentation of the

specified class

◮ label represents the text that shows up ◮ The curly brackets indicate that it is an inline tag ◮ So it can be placed anywhere in the comments, doesn’t have

to be in the beginning.

1

/**

2

* Get the names of an object

3

*

4

* @deprecated This function should not be used

5

* Use {@link #getFirstName ()} and

6

* {@link al91.Person#getLastName ()} instead.

7

*/

CS 2112 Lab: Javadoc and Debugging

slide-6
SLIDE 6

Javadoc Links

Important Tags

Some important tags

◮ @author: describes the author ◮ @param: describes a specific parameter ◮ @return: describes the return value ◮ @throws: describes exceptions it throws ◮ @deprecated: describes the reason ◮ @see package.class#member

CS 2112 Lab: Javadoc and Debugging

slide-7
SLIDE 7

Javadoc and Eclipse

Javadoc and Eclipse

◮ To generate the doc, go to Project and Generate Javadoc ◮ Eclipse automatically generates Javadoc comments if the

method signature is already written.

◮ Can configure Eclipse to complain about missing Javadoc by

going to preferences, compiler, javadoc

CS 2112 Lab: Javadoc and Debugging

slide-8
SLIDE 8

Exercise

Specification Exercise

Design a GPS system that finds the shortest route from the current location to the destination.

◮ There are three ways of transportation, by car, by public

transportation and by walking.

◮ The GPS sytem should be able to return a route given any

current location, and destination

◮ Can be easily updated to add new roads, or to avoid roads

CS 2112 Lab: Javadoc and Debugging

slide-9
SLIDE 9

Debugging

Debug Exercise

Run Lab02 in the debug perspective. The program currently prints

  • ut a grid of 4’s, but this is not right. Try to debug it using:

◮ breakpoints ◮ stepping over, in, out ◮ continuing ◮ inspecting variables

CS 2112 Lab: Javadoc and Debugging