Comments (2)
Builder를 자주 사용하시는 편인가요?
저는 매개변수가 3개 이상이 되면 거의 무조건 Builder 패턴을 사용하고 있어요.
Builder를 사용하였을때 해당 클래스의 추가로 필드가 생성되면, Builder를 사용하고 있던 모든곳에서 수정을 해주어야 하죠, 이 과정에서 놓친 부분에서는 Builder에서 값이 채워지지 않은 null 상태로 들어가게 되는데 다들 이러한 문제는 어떻게 생각하시는지 궁금합니다.
사용할 때마다 모두 수정해줍니다😢
from effective-java-study.
저는 prop 과 같은 방법으로 좀더 자바스크립트스러운? 구현을 선호합니다.
private MongoClient connClient(String prefix, boolean isPrimary) {
if (props == null) {
return null;
}
String host = props.getProperty("mongodb." + prefix + ".server");
int port = props.getProperty("mongodb." + prefix + ".port", Integer.class, 27017);
String username = props.getProperty("mongodb." + prefix + ".username");
String password = props.getProperty("mongodb." + prefix + ".password");
String database = props.getProperty("mongodb." + prefix + ".database");
from effective-java-study.
Related Issues (20)
- [Item58] 전통적인 for 문보다는 for-each 문을 사용하라
- [Item59] 라이브러리를 익히고 사용하라
- [Item60] 정확한 답이 필요하다면 float와 double은 피하라
- [Item61] 박싱된 기본 타입보다는 기본 타입을 사용하라
- [Item62] 다른 타입이 적절하다면 문자열 사용을 피하라
- [Item63] 문자열 연결은 느리니 주의하라
- [Item64] 객체는 인터페이스를 사용해 참조하라
- [Item65] 리플렉션보다는 인터페이스를 사용하라
- [Item66] 네이티브 메서드는 신중히 사용하라 HOT 1
- [Item67] 최적화는 신중히 하라
- [Item68] 일반적으로 통용되는 명명 규칙을 따르라
- [Item69] 예외는 진짜 예외 상황에만 사용하라
- [Item70] 복구할 수 있는 상황에는 검사 예외를, 프로그래밍 오류에는 런타임 예외를 사용하라
- [Item71] 필요 없는 검사 예외 사용은 피하라
- [Item72] 표준 예외를 사용하라
- [Item73] 추상화 수준에 맞는 예외를 던지라
- [Item74] 메서드가 던지는 모든 예외를 문서화하라
- [Item75] 예외의 상세 메시지에 실패 관련 정보를 담으라
- [Item76] 가능한 한 실패 원자적으로 만들라
- [Item77] 예외를 무시하지 말라
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 effective-java-study.