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.2 156 129 0.615385 1.000000 0.893102 0.791304 1.000000 1.000000 1.000000
1 axon-spring-boot-autoconfigure-5.0.2 72 55 0.571429 1.000000 0.896568 0.852273 1.000000 1.000000 1.000000
2 axon-conversion-5.0.2 30 27 0.700000 1.000000 0.925000 0.925000 1.000000 1.000000 1.000000
3 axon-update-5.0.2 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
4 axon-tracing-opentelemetry-5.0.2 5 5 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
5 axon-modelling-5.0.2 93 85 0.692308 1.000000 0.903907 0.867521 0.900000 1.000000 1.000000
6 axon-metrics-micrometer-5.0.2 13 10 0.750000 1.000000 0.875000 0.812500 0.875000 0.937500 0.975000
7 axon-messaging-5.0.2 570 432 0.250000 1.000000 0.809057 0.750000 0.846154 1.000000 1.000000
8 axon-test-5.0.2 73 59 0.600000 1.000000 0.819906 0.709677 0.833333 0.956522 0.982609
9 axon-server-connector-5.0.2 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
10 axon-eventsourcing-5.0.2 104 68 0.200000 0.900000 0.587897 0.491667 0.583333 0.724603 0.798889

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.2 104 68 0.200000 0.900000 0.587897 0.491667 0.583333 0.724603 0.798889
1 axon-test-5.0.2 73 59 0.600000 1.000000 0.819906 0.709677 0.833333 0.956522 0.982609
2 axon-server-connector-5.0.2 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
3 axon-messaging-5.0.2 570 432 0.250000 1.000000 0.809057 0.750000 0.846154 1.000000 1.000000
4 axon-metrics-micrometer-5.0.2 13 10 0.750000 1.000000 0.875000 0.812500 0.875000 0.937500 0.975000
5 axon-modelling-5.0.2 93 85 0.692308 1.000000 0.903907 0.867521 0.900000 1.000000 1.000000
6 axon-common-5.0.2 156 129 0.615385 1.000000 0.893102 0.791304 1.000000 1.000000 1.000000
7 axon-spring-boot-autoconfigure-5.0.2 72 55 0.571429 1.000000 0.896568 0.852273 1.000000 1.000000 1.000000
8 axon-conversion-5.0.2 30 27 0.700000 1.000000 0.925000 0.925000 1.000000 1.000000 1.000000
9 axon-update-5.0.2 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
10 axon-tracing-opentelemetry-5.0.2 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-modelling-5.0.2 org.axonframework.modelling.entity.annotation annotation 18 18 1.0
1 axon-modelling-5.0.2 org.axonframework.modelling modelling 16 16 1.0
2 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.conf... configuration 14 14 1.0
3 axon-modelling-5.0.2 org.axonframework.modelling.entity.child child 14 14 1.0
4 axon-common-5.0.2 org.axonframework.common.jdbc jdbc 12 12 1.0
5 axon-conversion-5.0.2 org.axonframework.conversion.avro avro 10 10 1.0
6 axon-common-5.0.2 org.axonframework.common.property property 9 9 1.0
7 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... jdbc 9 9 1.0
8 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.sequ... sequencing 9 9 1.0
9 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.tracing tracing 7 7 1.0
10 axon-messaging-5.0.2 org.axonframework.messaging.queryhandling.tracing tracing 7 7 1.0
11 axon-spring-boot-autoconfigure-5.0.2 org.axonframework.extension.springboot.util util 7 7 1.0
12 axon-update-5.0.2 org.axonframework.update.configuration configuration 7 7 1.0
13 axon-common-5.0.2 org.axonframework.common.util util 6 6 1.0
14 axon-messaging-5.0.2 org.axonframework.messaging.tracing.attributes attributes 6 6 1.0
15 axon-messaging-5.0.2 org.axonframework.messaging.core.correlation correlation 6 6 1.0
16 axon-update-5.0.2 org.axonframework.update.api api 6 6 1.0
17 axon-common-5.0.2 org.axonframework.common.lifecycle lifecycle 5 5 1.0
18 axon-conversion-5.0.2 org.axonframework.conversion.converter converter 5 5 1.0
19 axon-conversion-5.0.2 org.axonframework.conversion.json json 5 5 1.0
20 axon-messaging-5.0.2 org.axonframework.messaging.monitoring.interce... interception 5 5 1.0
21 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... store 5 5 1.0
22 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... subscribing 5 5 1.0
23 axon-tracing-opentelemetry-5.0.2 org.axonframework.extension.tracing.opentelemetry opentelemetry 5 5 1.0
24 axon-update-5.0.2 org.axonframework.update update 5 5 1.0
25 axon-common-5.0.2 org.axonframework.common.jpa jpa 4 4 1.0
26 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... jpa 4 4 1.0
27 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.replay replay 4 4 1.0
28 axon-update-5.0.2 org.axonframework.update.detection detection 4 4 1.0
29 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... errorhandling 3 3 1.0
30 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... processing 3 3 1.0
31 axon-messaging-5.0.2 org.axonframework.messaging.core.configuration... reflection 3 3 1.0
32 axon-common-5.0.2 org.axonframework.common.function function 2 2 1.0
33 axon-messaging-5.0.2 org.axonframework.messaging.core.configuration configuration 2 2 1.0
34 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.conv... conversion 2 2 1.0
35 axon-messaging-5.0.2 org.axonframework.messaging.core.conversion conversion 2 2 1.0
36 axon-messaging-5.0.2 org.axonframework.messaging.queryhandling.gateway gateway 2 2 1.0
37 axon-messaging-5.0.2 org.axonframework.messaging.core.reflection reflection 2 2 1.0
38 axon-spring-boot-autoconfigure-5.0.2 org.axonframework.extension.springboot.actuato... axonserver 2 2 1.0
39 axon-test-5.0.2 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.2 org.axonframework.eventsourcing.eventstore.inm... inmemory 1 5 0.200000
1 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... pooled 6 24 0.250000
2 axon-messaging-5.0.2 org.axonframework.messaging.monitoring.configu... configuration 2 8 0.250000
3 axon-messaging-5.0.2 org.axonframework.messaging.queryhandling.inte... interception 2 8 0.250000
4 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... inmemory 1 3 0.333333
5 axon-messaging-5.0.2 org.axonframework.messaging.commandhandling.in... interception 2 5 0.400000
6 axon-messaging-5.0.2 org.axonframework.messaging.core.interception interception 8 19 0.421053
7 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing.eventstore.jpa jpa 7 15 0.466667
8 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing.configuration configuration 7 14 0.500000
9 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing.eventstore.jdbc jdbc 1 2 0.500000
10 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... annotation 1 2 0.500000
11 axon-messaging-5.0.2 org.axonframework.messaging.core.unitofwork.an... annotation 1 2 0.500000
12 axon-messaging-5.0.2 org.axonframework.messaging.eventstreaming eventstreaming 9 16 0.562500
13 axon-spring-boot-autoconfigure-5.0.2 org.axonframework.extension.springboot.autoconfig autoconfig 20 35 0.571429
14 axon-test-5.0.2 org.axonframework.test test 3 5 0.600000
15 axon-common-5.0.2 org.axonframework.common.caching caching 8 13 0.615385
16 axon-messaging-5.0.2 org.axonframework.messaging.core core 50 80 0.625000
17 axon-common-5.0.2 org.axonframework.common.infra infra 5 8 0.625000
18 axon-server-connector-5.0.2 org.axonframework.axonserver.connector.event event 9 14 0.642857
19 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing.annotation.ref... reflection 4 6 0.666667
20 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.inte... interception 2 3 0.666667
21 axon-modelling-5.0.2 org.axonframework.modelling.configuration configuration 9 13 0.692308
22 axon-conversion-5.0.2 org.axonframework.conversion conversion 7 10 0.700000
23 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.repl... annotation 7 10 0.700000
24 axon-test-5.0.2 org.axonframework.test.fixture fixture 22 31 0.709677
25 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing eventsourcing 5 7 0.714286
26 axon-messaging-5.0.2 org.axonframework.messaging.core.interception.... annotation 8 11 0.727273
27 axon-messaging-5.0.2 org.axonframework.messaging.queryhandling.dist... distributed 8 11 0.727273
28 axon-server-connector-5.0.2 org.axonframework.axonserver.connector.query query 8 11 0.727273
29 axon-messaging-5.0.2 org.axonframework.messaging.commandhandling.an... annotation 9 12 0.750000
30 axon-metrics-micrometer-5.0.2 org.axonframework.extension.metrics.micrometer micrometer 9 12 0.750000
31 axon-messaging-5.0.2 org.axonframework.messaging.core.timeout timeout 6 8 0.750000
32 axon-messaging-5.0.2 org.axonframework.messaging.eventhandling.proc... token 6 8 0.750000
33 axon-common-5.0.2 org.axonframework.common.annotation annotation 3 4 0.750000
34 axon-messaging-5.0.2 org.axonframework.messaging.commandhandling.co... configuration 3 4 0.750000
35 axon-messaging-5.0.2 org.axonframework.messaging.queryhandling.conf... configuration 3 4 0.750000
36 axon-spring-boot-autoconfigure-5.0.2 org.axonframework.extension.springboot.service... connection 3 4 0.750000
37 axon-eventsourcing-5.0.2 org.axonframework.eventsourcing.eventstore eventstore 34 45 0.755556
38 axon-messaging-5.0.2 org.axonframework.messaging.core.retry retry 10 13 0.769231
39 axon-common-5.0.2 org.axonframework.common.configuration configuration 36 46 0.782609

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