How to define design rules for Java classes?

I want to define some design rules for a medium-sized project being developed by a team. These rules are not like the ifstatement rule should use parentheses. "They are related to design.

Examples of rules:

  • If a class has an association with a JPA class, it should not have any association with a GUI class.
  • There Messagemust be a subclass for each subclass Serializer.
  • If a class is marked as DTO, it should only have getter and setter methods.

Is there a way to define rules like exemplary and check compile time?

thank

+4
source share
3 answers

, . .

, , , , . , :

  • @IsJPA, JPA.
    @IsGUI, GUI.
    @IsJPA @IsGUI.

  • @IsMessage , Serializer

  • @IsDTO , getter setter.

+1

:

JPA, GUI.

, . , classycle , structure101.

0

Sonar .

, , , .

Java 101

Sonarqube . , SonarLint ( Eclipse Intelli-J).

And Sonar is free and easy to set up. (but for implementing custom rules, this will depend on the complexity of the rules)

0
source

Source: https://habr.com/ru/post/1657358/


All Articles