-
Notifications
You must be signed in to change notification settings - Fork 17
[김찬호] Sprint1 #2
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?
Conversation
|
||
test { | ||
useJUnitPlatform() | ||
} |
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 해결해주세요.
나중에 git에서 무의미한 diff 가 찍힐 수 있습니다.
@@ -0,0 +1 @@ | |||
rootProject.name = '1-sprint-mission' |
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 해결해주세요.
protected final Long createdAt; | ||
protected Long updatedAt; |
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.
멤버 변수는 private 으로 선언하시는게 좋습니다. 캡슐화를 위해서요.
private List<User> users; | ||
private List<Message> messages; |
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 void addUser(User user) { | ||
if(!users.contains(user)) { | ||
users.add(user); | ||
user.addChannel(this); | ||
} | ||
} | ||
public void removeUser(User user) { | ||
if(users.contains(user)) { | ||
users.remove(user); | ||
user.removeChannel(this); | ||
} | ||
} | ||
|
||
public void addMessage(Message message) { | ||
if(!messages.contains(message)) { | ||
messages.add(message); | ||
message.addChannel(this); | ||
} | ||
} | ||
public void removeMessage(Message message) { | ||
if(messages.contains(message)) { | ||
messages.remove(message); | ||
message.removeChannel(this); | ||
} | ||
} |
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 문에서는 예외를 처리하고, 그 밖에서 비지니스 로직이 처리되도록 구성해보세요.
private ChannelState(String state) { | ||
this.state = state; | ||
} | ||
} |
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 해결해주세요.
DEACTIVATED("비활성화"), | ||
DELETED("삭제"); | ||
|
||
private String state; |
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.
description이라고 명명해도 괜찮을것 같습니다.
private Channel channel; | ||
private String contents; | ||
private MessageState state; | ||
|
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.
이런 의미 없는 공백은 제거해주시는게 좋습니다.
spotless 같은 코드 포맷팅 툴 설치해서 돌려주시면 이런 문제는 해결할 수 있습니다.
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); | ||
String created = sdf.format(new Date(createdAt)); | ||
String updated = sdf.format(new Date(updatedAt)); |
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.
이런 코드가 중복되네요. 이런 경우는 Util 클래스로 빼는것도 괜찮습니다.
public void addChannel(Channel channel) { | ||
if(this.channel == null) { | ||
this.channel = channel; | ||
channel.addMessage(this); | ||
} | ||
} | ||
|
||
public void removeChannel(Channel channel) { | ||
if(this.channel != channel) { | ||
this.channel = null; | ||
channel.removeMessage(this); | ||
} | ||
} | ||
|
||
public void addUser(User user) { | ||
if(this.user == null) { | ||
this.user = user; | ||
user.addMessage(this); | ||
} | ||
} | ||
public void removeUser(User user) { | ||
if(this.user != user) { | ||
this.user = null; | ||
user.removeMessage(this); | ||
} | ||
} |
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 안에서 조건만족할때만 비지니스로직이 돌면 나중에 실 운영에서 이슈가 있습니다.
if 안에서는 조건 만족하지 않을 경우에 대한 예외처리를 하고 바깥에서 비지니스 로직을 처리해보시기 바랍니다.
package com.sprint.mission.discodeit.entity; | ||
|
||
public enum MessageState { | ||
VISIBLE(""), |
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.
"" 로 두지마시고 이것도 설명 달아주시면 좋을것 같습니다.
INVISIBLE("숨김"), | ||
DELETED("삭제"); | ||
|
||
private String state; |
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.
description 정도면 적당할듯합니다.
public void addChannel(Channel channel) { | ||
if(!channels.contains(channel)) { | ||
channels.add(channel); | ||
channel.addUser(this); | ||
} | ||
} | ||
public void removeChannel(Channel channel) { | ||
if(channels.contains(channel)) { | ||
channels.remove(channel); | ||
channel.removeUser(this); | ||
} | ||
} | ||
|
||
public void addMessage(Message message) { | ||
if(!messages.contains(message)) { | ||
messages.add(message); | ||
message.addUser(this); | ||
} | ||
} | ||
public void removeMessage(Message message) { | ||
if(messages.contains(message)) { | ||
messages.remove(message); | ||
message.removeUser(this); | ||
} | ||
} |
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 String getState() { | ||
return state; | ||
} | ||
} |
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 해결해주세요.
public void leaveUser(Channel channel, User user);//채널에서 유저 추방 | ||
public void deleteChannel(Channel 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.
eol 해결해주세요.
|
||
public interface ChannelService { | ||
public Channel createChannel(Channel channel);//채널 생성 | ||
public List<Channel> getChannels();//모든 채널 출력 |
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 List<Channel> getChannels();//모든 채널 출력 | |
public List<Channel> getAllChannels();//모든 채널 출력 |
|
||
public interface MessageService { | ||
public Message addMessage(Message message);//메세지 입력 | ||
public List<Message> getMessages();//모든 메세지 출력 |
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 List<Message> getMessages();//모든 메세지 출력 | |
public List<Message> getAllMessages();//모든 메세지 출력 |
|
||
public interface UserService { | ||
public User addUser(User user);//유저 가입 | ||
public List<User> 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.
public List<User> getUsers();//모든 유저 출력 | |
public List<User> getAllUsers();//모든 유저 출력 |
public void updateUser(UUID userId, String updatedText);//유저 이름 수정 | ||
public void deleteUser(User user);//유저 탈퇴 | ||
public List<Message> findMessagesByUser(User user);//유저가 쓴 메세지 출력 | ||
} |
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 해결해주세요.
public Optional<Channel> findChannelById(UUID channelId) { | ||
return data.stream() | ||
.filter(channel -> channel.getChannelId().equals(channelId)) | ||
.filter(channel -> channel.getState() != ChannelState.DELETED) | ||
.findFirst(); | ||
} |
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.
만약 결과가 empty인 경우 예외처리를 하고 Channel을 리턴하도록 바꿔보세요.
} | ||
|
||
@Override | ||
public Optional<User> findUserById(UUID UserId) { |
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.
만약 결과가 empty인 경우 예외처리를 하고 User를 리턴하도록 바꿔보세요.
} | ||
|
||
@Override | ||
public Optional<Message> findMessageById(UUID messageId) { |
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.
만약 결과가 empty인 경우 예외처리를 하고 Message를 리턴하도록 바꿔보세요.
요구사항
기본 요구사항
프로젝트 초기화
으로 설정합니다.
... .idea ...
도메인 모델링
서비스 설계 및 구현
메인 클래스 구현
기본 요구사항 커밋 태그
심화
서비스 간 의존성 주입
주요 변경사항
스크린샷
멘토에게