Skip to content

Check: Program to Interface, Not Implementation

Madeline Kahn edited this page Mar 11, 2024 · 2 revisions
  • Name: "programToInterface"
  • Default: Enabled

Configuration

Name Type Description
domainPackageName String Name of the domain package (default is "domain").
adapterClassNameRegex String Regular expression for adapter class names, to exempt from this check (default is "Adapter$").
allowedDependencies String[] List of user-specified allowed dependencies (add known interfaces and/or data classes here).

Description

For each class in the domain package, generates a warning if any field types, method return types, or method parameter types do not meet at least one of the following criteria for acceptable dependencies:

  • Type is also defined in the domain package.
  • Type is a primitive, or a class representing a primitive.
  • Type is an interface/enum defined within the project. (Interfaces defined elsewhere cannot be automatically detected; please add them to allowedDependencies to suppress warnings).
  • Type is Object.
  • Type is one of a few popular data structure interfaces.
  • Type is in the user-configured allowedDependencies.

Adapter classes (as specified by adapterClassNameRegex) are ignored.