-
Notifications
You must be signed in to change notification settings - Fork 6
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
3주차 과제(박민규) #18
base: main
Are you sure you want to change the base?
3주차 과제(박민규) #18
Conversation
allApplicantNum.put("PG", 0); | ||
allApplicantNum.put("PM", 0); | ||
allApplicantNum.put("DE", 0); | ||
|
||
// value = Registration | ||
for (String key : allRegistration.keySet()){ | ||
Registration registration = allRegistration.get(key); | ||
allApplicantNum.put(registration.getHopeField(), allApplicantNum.get(registration.getHopeField()) + 1); | ||
} | ||
|
||
// WEB, APP, AI, GAME | ||
// key = firstPriority, secondPriority | ||
Map<String, int[]> allApplicantPriority = new HashMap<>(); | ||
|
||
allApplicantPriority.put("WEB", new int[2]); | ||
allApplicantPriority.put("APP", new int[2]); | ||
allApplicantPriority.put("AI", new int[2]); | ||
allApplicantPriority.put("GAME", new int[2]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put put put put 해서 메소드 하나에 별도로 인덱스를 접근해서 초기화 하는 코드 하나로 지금 거의 10줄이 넘게 소요되고 있죠? 차라리 init 함수를 따로 빼도 좋겠습니다.
for (String key : allRegistration.keySet()){ | ||
Registration registration = allRegistration.get(key); | ||
int[] firstPriority = allApplicantPriority.get(registration.getFirstPriority()); | ||
int[] secondPriority = allApplicantPriority.get(registration.getSecondPriority()); | ||
|
||
firstPriority[0] += 1; | ||
secondPriority[1] += 1; | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1씩 늘려가며 집계하는 코드는 좋지 않습니다. 나중에 100만건이 있으면 100만번 더하는 것이 좋을까요? 다시 고민!
if(!allMajor.containsKey(major)){ | ||
allMajor.put(major, 0); | ||
} | ||
if(!allMajor.containsKey(doubleMajor)){ | ||
allMajor.put(doubleMajor, 0); | ||
} | ||
if(!allMajor.containsKey(minor)){ | ||
allMajor.put(minor, 0); | ||
} | ||
|
||
allMajor.put(major, allMajor.get(major) + 1); | ||
allMajor.put(doubleMajor, allMajor.get(doubleMajor) + 1); | ||
allMajor.put(minor, allMajor.get(minor) + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
르블랑의 법칙
나는 현재 충분히 아름다운 코드를 짜고 있는가?
우리 모두는 자신이 짠 쓰레기 코드를 쳐다보며 나중에 손보겠다고 생각한 경험이 있다. 우리 모두는 대충 짠 프로그램이 돌아간다는 사실에 안도감을 느끼며 그래도 안 돌아가는 프로그램보다 돌아가는 쓰레기가 좋다고 스스로를 위로한 경험이 있다. 다시 돌아와 나중에 정리하겠다고 다짐했었다. 물론 그때 그 시절 우리는 르블랑의 법칙을 몰랐다. 나중은 결코 오지 않는다.
public DesiredTimeMapper getAllDesiredTime() { | ||
Map<String, DesiredTime> allDesiredTime = db.getAllDesiredTime(); | ||
for (String key : allDesiredTime.keySet()){ | ||
DesiredTime desiredTime = allDesiredTime.get(key); | ||
for (int[] times: desiredTime.getDesiredTime()){ | ||
int startTime = times[0]; | ||
int endTime = times[1]; | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return이 없는데 덜 짜신건가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네...덜 짰습니다
No description provided.