-
Notifications
You must be signed in to change notification settings - Fork 127
建议增加一个统一入口类 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
谢谢建议。很多数据其实是松散的,难以归类的,我还没有想到一个比较合适的写法。需要一点时间来思考一下。 |
嗯,好的。归类暂时可以不做,保持现状就行。后面有更好的想法了再优化归类也可以。 public class RandomSource {
public EducationSource education() {
return EducationSource.getInstance();
}
public PersonInfoSource person() {
return PersonInfoSource.getInstance();
}
// 获取其他资源类……
} 当我需要造假数据时,我只需要这样: RandomSource randomSource = new RandomSource();
// 随机学校名字
String schoolName = randomSource.education().randomHighSchoolName();
// 随机人名
String personName = randomSource.person().randomChineseName();
这样的好处是:使用者只需要记住RandomSource这个主类即可。后面不管增加多少资源类,都可以依赖IDEA的提示功能,知道有哪些资源,然后按需调用即可。参考同类框架组件:Faker.java 而现在,因为没有统一的入口类;我需要去查看文档到底有哪些资源类(EducationSource、PersonInfoSource);然后再获取对应资源类的实例后才可以获取数据。 不知道我表达得是否清楚。 |
最终还是要看源码啊。不过谢谢你的建议,我后续加上。 |
看到这个框架感觉很惊喜,使用效果也非常好。
但使用过程也碰到了一点小小的问题:
第一次使用时,不知道该使用哪个类生成什么样的数据。这点可以通过查找文档解决,但还是有点麻烦。
所以我建议,能否个Java Faker那样增加一个总的入口类(Faker),比如叫RandomSource,由此类可以获取到com.apifan.common.random 包下的所有资源类;这样在IDEA强大的提示功能下,即使是初次使用的人,也可以大大减少查找文档,提高效率。
以上,仅个人愚见。
The text was updated successfully, but these errors were encountered: