Skip to content

Latest commit

 

History

History
1150 lines (1075 loc) · 27.8 KB

File metadata and controls

1150 lines (1075 loc) · 27.8 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-messaging-4.12.2 830 687 0.136364 1.000000 0.875651 0.771368 1.000000 1.000000 1.000000
1 axon-spring-boot-autoconfigure-4.12.2 91 77 0.682927 1.000000 0.948293 1.000000 1.000000 1.000000 1.000000
2 axon-tracing-opentelemetry-4.12.2 5 5 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
3 axon-server-connector-4.12.2 147 111 0.428571 1.000000 0.846062 0.770968 0.909091 1.000000 1.000000
4 axon-modelling-4.12.2 158 135 0.500000 1.000000 0.803352 0.737500 0.813187 0.889286 1.000000
5 axon-eventsourcing-4.12.2 133 98 0.500000 1.000000 0.771804 0.612903 0.785714 1.000000 1.000000
6 axon-test-4.12.2 87 65 0.473684 1.000000 0.781086 0.650000 0.775000 0.968750 1.000000
7 axon-configuration-4.12.2 43 30 0.697674 0.697674 0.697674 0.697674 0.697674 0.697674 0.697674
8 axon-disruptor-4.12.2 22 9 0.409091 0.409091 0.409091 0.409091 0.409091 0.409091 0.409091

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-disruptor-4.12.2 22 9 0.409091 0.409091 0.409091 0.409091 0.409091 0.409091 0.409091
1 axon-configuration-4.12.2 43 30 0.697674 0.697674 0.697674 0.697674 0.697674 0.697674 0.697674
2 axon-test-4.12.2 87 65 0.473684 1.000000 0.781086 0.650000 0.775000 0.968750 1.000000
3 axon-eventsourcing-4.12.2 133 98 0.500000 1.000000 0.771804 0.612903 0.785714 1.000000 1.000000
4 axon-modelling-4.12.2 158 135 0.500000 1.000000 0.803352 0.737500 0.813187 0.889286 1.000000
5 axon-server-connector-4.12.2 147 111 0.428571 1.000000 0.846062 0.770968 0.909091 1.000000 1.000000
6 axon-messaging-4.12.2 830 687 0.136364 1.000000 0.875651 0.771368 1.000000 1.000000 1.000000
7 axon-spring-boot-autoconfigure-4.12.2 91 77 0.682927 1.000000 0.948293 1.000000 1.000000 1.000000 1.000000
8 axon-tracing-opentelemetry-4.12.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-4.12.2 org.axonframework.modelling.saga saga 33 33 1.0
1 axon-spring-boot-autoconfigure-4.12.2 org.axonframework.springboot springboot 28 28 1.0
2 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.eventstore.jdb... statements 15 15 1.0
3 axon-messaging-4.12.2 org.axonframework.serialization.upcasting.event event 12 12 1.0
4 axon-messaging-4.12.2 org.axonframework.serialization.avro avro 11 11 1.0
5 axon-messaging-4.12.2 org.axonframework.lifecycle lifecycle 10 10 1.0
6 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.conflictresolu... conflictresolution 9 9 1.0
7 axon-messaging-4.12.2 org.axonframework.common.property property 9 9 1.0
8 axon-spring-boot-autoconfigure-4.12.2 org.axonframework.springboot.util util 9 9 1.0
9 axon-messaging-4.12.2 org.axonframework.messaging.interceptors interceptors 8 8 1.0
10 axon-messaging-4.12.2 org.axonframework.messaging.responsetypes responsetypes 8 8 1.0
11 axon-messaging-4.12.2 org.axonframework.commandhandling.distributed.... commandfilter 7 7 1.0
12 axon-messaging-4.12.2 org.axonframework.updates.configuration configuration 7 7 1.0
13 axon-messaging-4.12.2 org.axonframework.deadline.dbscheduler dbscheduler 7 7 1.0
14 axon-messaging-4.12.2 org.axonframework.eventhandling.scheduling.dbs... dbscheduler 7 7 1.0
15 axon-messaging-4.12.2 org.axonframework.serialization.json json 7 7 1.0
16 axon-messaging-4.12.2 org.axonframework.eventhandling.tokenstore tokenstore 7 7 1.0
17 axon-messaging-4.12.2 org.axonframework.serialization.xml xml 7 7 1.0
18 axon-messaging-4.12.2 org.axonframework.updates.api api 6 6 1.0
19 axon-messaging-4.12.2 org.axonframework.tracing.attributes attributes 6 6 1.0
20 axon-messaging-4.12.2 org.axonframework.eventhandling.scheduling.quartz quartz 6 6 1.0
21 axon-messaging-4.12.2 org.axonframework.serialization.upcasting upcasting 6 6 1.0
22 axon-messaging-4.12.2 org.axonframework.serialization.converters converters 5 5 1.0
23 axon-messaging-4.12.2 org.axonframework.eventhandling.gateway gateway 5 5 1.0
24 axon-messaging-4.12.2 org.axonframework.queryhandling.registration registration 5 5 1.0
25 axon-test-4.12.2 org.axonframework.test.eventscheduler eventscheduler 5 5 1.0
26 axon-tracing-opentelemetry-4.12.2 org.axonframework.tracing.opentelemetry opentelemetry 5 5 1.0
27 axon-messaging-4.12.2 org.axonframework.commandhandling.callbacks callbacks 4 4 1.0
28 axon-messaging-4.12.2 org.axonframework.messaging.correlation correlation 4 4 1.0
29 axon-messaging-4.12.2 org.axonframework.updates.detection detection 4 4 1.0
30 axon-messaging-4.12.2 org.axonframework.deadline.jobrunr jobrunr 4 4 1.0
31 axon-messaging-4.12.2 org.axonframework.common.jpa jpa 4 4 1.0
32 axon-messaging-4.12.2 org.axonframework.eventhandling.tokenstore.jpa jpa 4 4 1.0
33 axon-messaging-4.12.2 org.axonframework.common.legacyjpa legacyjpa 4 4 1.0
34 axon-messaging-4.12.2 org.axonframework.deadline.quartz quartz 4 4 1.0
35 axon-messaging-4.12.2 org.axonframework.updates updates 4 4 1.0
36 axon-test-4.12.2 org.axonframework.test.deadline deadline 4 4 1.0
37 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.snapshotting snapshotting 3 3 1.0
38 axon-messaging-4.12.2 org.axonframework.eventhandling.scheduling.job... jobrunr 3 3 1.0
39 axon-messaging-4.12.2 org.axonframework.eventhandling.scheduling scheduling 3 3 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-messaging-4.12.2 org.axonframework.eventhandling.pooled pooled 3 22 0.136364
1 axon-messaging-4.12.2 org.axonframework.eventhandling.deadletter deadletter 2 5 0.400000
2 axon-disruptor-4.12.2 org.axonframework.disruptor.commandhandling commandhandling 9 22 0.409091
3 axon-server-connector-4.12.2 org.axonframework.axonserver.connector.query query 9 21 0.428571
4 axon-test-4.12.2 org.axonframework.test.aggregate aggregate 9 19 0.473684
5 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.eventstore.leg... legacyjpa 5 10 0.500000
6 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.eventstore.inm... inmemory 1 2 0.500000
7 axon-messaging-4.12.2 org.axonframework.eventhandling.tokenstore.inm... inmemory 1 2 0.500000
8 axon-modelling-4.12.2 org.axonframework.modelling.saga.repository.in... inmemory 1 2 0.500000
9 axon-messaging-4.12.2 org.axonframework.commandhandling.gateway gateway 19 34 0.558824
10 axon-messaging-4.12.2 org.axonframework.common.caching caching 9 15 0.600000
11 axon-messaging-4.12.2 org.axonframework.eventhandling.replay replay 6 10 0.600000
12 axon-messaging-4.12.2 org.axonframework.deadline.annotation annotation 3 5 0.600000
13 axon-test-4.12.2 org.axonframework.test test 3 5 0.600000
14 axon-messaging-4.12.2 org.axonframework.eventhandling.async async 11 18 0.611111
15 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.eventstore eventstore 19 31 0.612903
16 axon-server-connector-4.12.2 org.axonframework.axonserver.connector.event.axon axon 21 32 0.656250
17 axon-test-4.12.2 org.axonframework.test.saga saga 14 21 0.666667
18 axon-messaging-4.12.2 org.axonframework.common.annotation annotation 2 3 0.666667
19 axon-messaging-4.12.2 org.axonframework.common.stream stream 2 3 0.666667
20 axon-modelling-4.12.2 org.axonframework.modelling.saga.repository.le... legacyjpa 2 3 0.666667
21 axon-spring-boot-autoconfigure-4.12.2 org.axonframework.springboot.autoconfig autoconfig 28 41 0.682927
22 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing eventsourcing 29 42 0.690476
23 axon-configuration-4.12.2 org.axonframework.config config 30 43 0.697674
24 axon-messaging-4.12.2 org.axonframework.messaging.unitofwork unitofwork 10 14 0.714286
25 axon-messaging-4.12.2 org.axonframework.common.lock lock 8 11 0.727273
26 axon-modelling-4.12.2 org.axonframework.modelling.saga.repository repository 11 15 0.733333
27 axon-messaging-4.12.2 org.axonframework.tracing tracing 14 19 0.736842
28 axon-server-connector-4.12.2 org.axonframework.axonserver.connector.util util 23 31 0.741935
29 axon-messaging-4.12.2 org.axonframework.messaging.timeout timeout 6 8 0.750000
30 axon-messaging-4.12.2 org.axonframework.queryhandling.annotation annotation 3 4 0.750000
31 axon-messaging-4.12.2 org.axonframework.eventhandling.scheduling.java java 3 4 0.750000
32 axon-messaging-4.12.2 org.axonframework.common.transaction transaction 3 4 0.750000
33 axon-modelling-4.12.2 org.axonframework.modelling.saga.metamodel metamodel 3 4 0.750000
34 axon-test-4.12.2 org.axonframework.test.server server 3 4 0.750000
35 axon-modelling-4.12.2 org.axonframework.modelling.command.inspection inspection 20 26 0.769231
36 axon-messaging-4.12.2 org.axonframework.deadline deadline 10 13 0.769231
37 axon-messaging-4.12.2 org.axonframework.messaging.annotation annotation 42 54 0.777778
38 axon-eventsourcing-4.12.2 org.axonframework.eventsourcing.eventstore.jdbc jdbc 11 14 0.785714
39 axon-server-connector-4.12.2 org.axonframework.axonserver.connector.heartbeat heartbeat 4 5 0.800000

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