(CSGC) Documenting and Debugging Lesson

Documenting and Debugging

Field Summary
Fields inherited from class Shared Resources
animationDelay, frame, xSpeed
Constructor Summary
Bird1 ()
constructor for the class
Method Summary
void
act()
Controls the behaviors for the bird.
void
animateBird()
Switches between the different bird images
void
applyGravity()
This method will apply Gravity to the bird and change the image
void
checkKeys ()
Moves the bird go up when the space bar or mouse is clicked.

In computer programming, a comment is a note or annotation in the source code of a computer program. They are specially marked lines of code that are not evaluated.

Comments are used to:

  • make the source code easier for humans to understand
  • make maintenance much easier
  • help find bugs faster

Java comments are grouped into two types:

1) Documentation comments

• Javadoc Comments

2) Implementation Comments

• Multi-line

• Single Line

Debugging Your Code

Image of BugIf there is a syntax error in your program, it will not compile. An error is referred to as a bug, so the process of correcting the error is called debugging. Debugging the program means finding the error and making the correction to the code so it will compile and run.

Recognizing and correcting errors in your program teaches good programming skills. If a program is very large, it is important to test it in intervals. After adding a functionality to the program, test it and debug.      

[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION