什么是一个很好的做法,你的类合并 [英] What is a good practice to combine your classes
问题描述
不要把我所有的班在一个单一的SRC - >程序包文件夹我创建不同的子包,以便通过类似团体我的班分开 - 实用工具,模型,活动本身,等我不知道这是一个很好的做法,人们做相同的实际项目。
Not to keep all my classes in a single src -> 'package_name' folder I'm creating different sub-packages in order to separate my classes by groups like - utilities, models, activities themselves, etc. I'm not sure if it is a good practice and people do the same in real projects.
推荐答案
是的,这绝对是标准的做法,你的类分成包。这是很好的建立它们的分隔方式,以方便以后找东西的约定。两种常见的方法:
Yes, it's definitely standard practice to separate your classes into packages. It's good to establish a convention for how they are separated, to make it easier to find things later. Two common approaches:
- 把东西放到基于包它们是什么:模式,服务,数据访问(DAO)等
- 基础上,他们支持什么功能(例如,java.io,java.security等把东西放进包。
我用两个,并保持回来前,因为它不太主观的(它总是清楚一个类是否是一个模型或服务,但并不总是清楚是否支持一个或另一个函数功能)。
I've used both and keep coming back to the former because it's less subjective (it's always clear whether a class is a model or a service, but not always clear whether it supports one function or another function).
这篇关于什么是一个很好的做法,你的类合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!