Skip to content

Latest commit

 

History

History
1202 lines (1127 loc) · 29.1 KB

File metadata and controls

1202 lines (1127 loc) · 29.1 KB

Visibility Metrics for Java


References

Relative Visibility Of Types

A Java class or interface may be declared with the modifier public, in which case it is visible to all classes everywhere. If a class or interface has no modifier (the default, also known as package-private), it is visible only within its own package.

The relative visibility is the number of inner components that are visible outside (public) divided by the number of all types:

$$ relative visibility = \frac{public:types}{all:types} $$

Using package protected types is one of many ways to improve encapsulation and implementation detail hiding.

How to apply the results

The relative visibility is between zero (all types are package protected) and one (all types are public). A value lower than one means that there are types that are declared package protected. The lower the value is, the better implementation details are hidden.

Non public classes can't be accessed from another package so they can be changed without affecting code in other packages. They clearly indicate functionality that only belongs to one package. This also motivates to use more classes and to split up code into smaller pieces with a single responsibility and reason to change.

Table 1a - Top 40 artifacts with lowest median of package protection encapsulation

This table shows the relative visibility statistics aggregated for all packages per artifact and focusses on artifacts with many packages and hardly any package protected types (lowest median, high visibility). Package protected types would help to improve encapsulation.

Only the top 40 entries are shown. The whole table can be found in the following CSV report:
Global_relative_visibility_statistics_for_types

artifact all public min max average percentile25 percentile50 percentile75 percentile90
0 axon-common-5.0.0 150 123 0.615385 1.000000 0.876656 0.782609 1.000000 1.000000 1.000000
1 axon-spring-boot-autoconfigure-5.0.0 66 52 0.580645 1.000000 0.904378 0.875000 1.000000 1.000000 1.000000
2 axon-conversion-5.0.0 30 27 0.700000 1.000000 0.925000 0.925000 1.000000 1.000000 1.000000
3 axon-update-5.0.0 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
4 axon-tracing-opentelemetry-5.0.0 5 5 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
5 axon-modelling-5.0.0 93 85 0.692308 1.000000 0.903907 0.867521 0.900000 1.000000 1.000000
6 axon-metrics-micrometer-5.0.0 13 10 0.750000 1.000000 0.875000 0.812500 0.875000 0.937500 0.975000
7 axon-messaging-5.0.0 570 432 0.250000 1.000000 0.808014 0.750000 0.846154 1.000000 1.000000
8 axon-test-5.0.0 73 59 0.600000 1.000000 0.819906 0.709677 0.833333 0.956522 0.982609
9 axon-server-connector-5.0.0 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
10 axon-eventsourcing-5.0.0 100 66 0.200000 0.900000 0.599721 0.480769 0.666667 0.734921 0.813333

Table 1b - Top 40 artifacts with highest median of package protection encapsulation

This table shows the relative visibility statistics aggregated for all packages per artifact and focusses on artifacts with many packages and the highest median of package protected types (low visibility). Package protected types help to improve encapsulation.

Only the top 40 entries are shown. The whole table can be found in the following CSV report:
Global_relative_visibility_statistics_for_types

artifact all public min max average percentile25 percentile50 percentile75 percentile90
0 axon-eventsourcing-5.0.0 100 66 0.200000 0.900000 0.599721 0.480769 0.666667 0.734921 0.813333
1 axon-test-5.0.0 73 59 0.600000 1.000000 0.819906 0.709677 0.833333 0.956522 0.982609
2 axon-server-connector-5.0.0 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
3 axon-messaging-5.0.0 570 432 0.250000 1.000000 0.808014 0.750000 0.846154 1.000000 1.000000
4 axon-metrics-micrometer-5.0.0 13 10 0.750000 1.000000 0.875000 0.812500 0.875000 0.937500 0.975000
5 axon-modelling-5.0.0 93 85 0.692308 1.000000 0.903907 0.867521 0.900000 1.000000 1.000000
6 axon-common-5.0.0 150 123 0.615385 1.000000 0.876656 0.782609 1.000000 1.000000 1.000000
7 axon-spring-boot-autoconfigure-5.0.0 66 52 0.580645 1.000000 0.904378 0.875000 1.000000 1.000000 1.000000
8 axon-conversion-5.0.0 30 27 0.700000 1.000000 0.925000 0.925000 1.000000 1.000000 1.000000
9 axon-update-5.0.0 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
10 axon-tracing-opentelemetry-5.0.0 5 5 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000

Table 1 Chart 1 - Relative visibility in artifacts

