Aar*_*esh 5 java performance builder javabeans
我目前正在使用 java bean 模型来构造具有许多参数的 POJO
例子:
Class Person {
// various fields
// the getters and setters for the fields
}
Run Code Online (Sandbox Code Playgroud)
所以为了构建 Person,我做
Person a = new Person();
// then setting all the fields(around 20) using the setters.
Run Code Online (Sandbox Code Playgroud)
现在我正在考虑切换到 java builder 模式来构建这些类型的数据持有者对象。我想在可读性方面,构建器模式更好。那么在效率和性能方面哪个更好?