Comments (3)
谢谢建议。很多数据其实是松散的,难以归类的,我还没有想到一个比较合适的写法。需要一点时间来思考一下。
from common-random.
谢谢建议。很多数据其实是松散的,难以归类的,我还没有想到一个比较合适的写法。需要一点时间来思考一下。
嗯,好的。归类暂时可以不做,保持现状就行。后面有更好的想法了再优化归类也可以。
我的意思是增加一个如下入口类:RandomSource,大概如下:
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);然后再获取对应资源类的实例后才可以获取数据。
不知道我表达得是否清楚。
from common-random.
谢谢建议。很多数据其实是松散的,难以归类的,我还没有想到一个比较合适的写法。需要一点时间来思考一下。
嗯,好的。归类暂时可以不做,保持现状就行。后面有更好的想法了再优化归类也可以。 我的意思是增加一个如下入口类:RandomSource,大概如下:
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);然后再获取对应资源类的实例后才可以获取数据。
不知道我表达得是否清楚。
最终还是要看源码啊。不过谢谢你的建议,我后续加上。
from common-random.
Related Issues (13)
- 报错java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Font; HOT 1
- 功能建议:建议做成简单的RESTful API的形式,方便第三方调用 HOT 4
- Android需要添加implementation HOT 1
- 非常不错,一个符合**国情的模拟数据生成,建议发布到maven**仓库 HOT 2
- 很好的工具,希望加个随机民族 HOT 2
- 随机邮箱逻辑似乎搞反了? HOT 1
- 引用存在漏洞依赖包jackson-databind HOT 1
- 随机日期、时间,能否增加返回Date类型的api HOT 1
- 可否增加一个生成银行卡号 HOT 2
- 虚拟网络昵称 乱码 HOT 3
- 请问汉语词汇数据是在哪里找的呢? HOT 4
- 虚拟地址,可以考虑把 randomAddress(nextArea()); 作为公开方法
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from common-random.