Lack of Cohesion of Methods (LCOM) is a measure of cohesiveness of a class. The low LCOM value means the methods in a class is authored to achieve a common goal. Thus, a low LCOM value is desirable as it indicates good encapsulation. LCOM is measured in percent (%).

Default Threshold77%

Example:

LCOM for class ‘ClusterInformation’ in below code is 50 which is within the default threshold.

package org.apache.flink.runtime.entrypoint;

import org.apache.flink.util.Preconditions;

import java.io.Serializable;

/**
 * Information about the cluster which is shared with the cluster components.
 */
public class ClusterInformation implements Serializable {

  private static final long serialVersionUID = 316958921518479205L;

  private final String blobServerHostname;

  private final int blobServerPort;

  public ClusterInformation(String blobServerHostname, int blobServerPort) {
    this.blobServerHostname = Preconditions.checkNotNull(blobServerHostname);
    Preconditions.checkArgument(
      0 < blobServerPort && blobServerPort < 65_536,
      "The blob port must between 0 and 65_536. However, it was " + blobServerPort + '.');
    this.blobServerPort = blobServerPort;
  }

  public String getBlobServerHostname() {
    return blobServerHostname;
  }

  public int getBlobServerPort() {
    return blobServerPort;
  }

  @Override
  public String toString() {
    return "ClusterInformation{" +
      "blobServerHostname='" + blobServerHostname + ''' +
      ", blobServerPort=" + blobServerPort +
      '}';
  }
}