-
Notifications
You must be signed in to change notification settings - Fork 17
[김민수] Sprint 2 #28
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?
[김민수] Sprint 2 #28
Conversation
public boolean equals(Object o) { | ||
if (o == null || getClass() != o.getClass()) return false; | ||
BasedEntity that = (BasedEntity) o; | ||
return Objects.equals(getId(), that.getId()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(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.
equals랑 hashCode 재정의해서 쓰는 것 굉장히 좋습니다.
public void addUser(User user) { | ||
if (this.user == null){ | ||
this.user = user; | ||
user.addMessage(this); | ||
} | ||
} | ||
|
||
// 작성된 채널 | ||
public void addChannel(Channel channel) { | ||
if (this.channel == null){ | ||
this.channel = channel; | ||
channel.addMessage(this); | ||
} | ||
} | ||
|
||
// 유저가 삭제하거나 유저가 삭제된 경우 | ||
public void removeUser() { | ||
if (this.user != null) { | ||
this.user = null; | ||
} | ||
} | ||
|
||
// 채널에서 삭제된 경우 | ||
public void removeChannel() { | ||
if (this.channel != null) { | ||
this.channel = 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.
여기도 분기 안에서는 예외 처리 밖에서는 비지니스 로직 수행하는 식으로 변경해보세요!
try (FileInputStream fis = new FileInputStream(FILE_PATH); | ||
ObjectInputStream ois = new ObjectInputStream(fis)) { | ||
list = (List<Channel>) 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.
에러는 각각 처리해주시는게 더 좋습니다.
List<Message> list = findAll(); | ||
if(list.stream().anyMatch(message::equals)){ | ||
List<Message> updatedList = list.stream().map(c -> c.equals(message) ? message : c) | ||
.collect(Collectors.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.
불변객체를 리턴하실거라면 아래처럼 수정해주세요. 나머지 코드들도 마찬가지입니다.
.collect(Collectors.toList()); | |
.toList(); |
.collect(Collectors.toList()); | |
.collect(Collectors.toList()); |
.collect(Collectors.toList()); | |
.collect(Collectors.toList()); |
// 채널 삭제 | ||
@Override | ||
public void deleteChannel(Channel channel) { | ||
validatedChannel(channel); |
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.
메서드명 수정해주세요.
validatedChannel(channel); | |
validateChannel(channel); |
validatedChannel(channel); | |
validatedChannel(channel); |
validatedChannel(channel); | |
validatedChannel(channel); |
요구사항
기본
File IO를 통한 데이터 영속화
서비스 구현체 분석
레포지토리 설계 및 구현
심화
관심사 분리를 통한 레이어 간 의존성 주입
다음의 조건을 만족하는 서비스 인터페이스의 구현체를 작성하세요.
Basic*Service 구현체를 활용하여 테스트해보세요.
JCF*Repository 구현체를 활용하여 테스트해보세요.
File*Repository 구현체를 활용하여 테스트해보세요.
이전에 작성했던 코드(JCFService 또는 FileService)와 비교해 어떤 차이가 있는지 정리해보세요.
주요 변경사항
멘토에게