-
Notifications
You must be signed in to change notification settings - Fork 17
[정지환] sprint 1 #7
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: main
Are you sure you want to change the base?
Conversation
Scanner sc = new Scanner(System.in); | ||
|
||
JCFServiceFactory factory = new JCFServiceFactory(); | ||
UserService userService = factory.createUserService(); | ||
MessageService messageService = factory.createMessageService(); | ||
ChannelService channelService = factory.createChannelService(); |
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.
Scanner로 분기처리 및 의존성 주입 처리 별도로 팩토리 서비스 만드셔서 처리해준 것 좋습니다
public List<Channel> getChannels() { | ||
return channels; | ||
} | ||
|
||
public List<Message> getMessages() { | ||
return messages; | ||
} | ||
|
||
public void updateUserName(String newUserName) { | ||
this.userName = newUserName; | ||
} | ||
|
||
public Status getStatus() { return status; } | ||
|
||
public void setStatus(Status status) { this.status = status; } | ||
|
||
public void addChannel(Channel newChannel){ | ||
if(!channels.contains(newChannel)) { | ||
channels.add(newChannel); | ||
newChannel.addUser(this); | ||
} | ||
} | ||
|
||
public void removeChannel(Channel newChannel){ | ||
if(channels.contains(newChannel)) { | ||
channels.remove(newChannel); | ||
newChannel.removeUser(this); | ||
} | ||
} | ||
|
||
public void addMessage(Message newMessage){ | ||
this.messages.add(newMessage); | ||
} | ||
|
||
public void removeMessage(Message m){ this.messages.remove(m); } |
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.
유저 도메인에 두기에는 너무 과도한 책임이라고 보여집니다 removeMesages, getChannels 등
서비스 계층으로 빼는게 나아보여요
private JCFChannelService(){ | ||
data = new ArrayList<>(); | ||
this.messageService = JCFMessageService.getInstance(); | ||
} | ||
|
||
public static JCFChannelService getInstance() { | ||
if (instance == null) { | ||
instance = new JCFChannelService(); | ||
} | ||
return instance; | ||
} |
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 static JCFChannelService instance; | ||
private final List<Channel> data; |
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.
리스트로 처리한게 좀 아쉽네요 Map을 쓰는게 더 효과적인 탐색이 가능할텐데요
public class JCFMessageService implements MessageService { | ||
|
||
private static JCFMessageService instance; | ||
private final List<Message> data; |
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.
여기도 마찬가지로 Map
public class JCFUserService implements UserService { | ||
|
||
private static JCFUserService instance; | ||
private final List<User> data; |
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.
여기도
요구사항
기본
프로젝트 초기화
도메인 모델링
com.sprint.mission.discodeit.entity
도메인 모델 정의
id
: UUID 타입createdAt
,updatedAt
: Long 타입생성자
id
는 생성자에서 초기화하세요.createdAt
은 생성자에서 초기화하세요.메소드
서비스 설계 및 구현
도메인 모델 별 CRUD 인터페이스 선언
com.sprint.mission.discodeit.service
[도메인명]Service
인터페이스 구현체 작성
com.sprint.mission.discodeit.service.jcf
JCF[인터페이스명]
data
필드를final
로 선언하고 생성자에서 초기화메인 클래스 구현 (
JavaApplication
)심화 요구 사항
서비스 간 의존성 주입
주요 변경사항
스크린샷
멘토에게