CHC4010 DevOps Week 4 Practical: Documentation
Part I. Commenting Code
In the
exercise1folder, find the fileSort.javaand copy the file into thesrcfolder of your project. Read through the implementation of insertion sort. Try to understand what each line of code does and how together they complete the task of sorting an array of integers.Open
comments.txtto find 11 pre-written comments. Based on your understanding of the code inSort.java, put each comment into an appropriate place among the 11 empty lines of comments marked (1) to (11).
Part II. Documenting Code with JavaDoc
Open the
exercise2folder and copy three files insidesrcinto the srcfolder of your project. Copymovies.csvinto the root folder of your project (that is, the parent folder ofsrc).Run
DBInterface.javaand experiment with different user input. Understand what the program does. Look atmovies.csvand check if there are any changes.There are some methods, parameters, attributes, and local variables in
Movieclass that have weird names. Based on your understanding of the program behavior and the roles they play in realizing this behaviour, rename these methods, parameters, attributes, and local variables so that their names have meaning and make the code more readable.Add appropriate JavaDoc comments to all public methods of
Movieclass andMovieDBclass. Check that your JavaDoc comments are detected by the IDE. Then compile all the JavaDoc comments in your project into a reference guide in HTML format and view them in a web browser.In
MovieDBclass,java.util.ArrayListis used for storing a collection of movies. Replace this datatype withjava.util.HashMap, a datatype similar to dictionaries in Python, with the help of JavaDoc, and make necessary changes to the code so that the program will still work.
After this change, do we need to update the JavaDoc comments for any of the public methods? Why or why not?
[!TIP] π Solution Codes
Last updated