WebSphere Application Server & Liberty

 View Only

Consideration of class dependencies when refactoring with Mono2Micro

By Tiaoyu Wang posted Wed October 13, 2021 03:27 PM

One of the keys to successfully transforming monolithic applications to microservices is to efficiently partition classes with consideration of existing dependencies in code.  A key type of class dependency is when one class contains another class as a class-level variable. This dependency impacts the state of the containing class which has implications when these classes are placed in different partitions. IBM® Mono2Micro™ helps to visually identify these kinds of class containment dependencies in the UI where the AI's recommendations of the partitions are viewed.

In the previous 21.0.06 release of Mono2Micro, we introduced a way for users to view class containment dependencies for a single selected class in any partition. Once selected, if that class had any containment relationships with other classes a dashed line would be shown either pointing to it (which means this class was being contained by another class), or pointing away from it to another class (which means this class contains that other class).  In the recent 21.0.09 release, we have enhanced this feature to see all existing class containment relationships at once in any view you happen to be in (business logic, natural seams, or custom).

The following is an example of viewing class containment dependencies in the Business Logic view of DayTrader application (Containment Dependencies toggle button is On):

Class containment dependencies in Business Logic view

There is a cross partition dependency shown where HoldingDataBean in partition3 has various class dependency relationships with classes in partition2.

Next is an example of the Natural Seams view in the same DayTrader application:


Class containment dependencies in the Natural Seams view

In this view, we clearly see that are no longer class containment dependencies that cross partitions.  HoldingDataBean and its dependencies are all in partition1.  This is to be expected since Mono2Micro considers class containment dependencies in addition to observed use case runs when partitioning for natural seams.

Being able to see all existing class containment dependencies is a very useful way for users to verify the efficiency of the class partitioning and schemes that Mono2Micro's AI employs for your application.