Home » Language IDEs » Java Development Tools (JDT) » New feature: Outline as class diagram
New feature: Outline as class diagram [message #1800564] |
Wed, 02 January 2019 14:27 |
Adriano Carvalho Messages: 54 Registered: November 2018 |
Member |
|
|
What is your opinion?[ 0 votes ] |
1. | Awesome! That is exactly what I need! | 0 / 0% | 2. | Nice to have. I'll use some of the time. | 0 / 0% | 3. | I'll use rarely. | 0 / 0% | 4. | I'll never use. | 0 / 0% |
Hi,
Summary: I would like to know your opinion on a feature I am working on.
I am currently working on a feature which provides an outline of the source code graphically, as a class diagram. The outline can be of individual files, complete folders/packages, or an entire project/workspace. It is also possible to rearrange the position of the elements in the diagram to make the architecture of the source code clearer. Updates to the source code are reflected on the diagram: changed elements stay where they are; deleted elements are also deleted from the diagram; new elements are added to the diagram.
Consider the following scenario:
- You are working on a Java project.
- You are on the source code editor, you zoom out and eclipse shows you a class diagram of the source code in the current file.
- You zoom out again and eclipse shows you a class diagram of the source code in the current folder. And so on... up to the current project/workspace.
(Zoom in would take you back where you were before zoom out.)
While on the class diagram you rearrange the elements, show/hide relationships, add comments, etc., to facilitate understanding and increase the clarity of the source code and its architecture. When you update the source code the elements in the diagram are updated accordingly.
Question on my mind right now:
- Do you think this is a useful feature? How much?
- Do you see yourself using this feature? How often do you think you'll use this feature?
- What are your concerns regarding this feature?
- Do you think its a productive use of my time or do you think that there are more important problems to be solved? Which problem or problems?
- Are you available to test or to provide test data?
Please vote and let me know your opinion.
If you are available for testing let me know.
Any feedback is appreciated.
Thanks in advance.
Best regards,
Adriano Carvalho
|
|
| | |
Re: New feature: Outline as class diagram [message #1800643 is a reply to message #1800635] |
Fri, 04 January 2019 10:09 |
Ed Willink Messages: 7669 Registered: July 2009 |
Senior Member |
|
|
Hi
Interesting question, but doing precisely what you outline could be a complete waste of time. Something similar could be very useful.
Most of our tools are based on the text paradigm; text editors that are made more scalable by scrolling/folding and more intelligible by projections such as outlines/hierarchies. The projections often use a tree structure for which intelligibility may be assisted by child-folding/ancestor-omission/alphabetical-ordering. This approach is good at conveying list/tree-structured information where the sole relationship of interest can be organised by children/siblings. Repeated named elements require repeated independent text.
Alternative tools use the graph paradigm; graphical editors that are made more scalable by 2-D scrolling (but not folding). Outlines and hierarchies can help. Neighbourhood/successor/predecessor sub-graphs can help too. Graphs are good for displaying graph-structured information, a single box/node for each named-element (no repeats), a line/edge for each relationship, diverse relationships can use line annotations/styling.
For some purposes text is much better, for other purposes graphs are much better. Text is generally more scalable. You need to understand the difference and focus your 'class diagram' attention on problems for which graphs are better.
A further important difference lies in sequential readability. For text we naturally start at the first character and read on. Sometimes we read the outline and use it to fast index to text that we then read. IMHO most graphical drawings are only useful to the original author for whom there was a sequential drawing order that enabled the author to get their ideas in order. During or after drawing, the layout is often contrived to make the drawing maximally visible in some artificial rectangle; drawings in publications are particularly bad this way. An independent reader of the diagram does not know where the story starts. As a minimum, a well-drawn diagram needs a well-written editorial paragraph to guide the reader through the middle-out, bottom-up, left-to-right organisation and focus of the diagram.
A catastrophic problem for Java users is the obfuscation of the code.
For modellers, where UML is encouraged, but often ignored, the 'code' has a simpler structure comprising class and properties with inheritance and reference relationships. There may be operations, but these tend to be secondary queries rather than primary functionality. Auto-drawing this functionality is hard, but perhaps tools have not worked hard enough on folding (so that a class-ancestry appears as a single 'class')..
For EMF modellers, the simple class structure is typically obfuscated by getter/setters per property and by interface/implementation per-class; the implemented data is therefore missing from the interface where you would like to find it. Any diagram is therefore bloated to show two boxes per class, and operation boxes around every property. For EMF Java, where the auto-generation imposes a very strong discipline, a tool could invert the auto-generation to show a nicer picture, but as soon as non-trivial custom code, let alone pure manual Java code, is in use there is a huge problem.
Consequently I would conclude that any attempt to auto-draw 'class' diagrams for typical Eclipse Java code is doomed to failure; you will have much too much to display and the underlying design concepts will be obfuscated.
i.e. zoom out from here will hit excess detail before anything useful is visible. Although a judicious combination of show/hide neighbours may enable the user to tailor the drawing to something useful.
-----
Yesterday, I was trying to understand some EMF code, and on reflection some of my understanding could have been aided by a graphical tool.
Problem: How does my code in MyClass::myMethod() access YourClass::yourData? Solution.
- Select MyClass::myMethod()
- Create a new 'navigation class diagram' for the selection (perhaps called "MyClass::myMethod() Navigation")
- Select YourClass::yourData
- Add the selection to "MyClass::myMethod() Navigation" (perhaps tailored to up-to 5 class search radius, up-to 2 class sub-optimal search)
Result: "MyClass::myMethod() Navigation" shows me the optimum navigation path to YourClass::yourData and alternate paths that are not more than two steps longer.
Problem: How does MyClass ensure that YourClass::yourData is initialized before it is read? Solution.
- Select YourClass::yourData
- Create a new 'access class diagram' for the selection (perhaps called "YourClass::yourData Access")
- Select MyClass
- Add the selection to "YourClass::yourData Access" (not sure how to tailor a search)
Result: "YourClass::yourData Access" shows me in horizontal order
- MyClass ancestor/descendant class methods from which writes can be triggered
- the call-trees that perform the writes
- YourClass::yourData
- the call-trees that perform the reads
- MyClass ancestor/descendant methods from which reads can be triggered
NB. Some kind of pseudo primitives will need to be defined so that Map::put is a known write, and Collection::isEmpty is a known read.
----
Many other programming challenges could be assisted in this way.
Problem: Is MyClass::myData threadsafe? Solution:
- Select MyClass
- Create a new 'thread safety class diagram' for the selection (perhaps called "MyClass Thread Safety")
- Select MyClass::myData1
- Add the selection to "MyClass Thread Safety"
- Select MyClass::myData2
- Add the selection to "MyClass Thread Safety"
The reads/write call-trees to myData are added to the diagram where a thick 'circle' surrounds myData1, myData2 with synchronized methods bridging the circle. Any call-tree not including a suitable synchronized gets a big red thick line. Redundant synchronized operations get a thin red line.
Ideally this kind of "MyClass Thread Safety" diagram can be saved and its semantics automatically executed by a Java Semantics Analysis Builder.
----
Bottom line, simple class diagrams are a waste of time. Highly focussed diagrams that focus on particular relationships could be very valuable.
----
Hm. This would be 'easy' in a side-effect fee language such as OCL. In Java, I guess you have to do a deep analysis of all knowable implementations of Map::put to discover what it writes to, and of Collection::isEmpty to discover that it writes nothing. Ouch! what about MyLinkedList that lazily caches size() on demand.
Regards
Ed Willink
|
|
| |
Re: New feature: Outline as class diagram [message #1800667 is a reply to message #1800643] |
Fri, 04 January 2019 19:03 |
Adriano Carvalho Messages: 54 Registered: November 2018 |
Member |
|
|
Ed Willink wrote on Fri, 04 January 2019 10:09Hi
Interesting question, but doing precisely what you outline could be a complete waste of time. Something similar could be very useful.
Most of our tools are based on the text paradigm; text editors that are made more scalable by scrolling/folding and more intelligible by projections such as outlines/hierarchies. The projections often use a tree structure for which intelligibility may be assisted by child-folding/ancestor-omission/alphabetical-ordering. This approach is good at conveying list/tree-structured information where the sole relationship of interest can be organised by children/siblings. Repeated named elements require repeated independent text.
Alternative tools use the graph paradigm; graphical editors that are made more scalable by 2-D scrolling (but not folding). Outlines and hierarchies can help. Neighbourhood/successor/predecessor sub-graphs can help too. Graphs are good for displaying graph-structured information, a single box/node for each named-element (no repeats), a line/edge for each relationship, diverse relationships can use line annotations/styling.
For some purposes text is much better, for other purposes graphs are much better. Text is generally more scalable. You need to understand the difference and focus your 'class diagram' attention on problems for which graphs are better.
This is not meant to replace but to complement existing features. It seems that you are going all the way down to the statement level. My idea was to stop at class/method/attribute level.
Quote:A further important difference lies in sequential readability. For text we naturally start at the first character and read on. Sometimes we read the outline and use it to fast index to text that we then read. IMHO most graphical drawings are only useful to the original author for whom there was a sequential drawing order that enabled the author to get their ideas in order. During or after drawing, the layout is often contrived to make the drawing maximally visible in some artificial rectangle; drawings in publications are particularly bad this way. An independent reader of the diagram does not know where the story starts. As a minimum, a well-drawn diagram needs a well-written editorial paragraph to guide the reader through the middle-out, bottom-up, left-to-right organisation and focus of the diagram.
That is a problem that affects both text-based and graphics-based representation. The benefit of the graphical-based representation IMHO is that is much less cluttered.
Quote:A catastrophic problem for Java users is the obfuscation of the code.
I also hope that by enabling users to see how unclear is their code at a higher-level of abstraction, *some* of them will work to make it clearer.
It is also possible that the lack of overview is one of the source for obfuscation (accidental obfuscation, that is).
Quote:For modellers, where UML is encouraged, but often ignored, the 'code' has a simpler structure comprising class and properties with inheritance and reference relationships. There may be operations, but these tend to be secondary queries rather than primary functionality. Auto-drawing this functionality is hard, but perhaps tools have not worked hard enough on folding (so that a class-ancestry appears as a single 'class').
For EMF modellers, the simple class structure is typically obfuscated by getter/setters per property and by interface/implementation per-class; the implemented data is therefore missing from the interface where you would like to find it. Any diagram is therefore bloated to show two boxes per class, and operation boxes around every property.
With filters we can show/hide certain elements.
Quote:For EMF Java, where the auto-generation imposes a very strong discipline, a tool could invert the auto-generation to show a nicer picture, but as soon as non-trivial custom code, let alone pure manual Java code, is in use there is a huge problem.
As you see from the video in my previous response this is something that can be done already.
Quote:Consequently I would conclude that any attempt to auto-draw 'class' diagrams for typical Eclipse Java code is doomed to failure; you will have much too much to display and the underlying design concepts will be obfuscated.
i.e. zoom out from here will hit excess detail before anything useful is visible. Although a judicious combination of show/hide neighbours may enable the user to tailor the drawing to something useful.
IMHO to get an overview, a graphical high-level view is better than a text-based view because of the implementation clutter and the difficulty of visualising multiple text files at once.
Quote:Yesterday, I was trying to understand some EMF code, and on reflection some of my understanding could have been aided by a graphical tool.
Problem: How does my code in MyClass::myMethod() access YourClass::yourData? Solution.
- Select MyClass::myMethod()
- Create a new 'navigation class diagram' for the selection (perhaps called "MyClass::myMethod() Navigation")
- Select YourClass::yourData
- Add the selection to "MyClass::myMethod() Navigation" (perhaps tailored to up-to 5 class search radius, up-to 2 class sub-optimal search)
Result: "MyClass::myMethod() Navigation" shows me the optimum navigation path to YourClass::yourData and alternate paths that are not more than two steps longer.
Problem: How does MyClass ensure that YourClass::yourData is initialized before it is read? Solution.
- Select YourClass::yourData
- Create a new 'access class diagram' for the selection (perhaps called "YourClass::yourData Access")
- Select MyClass
- Add the selection to "YourClass::yourData Access" (not sure how to tailor a search)
Result: "YourClass::yourData Access" shows me in horizontal order
- MyClass ancestor/descendant class methods from which writes can be triggered
- the call-trees that perform the writes
- YourClass::yourData
- the call-trees that perform the reads
- MyClass ancestor/descendant methods from which reads can be triggered
NB. Some kind of pseudo primitives will need to be defined so that Map::put is a known write, and Collection::isEmpty is a known read.
Many other programming challenges could be assisted in this way.
Problem: Is MyClass::myData threadsafe? Solution:
- Select MyClass
- Create a new 'thread safety class diagram' for the selection (perhaps called "MyClass Thread Safety")
- Select MyClass::myData1
- Add the selection to "MyClass Thread Safety"
- Select MyClass::myData2
- Add the selection to "MyClass Thread Safety"
The reads/write call-trees to myData are added to the diagram where a thick 'circle' surrounds myData1, myData2 with synchronized methods bridging the circle. Any call-tree not including a suitable synchronized gets a big red thick line. Redundant synchronized operations get a thin red line.
Ideally this kind of "MyClass Thread Safety" diagram can be saved and its semantics automatically executed by a Java Semantics Analysis Builder.
I see what you mean. This could be generalised as source code querying. That's a different beast. However, on top of the class diagrams simple query actions could be provided which when executed in order would give the same result. With this it would be a matter of creating predefined lists of actions composed by primitive actions.
Even though the simple diagrams sometimes require reverse engineering at the statement level, the queries that you mention may not be as simple.
Again, thanks a lot for your feedback.
|
|
|
Re: New feature: Outline as class diagram [message #1801571 is a reply to message #1800667] |
Tue, 22 January 2019 18:13 |
Stephan Herrmann Messages: 1853 Registered: July 2009 |
Senior Member |
|
|
As already hinted at by previous answers, software comprehension is a matter of perspectives. How information should be presented foremost depends on the question you are asking.
If you only want to see an enumeration of all things contained in, e.g., a package, then what's wrong with a tree like our Package Explorer? No clutter here :)
Things get tricky, to say the least, when you start considering relations between the things.
Inheritance structure may be amenable to graphical visualization (but then, is package structure relevant for this aspect?). Perhaps a Type Hierarchy view is best suited for this :)
For any other relations, just have a look at the typical import list: if you multiply this with the number of classes in the set, then you have the number of edges between them. Simply overwhelming in the general case.
It's for good reasons, that many of the interesting relations don't show up until you switch to a dynamic view, like a sequence diagram. But then you have to focus on a tiny number of classes (instances actually) to prevent the diagram from blowing up completely. Actually, what's the buzz about classes at this level. Maybe you prefer the Call Hierarchy view?
I'm not saying that JDT has every possible useful view. Far from it. Nor are graphical representations a bad idea. But depicting things graphically isn't the answer, its the first step on a long way towards useful program representations. I personally wouldn't consider class diagrams as a particularly big step of this journey.
my 3c
|
|
|
Goto Forum:
Current Time: Sun Sep 15 09:41:53 GMT 2024
Powered by FUDForum. Page generated in 0.04684 seconds
|