Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly detect intercomponent dependencies from Java code #65

Open
Z13NDELS opened this issue Oct 31, 2020 · 5 comments
Open

Directly detect intercomponent dependencies from Java code #65

Z13NDELS opened this issue Oct 31, 2020 · 5 comments
Labels
effort: 13 priority: 2day state: approved Approved to proceed. type: research Tickets with this label are researches, that may or may not have a final result 🧪 work: complex The situation is complex, emergent practices used.

Comments

@Z13NDELS
Copy link
Contributor

This is easy, provided we know how to parse components : just read imports from components source code using JavaParser, and detect if these dependencies are non static and go from one component to one another

@Riduidel
Copy link
Owner

This is (partially) implemented in sequence-diagram-generator maven module, but could be improved (and module name could be changed.

@Riduidel
Copy link
Owner

ok, let's explain dev strategy : the architecture-documentation maven module invokes the sequence-diagram-generator module as a dependency, triggeing the sequence diagrams generation in target/structurizr. I see multiple deffects that I'll try to handle separatly by creating sub-issues (which to my mind mostly come from my inhability to correctly parse modern java code).

@Riduidel
Copy link
Owner

Riduidel commented Aug 10, 2022

So first bug is easily viewed.

Here is the /architecture-documentation/target/structurizr/diagrams/Aadarchi/base/ArchitectureDocumentationBuilder/ArchitectureDocumentationBuilder_run.plantuml diagram. It exposes the ArchitectureDocumentationBuilder#run method.

ArchitectureDocumentationBuilder_run_plantuml

But look ! here is the ArchitectureEnhancer#enhance method code ...

		classloader = Thread.currentThread().getContextClassLoader();
		logger.info(() -> String.format("Enhancers applied to this architecture are\n%s",  
			enhancers.stream()
				.sorted(Comparator.comparingInt(e -> e.priority()))
				.map(e -> String.format("%s => %d", e.getClass().getName(), e.priority()))
				.collect(Collectors.joining("\n"))));
		withStopWatch("Running all enhancements took %s", () -> enhancers.stream()
			.sorted(Comparator.comparingInt(e -> e.priority()))
			.forEach(enhancer -> enhancerVisitWorkspace(enhancer, workspace)));
	}

You see what is wrong ?
Yup, there are enhancers.stream() calls. And the mix between iteration through keywords and iteration through method calls is not nice.
Furthermore, the #enhancerVisitWorkspace method, which is private, prevent us from understanding the full visit. This is unfortunate, and should be fixed.

@Riduidel
Copy link
Owner

Regarding the streams, and closures from java 8, the first log line is quite clear

[ERROR] (org.ndx.aadarchi.sequence.generator.javaparser.visitor.JavaParserVisitorForBuildingCallGraph) Unable to resolve method call String.format("Enhancers applied to this architecture are\n%s", enhancers.stream().sorted(Comparator.comparingInt(e -> e.priority())).map(e -> String.format("%s => %d", e.getClass().getName(), e.priority())).collect(Collectors.joining("\n"))) due to exception "Unable to calculate the type of a parameter of a method call. Method call: String.format("Enhancers applied to this architecture are\n%s", enhancers.stream().sorted(Comparator.comparingInt(e -> e.priority())).map(e -> String.format("%s => %d", e.getClass().getName(), e.priority())).collect(Collectors.joining("\n"))), Parameter: enhancers.stream().sorted(Comparator.comparingInt(e -> e.priority())).map(e -> String.format("%s => %d", e.getClass().getName(), e.priority())).collect(Collectors.joining("\n"))". We give up on that one.

So I never wrote the code to understand what a closure is ... Let's start with that very precise problem.

@Riduidel
Copy link
Owner

Regarding the initial subject, it seems like letting the visitor handling the navigation in the containers may not be the smartest idea.
Indeed, the aadarchi.sequence.generator.with define a list of containers used to render diagram.
As a consequence, those containers should be scanned before the current one. Which screams Direct acyclic graph to my ears. A notion which is very interesting, but which is not yet supported by our model visitor system.

@Riduidel Riduidel assigned Helielzel and unassigned Bullfrog666 Mar 1, 2023
@Riduidel Riduidel added effort: 13 state: approved Approved to proceed. priority: soon work: complex The situation is complex, emergent practices used. type: research Tickets with this label are researches, that may or may not have a final result 🧪 priority: 2day and removed difficulty-🐛🐛🐛 priority: soon labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: 13 priority: 2day state: approved Approved to proceed. type: research Tickets with this label are researches, that may or may not have a final result 🧪 work: complex The situation is complex, emergent practices used.
Projects
None yet
Development

No branches or pull requests

4 participants