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.3 156 129 0.615385 1.000000 0.893102 0.791304 1.000000 1.000000 1.000000
1 axon-spring-boot-autoconfigure-5.0.3 75 53 0.512195 1.000000 0.887081 0.848684 1.000000 1.000000 1.000000
2 axon-conversion-5.0.3 35 32 0.700000 1.000000 0.940000 1.000000 1.000000 1.000000 1.000000
3 axon-update-5.0.3 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
4 axon-tracing-opentelemetry-5.0.3 5 5 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
5 axon-modelling-5.0.3 92 84 0.692308 1.000000 0.901923 0.860577 0.900000 1.000000 1.000000
6 axon-messaging-5.0.3 579 439 0.250000 1.000000 0.802085 0.727273 0.842105 1.000000 1.000000
7 axon-server-connector-5.0.3 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
8 axon-test-5.0.3 78 63 0.600000 1.000000 0.809768 0.726562 0.791667 0.925725 0.978261
9 axon-metrics-micrometer-5.0.3 16 12 0.727273 1.000000 0.825758 0.738636 0.750000 0.875000 0.950000
10 axon-eventsourcing-5.0.3 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.3 100 66 0.200000 0.900000 0.599721 0.480769 0.666667 0.734921 0.813333
1 axon-metrics-micrometer-5.0.3 16 12 0.727273 1.000000 0.825758 0.738636 0.750000 0.875000 0.950000
2 axon-test-5.0.3 78 63 0.600000 1.000000 0.809768 0.726562 0.791667 0.925725 0.978261
3 axon-server-connector-5.0.3 72 58 0.642857 0.892857 0.788495 0.727273 0.833333 0.846154 0.874176
4 axon-messaging-5.0.3 579 439 0.250000 1.000000 0.802085 0.727273 0.842105 1.000000 1.000000
5 axon-modelling-5.0.3 92 84 0.692308 1.000000 0.901923 0.860577 0.900000 1.000000 1.000000
6 axon-common-5.0.3 156 129 0.615385 1.000000 0.893102 0.791304 1.000000 1.000000 1.000000
7 axon-spring-boot-autoconfigure-5.0.3 75 53 0.512195 1.000000 0.887081 0.848684 1.000000 1.000000 1.000000
8 axon-conversion-5.0.3 35 32 0.700000 1.000000 0.940000 1.000000 1.000000 1.000000 1.000000
9 axon-update-5.0.3 23 23 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
10 axon-tracing-opentelemetry-5.0.3 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.3 org.axonframework.modelling.entity.annotation annotation 18 18 1.0
1 axon-modelling-5.0.3 org.axonframework.modelling modelling 16 16 1.0
2 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.conf... configuration 14 14 1.0
3 axon-modelling-5.0.3 org.axonframework.modelling.entity.child child 14 14 1.0
4 axon-common-5.0.3 org.axonframework.common.jdbc jdbc 12 12 1.0
5 axon-messaging-5.0.3 org.axonframework.messaging.core.sequencing sequencing 11 11 1.0
6 axon-conversion-5.0.3 org.axonframework.conversion.avro avro 10 10 1.0
7 axon-common-5.0.3 org.axonframework.common.property property 9 9 1.0
8 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... jdbc 9 9 1.0
9 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.tracing tracing 7 7 1.0
10 axon-messaging-5.0.3 org.axonframework.messaging.queryhandling.tracing tracing 7 7 1.0
11 axon-spring-boot-autoconfigure-5.0.3 org.axonframework.extension.springboot.util util 7 7 1.0
12 axon-update-5.0.3 org.axonframework.update.configuration configuration 7 7 1.0
13 axon-common-5.0.3 org.axonframework.common.util util 6 6 1.0
14 axon-messaging-5.0.3 org.axonframework.messaging.tracing.attributes attributes 6 6 1.0
15 axon-messaging-5.0.3 org.axonframework.messaging.core.correlation correlation 6 6 1.0
16 axon-update-5.0.3 org.axonframework.update.api api 6 6 1.0
17 axon-common-5.0.3 org.axonframework.common.lifecycle lifecycle 5 5 1.0
18 axon-conversion-5.0.3 org.axonframework.conversion.converter converter 5 5 1.0
19 axon-conversion-5.0.3 org.axonframework.conversion.jackson jackson 5 5 1.0
20 axon-conversion-5.0.3 org.axonframework.conversion.jackson2 jackson2 5 5 1.0
21 axon-messaging-5.0.3 org.axonframework.messaging.monitoring.interce... interception 5 5 1.0
22 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... store 5 5 1.0
23 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... subscribing 5 5 1.0
24 axon-tracing-opentelemetry-5.0.3 org.axonframework.extension.tracing.opentelemetry opentelemetry 5 5 1.0
25 axon-update-5.0.3 org.axonframework.update update 5 5 1.0
26 axon-common-5.0.3 org.axonframework.common.jpa jpa 4 4 1.0
27 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... jpa 4 4 1.0
28 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.replay replay 4 4 1.0
29 axon-update-5.0.3 org.axonframework.update.detection detection 4 4 1.0
30 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... errorhandling 3 3 1.0
31 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... processing 3 3 1.0
32 axon-messaging-5.0.3 org.axonframework.messaging.core.configuration... reflection 3 3 1.0
33 axon-common-5.0.3 org.axonframework.common.function function 2 2 1.0
34 axon-messaging-5.0.3 org.axonframework.messaging.core.configuration configuration 2 2 1.0
35 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.conv... conversion 2 2 1.0
36 axon-messaging-5.0.3 org.axonframework.messaging.core.conversion conversion 2 2 1.0
37 axon-messaging-5.0.3 org.axonframework.messaging.queryhandling.gateway gateway 2 2 1.0
38 axon-messaging-5.0.3 org.axonframework.messaging.core.reflection reflection 2 2 1.0
39 axon-spring-boot-autoconfigure-5.0.3 org.axonframework.extension.springboot.actuato... axonserver 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.3 org.axonframework.eventsourcing.eventstore.inm... inmemory 1 5 0.200000
1 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... pooled 6 24 0.250000
2 axon-messaging-5.0.3 org.axonframework.messaging.queryhandling.inte... interception 2 8 0.250000
3 axon-messaging-5.0.3 org.axonframework.messaging.monitoring.configu... configuration 3 9 0.333333
4 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... inmemory 1 3 0.333333
5 axon-eventsourcing-5.0.3 org.axonframework.eventsourcing.eventstore.jpa jpa 6 13 0.461538
6 axon-messaging-5.0.3 org.axonframework.messaging.core.interception interception 10 21 0.476190
7 axon-eventsourcing-5.0.3 org.axonframework.eventsourcing.configuration configuration 7 14 0.500000
8 axon-messaging-5.0.3 org.axonframework.messaging.commandhandling.in... interception 3 6 0.500000
9 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... annotation 1 2 0.500000
10 axon-messaging-5.0.3 org.axonframework.messaging.core.unitofwork.an... annotation 1 2 0.500000
11 axon-messaging-5.0.3 org.axonframework.messaging.core.unitofwork.tr... jdbc 1 2 0.500000
12 axon-messaging-5.0.3 org.axonframework.messaging.core.unitofwork.tr... jpa 1 2 0.500000
13 axon-spring-boot-autoconfigure-5.0.3 org.axonframework.extension.springboot.autoconfig autoconfig 21 41 0.512195
14 axon-messaging-5.0.3 org.axonframework.messaging.eventstreaming eventstreaming 9 16 0.562500
15 axon-test-5.0.3 org.axonframework.test test 3 5 0.600000
16 axon-common-5.0.3 org.axonframework.common.caching caching 8 13 0.615385
17 axon-messaging-5.0.3 org.axonframework.messaging.core core 50 80 0.625000
18 axon-common-5.0.3 org.axonframework.common.infra infra 5 8 0.625000
19 axon-server-connector-5.0.3 org.axonframework.axonserver.connector.event event 9 14 0.642857
20 axon-eventsourcing-5.0.3 org.axonframework.eventsourcing.annotation.ref... reflection 4 6 0.666667
21 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.inte... interception 2 3 0.666667
22 axon-modelling-5.0.3 org.axonframework.modelling.configuration configuration 9 13 0.692308
23 axon-conversion-5.0.3 org.axonframework.conversion conversion 7 10 0.700000
24 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.repl... annotation 7 10 0.700000
25 axon-eventsourcing-5.0.3 org.axonframework.eventsourcing eventsourcing 5 7 0.714286
26 axon-test-5.0.3 org.axonframework.test.fixture fixture 23 32 0.718750
27 axon-messaging-5.0.3 org.axonframework.messaging.commandhandling.an... annotation 8 11 0.727273
28 axon-messaging-5.0.3 org.axonframework.messaging.core.interception.... annotation 8 11 0.727273
29 axon-messaging-5.0.3 org.axonframework.messaging.queryhandling.dist... distributed 8 11 0.727273
30 axon-metrics-micrometer-5.0.3 org.axonframework.extension.metrics.micrometer micrometer 8 11 0.727273
31 axon-server-connector-5.0.3 org.axonframework.axonserver.connector.query query 8 11 0.727273
32 axon-messaging-5.0.3 org.axonframework.messaging.core.timeout timeout 6 8 0.750000
33 axon-messaging-5.0.3 org.axonframework.messaging.eventhandling.proc... token 6 8 0.750000
34 axon-common-5.0.3 org.axonframework.common.annotation annotation 3 4 0.750000
35 axon-messaging-5.0.3 org.axonframework.messaging.commandhandling.co... configuration 3 4 0.750000
36 axon-messaging-5.0.3 org.axonframework.messaging.queryhandling.conf... configuration 3 4 0.750000
37 axon-metrics-micrometer-5.0.3 org.axonframework.extension.metrics.micrometer... springboot 3 4 0.750000
38 axon-spring-boot-autoconfigure-5.0.3 org.axonframework.extension.springboot.service... connection 3 4 0.750000
39 axon-test-5.0.3 org.axonframework.test.extension extension 3 4 0.750000

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