-
Notifications
You must be signed in to change notification settings - Fork 17
[권용진] Sprint2 #23
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
base: 권용진
Are you sure you want to change the base?
[권용진] Sprint2 #23
Conversation
파일 수정 시 동기화 적용
파일 수정 시 동기화 적용
중첩 for문 stream으로 변경
public void addChannel(Channel channel) { | ||
for (Channel c : channels) { | ||
if(c.getId().equals(channel.getId())) { | ||
// 같은 걸 찾믕 |
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.
별건 아닌데 오타가 있네요 ㅎㅎ
} | ||
|
||
if(!channels.contains(channel)) { | ||
System.out.println("1231231"+channel.getUsers()); |
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.
1231231 은 혹시 어떤 값일까요?
만약 디버깅 용도로 넣어 두신거면 제외해주시고, 디버깅은 디버깅 기능을 사용해서 하시는 습관을 들이시면 좋을것 같아여!
"\nmessages=" + messages.stream().map(Message::toString).toList() + | ||
'}'; | ||
} | ||
} |
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.
EOL 확인해주세요!
|
||
@Override | ||
public Channel createChannel(User user, String channelName) { | ||
if (user.getStatus() == UserStatus.DEACTIVE) return null; |
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 null 로 하시고 null을 외부에서 처리하지 마시고, 아예 예외로 던지는 것도 좋은 선택입니다.
아래도 수정 고려해주세요!!
for(User userFromFile : users) { | ||
if(userFromFile.getId().equals(user.getId())) { | ||
userFromFile.addMessage(newMessage); | ||
break; | ||
} |
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.
함수형으로 한번 작성해보시길 권해드립니다.
아래 for문들도 모두 확인해서 함수형으로 짜보시고 어떤 로직이 더 가독성이 있는지 판단해보시기 바랍니다.
// ArrayList<User> 역직렬화및 반환 | ||
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(USER_FILE_PATH))) { | ||
return (List<User>) ois.readObject(); | ||
} catch (IOException | ClassNotFoundException e) { |
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.
에러는 각각 처리해주시는게 좋습니다.
File file = new File(USER_FILE_PATH); | ||
|
||
if (!file.exists() || file.length() == 0) { | ||
return new ArrayList<User>(); // 해당 파일이 없거나 비어 있다면 빈 ArrayList를 반환 |
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 new ArrayList<User>(); // 해당 파일이 없거나 비어 있다면 빈 ArrayList를 반환 | |
return Collections.emptyList();// 해당 파일이 없거나 비어 있다면 빈 ArrayList를 반환 |
빈리스트를 반환하는게 목적이라면 의도가 명확하게 위처럼 표현하시는게 훨씬 직관적입니다.
불변 리스트를 리턴하는 것이기도 하구요.
서비스 초기화시 레퍼지토리를 주입하는 형태로 구현하셔야합니다! 의존성 주입에 대한 공부를 해보시면 좋을것 같아요! |
요구사항
기본
File IO를 통한 데이터 영속화
서비스 구현체 분석
레포지토리 설계 및 구현
심화
관심사 분리를 통한 레이어 간 의존성 주입
주요 변경사항