bineanzhou / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Grapher, to create graphs from an Injector #213

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be great if we had a robust, easy-to-use class that creates graphs 
from Injectors.

I've attached the source of a proof-of-concept, its source, and a generated 
image. The application 
uses Graphviz, which makes the actual graph part easy.
http://www.graphviz.org/

It would be nice if the graphs that were easy to read. There's two major types 
of edges (Bindings, 
InjectionPoints) in the graph, and they should look different. In the attached 
code, I used different 
arrowheads for this. A good implementation could go much further (colours, line 
styles). 

There's a lot of information in an Injector, and a good graph could make 
understanding it very easy. 
It would also be nice if it the grapher had extension hooks.

Original issue reported on code.google.com by limpbizkit on 23 Jun 2008 at 4:48

Attachments:

GoogleCodeExporter commented 9 years ago
Hi. I saw your blog post and I'm interested in helping with this issue. I have 
some
experience with the Java2D API and think I can help.
Here is a sample of my work with Java2D (still work in progress)
http://www.cin.ufpe.br/~vcac/projetos/PaintOnline.jnlp

If you are willing to accept my help please send me an email with further
instructions (gmail: victorcisneiros). I have never contributed to an 
open-source
project so I'm not sure how I should proceed.

Original comment by victorci...@gmail.com on 24 Jun 2008 at 3:22

GoogleCodeExporter commented 9 years ago
FYI, I talked to victorcisneiros and he's no longer interested in implementing 
this. If anyone wants it, it's up-for-
grabs yet again.

Original comment by limpbizkit on 24 Jun 2008 at 5:18

GoogleCodeExporter commented 9 years ago
I'm working on a library for automated graph layout --
http://code.google.com/p/modsl/.  The primary goal of my project was to be able 
to
process a simple domain specific language into a UML diagram (for quick and 
dirty UML
sketching). Internally the graph is represented as a simple hierarchical tree of
nodes, edges and labels of different types, so I think it wouldn't be that hard 
to
reuse it for your injector graphing. Also it is quite flexible in terms of
customizing look and feel. I could work out the integration part. Please let me 
know.

Original comment by avi...@gmail.com on 2 Jul 2008 at 9:35

GoogleCodeExporter commented 9 years ago
We've already got Graphviz for graph rendering and layout. It works fine and 
meets our needs.

The problem I'm interested in solving is generating the actual Graphviz file to 
use as input. This file should 
describe the injector, balancing the tradeoffs between readability and 
completeness.

Original comment by limpbizkit on 3 Jul 2008 at 12:15

GoogleCodeExporter commented 9 years ago
Graphviz is an excellent tool. I'm curious though if you're planning to bundle 
it
with Guice (Graphviz is not cross-platform) or if it is expected to be present 
on the
developer's machine to take advantage of the Guice graphing functionality.

Original comment by avi...@gmail.com on 3 Jul 2008 at 2:48

GoogleCodeExporter commented 9 years ago
I'd prefer we generate a graphviz .dot file but not render it. 

Users can view .dot files in many viewers. According to graphviz.org, there's 
viewers for Unix, Windows, Mac, 
Java and even SVG.

Original comment by limpbizkit on 3 Jul 2008 at 3:11

GoogleCodeExporter commented 9 years ago
The tool should provide information about the scopes of the bindings, both 
built-in 
and custom scopes. It would also be useful to see an object diagram, which 
visualizes 
how the object graph will look like at runtime. This would be useful in 
debugging the 
number of instances per scope (see http://groups.google.com/group/google-
guice/browse_thread/thread/93dd8f0efc765ac8?hl=en).

Original comment by esko.luo...@gmail.com on 14 Sep 2008 at 6:50

GoogleCodeExporter commented 9 years ago
I'd like to take this on.

I've attached some output from the tool I whipped up. I still need to handle 
providers, and I think there's some 
improvements that could be made to the display (Graphviz apparently has rough 
HTML support, so I could do 
background colors, possibly small text, and italics).

Let me know what you think.

Original comment by phopkins on 22 Dec 2008 at 7:46

Attachments:

GoogleCodeExporter commented 9 years ago
Oh, and the generated dot file.

Original comment by phopkins on 22 Dec 2008 at 7:47

Attachments:

GoogleCodeExporter commented 9 years ago
@phopkins - wow, this is fantastic. I really like the dotted lines styling the 
interfaces. Sweet!

FYI, I've recently made some big changes to the SPI, which will certainly break 
your code. I've changed the 
Bindings to have proper types so the visitors aren't the only way to get at the 
data - they were quite clumsy to 
work with.

I'd also like to use your grapher to help us to ensure the SPI is 'good 
enough'. What are the rough edges? What 
are we missing? I'm going to try to fill in the gaps to make sure all the 
necessary stuff is in there, and your 
input is extremely valuable.

Original comment by limpbizkit on 25 Dec 2008 at 4:39

GoogleCodeExporter commented 9 years ago
A bit more. :)

Gray background denotes an instance, double arrow denotes binding to a 
provider, and circle-arrow denotes a 
constant type conversion.

I think I packed in most ways to Guice stuff together in this example.

There's no scope display yet, but I figure it'd be better to focus on getting 
this cleaned up and checked in first.

Original comment by phopkins on 25 Dec 2008 at 4:42

Attachments:

GoogleCodeExporter commented 9 years ago
Crossed messages. :)

The two bugs I filed (that you found) are mostly what I found for roughness. 
The other big one I can think of is 
Multibinding support. The bindings that it creates are a bit of a mess when 
viewed naively through SPI (in 
particular, the RealMultibinder instance has no dependencies on the elements, 
just on an Injector), and the 
classes that one could try to instanceof a way out of (such as @Element) are 
package-private, so no luck 
there.

What's the best way to share the code, so you can see if the Visitor bits look 
right to you? It'll be a big CL. 
(Btw, are there code conventions / developer docs lying around? Is it basically 
just Google style? 80 or 100?)

Looking forward to trying your updates. I haven't synched since the weekend, so 
I'll see how things come 
together over the next day or two.

Oh, and as I said I haven't looked through Scopes yet, so I don't know how well 
the SPI stuff works there.

Original comment by phopkins on 25 Dec 2008 at 4:51

GoogleCodeExporter commented 9 years ago

Original comment by phopkins on 30 Dec 2008 at 8:05

GoogleCodeExporter commented 9 years ago
Fixed w/ r752

Original comment by phopkins on 30 Dec 2008 at 9:59