Java – what is a good habit of combining classes

Do not save all my courses in a single SRC – > 'package'_ Name 'folder I'm creating different sub packages to separate my classes according to groups, such as - utilities, models, activities themselves, etc I'm not sure if this is a good practice, and people do it in real projects

Solution

Yes, it is absolutely standard practice to package classes It's good to establish a convention on how to separate them so that they can be found more easily in the future Two common methods:

>Put things into packages according to their contents: models, services, data access (DAO), etc. > Put the content into the package according to the functions they support (for example, Java. IO, Java. Security, etc.)

I have used both and continue to return to the former because it is not so subjective (it is always clear whether a class is a model or a service, but it is not always clear whether it supports one function or another)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>