How should I structure a Java application, where do I put my classes?

后端 未结 10 1448
轻奢々
轻奢々 2020-12-24 05:17

First of all, I know how to build a Java application. But I have always been puzzled about where to put my classes. There are proponents for organizing the packages in a str

10条回答
  •  时光取名叫无心
    2020-12-24 06:06

    Class names should always be descriptive and self-explanatory. If you have multiple domains of responsibility for your classes then they should probably be refactored.

    Likewise for you packages. They should be grouped by domain of responsibility. Every domain has it's own exceptions.

    Generally don't sweat it until you get to a point where it is becoming overwhelming and bloated. Then sit down and don't code, just refactor the classes out, compiling regularly to make sure everything works. Then continue as you did before.

提交回复
热议问题