[BLUEJ-76] Object Inspector should show abstract state, not concrete state, of instances of ArrayList and other library classes
When inspecting an ArrayList instance in BlueJ, you see the ArrayList's private fields elementData, size, and modCount. This is confusing to students and also not very helpful.
Ideally, for instances of library classes (i.e. classes outside the project), BlueJ's Object Inspector would show the instance's state in an abstracted way, i.e. the way that we want students to think about it.
For example, for an ArrayList instance (as in the Notebook example), the Object Inspector should show the following:
public int size() [ 2 ] public String get(0) [ "Hi!" ] public String get(1) [ "There!" ]
For some other classes, like HashMap, it's less clear how best to represent the state, but here's one way to represent a HashMap<String,int>
public int size() [ 2 ] public String entrySet().iterator().next()^1.getKey() [ "One" ] public int entrySet().iterator().next()^1.getValue() [ 1 ] public String entrySet().iterator().next()^2.getKey() [ "Two" ] public int entrySet().iterator().next()^2.getValue() [ 2 ]
Another way would be:
public int size [ 2 ] public String key0 [ "One" ] public int value0 [ 1 ] public String key1 [ "Two" ] public int value1 [ 2 ]
Now for the technical part: how to implement this? It's clear that BlueJ cannot automatically come up with a sensible abstract representation for all possible classes. Therefore, I propose that it should be possible to plug "abstractors" into BlueJ, that know how to show the abstract state of instances of a given set of classes. They would inspect the state of the instance either through com.sun.jdi.ObjectReference.getValue, or, preferably, by calling accessors through com.sun.jdi.ObjectReference.invokeMethod. As their output, they would return a list of label-value pairs, which would then be shown in the Object Inspector as usual. Alternatively, abstractors would be allowed to paint the content of the Object Inspector themselves.
Of course, ideally, abstractors for the classes used in the book should be built into BlueJ.
Thanks!
------- Comment BLUEJ-1 From Davin McCall 2006-04-12 02:52:04 [reply] ------- Marking as an enhancement.
------- Comment BLUEJ-2 From Michael K?lling 2006-04-26 12:37:42 [reply] ------- This is a complicated question.
Sometimes you do want to see the internal representation. Sometimes not.
Thsi needs further thought. (We once had custom inspectors, but removed them since nobody used them. They did essentiall this...)
mik
Issue metadata
- Issue type: Task
- Priority: Low