CS2_11_Debugging

CS2_11_Debugging - CS2 Module 11 Category Elements of Java...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2 Module 11 Category: Elements of Java Topic: Coding Style/Debugging Objectives Emphasize key aspects of coding style Introduce basic debugging concepts
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 2 Introduction to Object Oriented Programming Module 11 Elements of Java Debugging
Background image of page 2
Coding Style Use a consistent clear coding style Java identifiers typically do not contain underscores. Instead words are together with successive words capitalized Class names should be capitalized class Queue class CountingQueue class LinkedList class ThreeBlindMice
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Coding Style Method and variable names should not have their first letter capitalized. Names should suggest what they do or hold calcAverage() printMenu() getChoice() int count; float maxPressure; boolean isBad; // Note: not goodOrBad
Background image of page 4
Coding Style Methods should generally not be longer than one screenful of code. Extremely long methods are often difficult to understand and usually indicate poor abstraction thus suggesting further abstraction (i.e. write more methods) is needed Methods that fit on one screen can use simple variable names: Queue q = new Queue(); Stack s = new Stack(); s.push(q.dequeue());
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Coding Style Comment closing braces to indicate which block is closing particularly when blocks are nested while(forever) { if(someBoolean) { for() { ... } // end for } // end if. ..then else { // whatever } // end else } // while forever
Background image of page 6
Coding Style Use a consistent indentation style while(forever) { if(someBoolean) { for() { ... } // end for } // end if. ..then else { // whatever } // end else } // while forever
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Coding Style Use a consistent indentation style while(forever) { if(someBoolean) { for() { ... } // end for } // end if. ..then else { // whatever } // end else } // while forever
Background image of page 8
Debugging
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Debugging Strategies Incremental programming System.out.println Use of toString method Debug constant Debugging mains Command line arguments Understanding errors
Background image of page 10
The Idea : Find and repair bugs “in the small” before you have a program with several components. The hardest thing is finding the errors. So, find them as you create each class. Thus, do not : write your entire program, then type in your entire program, then attempt to test your entire program Instead: design your program at high level, then focus on one class at a time, for each class, write and test before going on to the next one, this means write a main method for every class! This way, you deal with bugs when it‘s easiest!
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2012 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Page1 / 41

CS2_11_Debugging - CS2 Module 11 Category Elements of Java...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online