Why is java:S1610 deprecated

Hello support!

I would like to know what was the rationale behind the deprecation of the java:S1610 rule (Abstract classes without fields should be converted to interfaces). I looked around but was not able to find any explanations or replacement rules.

Thanks a lot for your help!

Best regards,

Sophie

Hey Sophie,

When reviewing S1610, we realized some conceptual problems with this rule. Basically, default interface methods are just there to have multiple inheritance also with method implementations, not only API definitions. I.e., an abstract class can implement methods, but you cannot inherit from multiple abstract classes. Default methods solve this problem but at the cost of mixing interface and implementation.

Developers should, therefore, not be forced to replace abstract classes with interfaces and default methods. Maybe they want this clean separation between API and implementation. It should be their design decision.

There are also other possible reasons why a developer might want to keep an abstract class, for example, when they work with tools or frameworks that require it to be a class or to provide an extendable class in a public API with a clean inheritance hierarchy.

Best,
Marco

Hey Marco,

Thank you for your detailed and clear answer!

Best regards,

Sophie

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.