Having too many class definitions in Java can be unreadable

Software AgilityCode Readability

Having too many class definitions in Java can be unreadable

This code insight counts one violation each time a ternary operator is encountered.

Note : Do not confuse with question mark used as wildcard for unknow generic type.


String data = (str.contains(“A”) ? “Str contains ‘A'” : “Str doesn’t contains ‘A'”);


void process(List<? extends Foo> list) {…}

public static void printList(List<?> list) {
for (Object elem: list)
System.out.print(elem + ” “);


Why you should care

Class definitions are an integral aspect of coding however having too many of them can cause readability issues which results in losing time and wasting effort amongst developers that are collaborating.  It can also cause bugs and other type of risks because of increased presence of class definitions.

Business Impacts

It is recommended to avoid these in order to ensure the code is more readable and cost effective.

CostTime / Effort

CAST recommendations



About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

See featuresHow it works