This is an old revision of the document!


Basic Software Development with Eclipse

In Lab 1 you learned Eclipse basics; today you'll learn about more advanced software development features:

  • Using the type hierarchy & call hierarchy
  • Introduction to refactoring
  • Using Eclipse's debugger
Initial Setup

We'll be working with Freemind, a medium-sized (50 KLOC) open source application. You will need 65 MB of available space (or find a partner who does). On the composer machines, you should have no more than 37000 KB used (quota -v).

Setup instructions for composer machines (can be adapted to other OS's):

  1. Download & extract Freemind
    • Download freemind-src-0.9.0_RC_4.tar.gz from sourceforge
    • Open a terminal and navigate to the file (most likely in 'Desktop')
    • Unzip & untar (gunzip freemind-src-0.9.0_RC_4.tar.gz; tar xvf freemind-src-0.9.0_RC_4.tar)
    • If space is tight, delete the tar file once extracted (rm freemind-src-0.9.0_RC_4.tar)
  2. Import Freemind into Eclipse
    • open eclipse (eclipse &)
    • Select File > New > Java Project
    • Name the project “freemind”, and select “create from existing source”
    • Browse to your freemind folder (e.g., $USER_HOME/Desktop/freemind)

  • Select “finish”, and wait for “Building workspace” to finish in the bottom right of the screen.
Running Freemind

Freemind is mind mapping software often used for knowledge and content management. It's a hierarchical editor that supports “folding”–that is, collapsing and expanding sections of the hierarchy. Today we'll focus on understanding how the folding functionality is implemented.

The easiest way to understand the concept of folding is to try it out:

  1. In the package explorer, right click on the freemind folder & select “Run As > Java Application”
  2. Select “freemind.main.FreemindStarter” as the main class to execute (ignore errors written to console)

  1. Create a new mind map about Software Engineering:
    • Add children nodes by going to “Insert > New Child Node”, hitting the “insert” key, or selecting the lightbulb
    • Add at least 3 levels of children, with at least 2 children per level
    • Save the mind map
  2. Select a middle node (not leaf or root) and attempt to fold it. There are 3 ways to change a node's folding status:
    • click the node
    • hit space bar
    • right click and select “toggle folded”
    • select “Navigate > Toggle Folded” in the menu

Using the type & call hierarchy to understand code

Call Hierarchy

The call hierarchy shows calling relationships between methods in a program. For example:

  • Navigate to the method toggleFolded(ListIterator listIterator) in class freemind.modes.minmapmode.actions.ToggleFoldedAction
  • Right click the method name and select “Open Call Hierarchy”
  • Look at the callers and callees
  • Going back to the callers, expand toggleFolded & toggleFolded again. Look at the callers of actionPerformed.
  • Try looking at the callers of other methods, such as nameSetFolded

What information does the call hierarchy give you? Why is it useful for understanding a program?

Type Hierarchy

The type hierarchy shows how types are related. For example:

  • Right click in the editor window for ToggleFoldedAction and select “Open Type Hierarchy”
  • Right click on AbstractAction and select “Focus On 'AbstractAction'”

What information does the type hierarchy give you? Why is it useful for understanding a program?

Basic Refactoring

Debugging in Eclipse

Exercises

  • Show me an interesting call hierarchy and type hierarchy on your project code (“interesting” = more than 3 nodes)
  • Show me a debugging trace for toggleFolded. Which method calls in the trace do you think handle your input method (click, space, right click, etc.)?
hill/275.1255473172.txt.gz · Last modified: 2009/10/13 18:32 by hill
  • 213 Smith Hall   •   Computer & Information Sciences   •   Newark, DE 19716  •   USA
    Phone: 302-831-6339  •   Fax: 302-831-8458