java -agentlib:hprof Prog

Download Report

Transcript java -agentlib:hprof Prog

Object-Oriented Design
Object Oriented Design

CRC stands for Classes, Responsibilities,
Collaborators

Class name goes on the top

Responsibilities go on the left

Collaborators go on the right
UML Basics
Inherits, is a...
Implements, is a...
Aggregation, has a...
Dependency
Design

Identify nouns

Group nouns into packages

Responsibilities

Identify more nouns & responsibilities

Use case - example that helps identify what the
program needs to do/handle
Testing


It's a good idea to write unit tests, small
examples of things that should happen
Language feature: assert()
Documentation

/** javadoc comment */

put them on classes, methods, fields, as
appropriate

@see refer to another class or method

@param document a param

@return document the return value
Examples

Blackjack?

Chess?

Battleship?

Adventure?
Debugging

To debug:


compile with the -g flag, javac -g Prog.java
To run the debugger

local debugging



jdb Prog
remote debugging

java -Xdebug Xrunjdwp:transport=dt_socket,server=y,address=8080 Prog

jdb -attach 8080
To profile:

run like this: java -agentlib:hprof Prog

then start jconsole and attach to your program
Debugging

stop at BlackJackViewer:58


clear BlackJackViewer:58


clears breakpoint
dump bj / print bj.game.deck.cards.size()


sets breakpoint
prints out variables
run / step / step up / next / cont
Debugging

threads / thread

locals

set

watch

threads

where