/home/runner/miniconda3/envs/codegraph/lib/python3.12/site-packages/pandas/plotting/_matplotlib/core.py:1351: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  scatter = ax.scatter(
/home/runner/miniconda3/envs/codegraph/lib/python3.12/site-packages/pandas/plotting/_matplotlib/core.py:1351: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  scatter = ax.scatter(
/home/runner/miniconda3/envs/codegraph/lib/python3.12/site-packages/pandas/plotting/_matplotlib/core.py:1351: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  scatter = ax.scatter(



<Figure size 640x480 with 0 Axes>

png

Table 2a - Top 40 packages with the highest visibility and lowest encapsulation

This table shows the relative visibility statistics per packages and artifact and focusses on packages with many types, hardly any package protected ones and therefore the highest relative visibility (lowest encapsulation). Package protected types would help to improve encapsulation.

Only the top 40 entries are shown. The whole table can be found in the following CSV report:
Relative_visibility_public_types_to_all_types_per_package

artifactName fullQualifiedPackageName packageName publicTypes allTypes relativeVisibility
0 axon-spring-boot-autoconfigure-5.0.0 org.axonframework.extension.springboot springboot 20 20 1.0
1 axon-modelling-5.0.0 org.axonframework.modelling.entity.annotation annotation 18 18 1.0
2 axon-modelling-5.0.0 org.axonframework.modelling modelling 16 16 1.0
3 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.conf... configuration 14 14 1.0
4 axon-modelling-5.0.0 org.axonframework.modelling.entity.child child 14 14 1.0
5 axon-common-5.0.0 org.axonframework.common.jdbc jdbc 11 11 1.0
6 axon-conversion-5.0.0 org.axonframework.conversion.avro avro 10 10 1.0
7 axon-common-5.0.0 org.axonframework.common.property property 9 9 1.0
8 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... jdbc 9 9 1.0
9 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.sequ... sequencing 9 9 1.0
10 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.tracing tracing 7 7 1.0
11 axon-messaging-5.0.0 org.axonframework.messaging.queryhandling.tracing tracing 7 7 1.0
12 axon-spring-boot-autoconfigure-5.0.0 org.axonframework.extension.springboot.util util 7 7 1.0
13 axon-update-5.0.0 org.axonframework.update.configuration configuration 7 7 1.0
14 axon-common-5.0.0 org.axonframework.common.util util 6 6 1.0
15 axon-messaging-5.0.0 org.axonframework.messaging.tracing.attributes attributes 6 6 1.0
16 axon-messaging-5.0.0 org.axonframework.messaging.core.correlation correlation 6 6 1.0
17 axon-update-5.0.0 org.axonframework.update.api api 6 6 1.0
18 axon-common-5.0.0 org.axonframework.common.lifecycle lifecycle 5 5 1.0
19 axon-conversion-5.0.0 org.axonframework.conversion.converter converter 5 5 1.0
20 axon-conversion-5.0.0 org.axonframework.conversion.json json 5 5 1.0
21 axon-messaging-5.0.0 org.axonframework.messaging.monitoring.interce... interception 5 5 1.0
22 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... store 5 5 1.0
23 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... subscribing 5 5 1.0
24 axon-tracing-opentelemetry-5.0.0 org.axonframework.extension.tracing.opentelemetry opentelemetry 5 5 1.0
25 axon-update-5.0.0 org.axonframework.update update 5 5 1.0
26 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... jpa 4 4 1.0
27 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.replay replay 4 4 1.0
28 axon-update-5.0.0 org.axonframework.update.detection detection 4 4 1.0
29 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... errorhandling 3 3 1.0
30 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... processing 3 3 1.0
31 axon-messaging-5.0.0 org.axonframework.messaging.core.configuration... reflection 3 3 1.0
32 axon-common-5.0.0 org.axonframework.common.jpa jpa 2 2 1.0
33 axon-messaging-5.0.0 org.axonframework.messaging.core.configuration configuration 2 2 1.0
34 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.conv... conversion 2 2 1.0
35 axon-messaging-5.0.0 org.axonframework.messaging.core.conversion conversion 2 2 1.0
36 axon-messaging-5.0.0 org.axonframework.messaging.queryhandling.gateway gateway 2 2 1.0
37 axon-messaging-5.0.0 org.axonframework.messaging.core.reflection reflection 2 2 1.0
38 axon-spring-boot-autoconfigure-5.0.0 org.axonframework.extension.springboot.actuato... axonserver 2 2 1.0
39 axon-test-5.0.0 org.axonframework.test.server server 2 2 1.0

Table 2b - Top 40 packages with the lowest visibility and highest encapsulation

This table shows the relative visibility statistics per packages and artifact and focusses on packages with many types, many package protected ones and therefore the lowest relative visibility (highest encapsulation). Package protected types help to improve encapsulation. Zero percent visibility and therefore packages with no public visible type are suspicious to be dead code.

Only the top 40 entries are shown. The whole table can be found in the following CSV report:
Relative_visibility_public_types_to_all_types_per_package

artifactName fullQualifiedPackageName packageName publicTypes allTypes relativeVisibility
0 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing.eventstore.inm... inmemory 1 5 0.200000
1 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... pooled 6 24 0.250000
2 axon-messaging-5.0.0 org.axonframework.messaging.monitoring.configu... configuration 2 8 0.250000
3 axon-messaging-5.0.0 org.axonframework.messaging.queryhandling.inte... interception 2 8 0.250000
4 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... inmemory 1 3 0.333333
5 axon-messaging-5.0.0 org.axonframework.messaging.commandhandling.in... interception 2 5 0.400000
6 axon-messaging-5.0.0 org.axonframework.messaging.core.interception interception 8 19 0.421053
7 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing.eventstore.jpa jpa 6 13 0.461538
8 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing.configuration configuration 7 14 0.500000
9 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... annotation 1 2 0.500000
10 axon-messaging-5.0.0 org.axonframework.messaging.core.unitofwork.an... annotation 1 2 0.500000
11 axon-messaging-5.0.0 org.axonframework.messaging.eventstreaming eventstreaming 9 16 0.562500
12 axon-spring-boot-autoconfigure-5.0.0 org.axonframework.extension.springboot.autoconfig autoconfig 18 31 0.580645
13 axon-test-5.0.0 org.axonframework.test test 3 5 0.600000
14 axon-common-5.0.0 org.axonframework.common.caching caching 8 13 0.615385
15 axon-messaging-5.0.0 org.axonframework.messaging.core core 50 80 0.625000
16 axon-common-5.0.0 org.axonframework.common.infra infra 5 8 0.625000
17 axon-server-connector-5.0.0 org.axonframework.axonserver.connector.event event 9 14 0.642857
18 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing.annotation.ref... reflection 4 6 0.666667
19 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.inte... interception 2 3 0.666667
20 axon-modelling-5.0.0 org.axonframework.modelling.configuration configuration 9 13 0.692308
21 axon-conversion-5.0.0 org.axonframework.conversion conversion 7 10 0.700000
22 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.repl... annotation 7 10 0.700000
23 axon-test-5.0.0 org.axonframework.test.fixture fixture 22 31 0.709677
24 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing eventsourcing 5 7 0.714286
25 axon-messaging-5.0.0 org.axonframework.messaging.core.interception.... annotation 8 11 0.727273
26 axon-messaging-5.0.0 org.axonframework.messaging.queryhandling.dist... distributed 8 11 0.727273
27 axon-server-connector-5.0.0 org.axonframework.axonserver.connector.query query 8 11 0.727273
28 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.anno... annotation 15 20 0.750000
29 axon-messaging-5.0.0 org.axonframework.messaging.commandhandling.an... annotation 9 12 0.750000
30 axon-metrics-micrometer-5.0.0 org.axonframework.extension.metrics.micrometer micrometer 9 12 0.750000
31 axon-messaging-5.0.0 org.axonframework.messaging.core.timeout timeout 6 8 0.750000
32 axon-messaging-5.0.0 org.axonframework.messaging.eventhandling.proc... token 6 8 0.750000
33 axon-common-5.0.0 org.axonframework.common.annotation annotation 3 4 0.750000
34 axon-messaging-5.0.0 org.axonframework.messaging.commandhandling.co... configuration 3 4 0.750000
35 axon-messaging-5.0.0 org.axonframework.messaging.queryhandling.conf... configuration 3 4 0.750000
36 axon-messaging-5.0.0 org.axonframework.messaging.core.unitofwork.tr... transaction 3 4 0.750000
37 axon-spring-boot-autoconfigure-5.0.0 org.axonframework.extension.springboot.service... connection 3 4 0.750000
38 axon-eventsourcing-5.0.0 org.axonframework.eventsourcing.eventstore eventstore 34 45 0.755556
39 axon-messaging-5.0.0 org.axonframework.messaging.core.retry retry 10 13 0.769231

Table 2 Chart 1 - Relative visibility of packages

/home/runner/miniconda3/envs/codegraph/lib/python3.12/site-packages/pandas/plotting/_matplotlib/core.py:1351: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  scatter = ax.scatter(



<Figure size 640x480 with 0 Axes>

png