-
Notifications
You must be signed in to change notification settings - Fork 17
[안중원] sprint 1 #5
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 1 #5
Conversation
import java.util.UUID; | ||
|
||
public class JCFChannelService implements ChannelService { | ||
private final List<Channel> data = new 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.
Map 사용이 더 적절해보입니다
import java.util.UUID; | ||
|
||
public class JCFMessageService implements MessageService { | ||
private final List<Message> data = new 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.
여기도 Map
import java.util.stream.Collectors; | ||
|
||
public class JCFUserService implements UserService { | ||
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.
여기도 Map
// 수정 | ||
/* @Override | ||
public User updateUserById(UUID id, String newName) { | ||
for (User user : data) { | ||
if (user.getId().equals(id)) { | ||
user.setUsername(newName); | ||
user.setUpdatedAt(); | ||
return user; | ||
} | ||
} | ||
return null; | ||
}*/ | ||
// Stream 변환 | ||
/* | ||
* update 로직 : 찾음 > 수정 > 반환 | ||
* filter > findFirst로 찾고, map으로 수정 | ||
* 여기서 map은 중간 연산자 아니고, Optional!! | ||
* | ||
* +) Stream은 내부 반복자라 전체를 내부 순회하므로 update 할 요소가 많아지면 Stream 사용 권장 X |
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.
개발단계에서 학습이나 코딩에는 도움이 되겠지만,
나중에는 이런 주석들은 다 삭제되어야 합니다!
User user1 = userService.createUser("user1"); | ||
User user2 = userService.createUser("user2"); |
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.
유저이름을 String으로 넘겨 생성하는 것보다,
유저 객체를 넘겨서 생성하는 편이 좀 더 적절해보이긴 하네요
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.
전반적으로 리팩토링이 필요한 코드로 보입니다. Stream 활용 등은 잘 해주셨으나, 도메인 객체 내에 선언된 여러 메서드들이 사용되지 않는 경우도 더러 있고, 사용하지 않는/불필요한 주석 제거, Map 활용 등 여러 포인트들을 잡아서 리팩토링하면 좋겠습니다!
목표
프로젝트 마일스톤
요구사항
기본 요구사항
프로젝트 초기화
도메인 모델링
서비스 설계 및 구현
도메인 모델 별 CRUD(생성, 읽기, 모두 읽기, 수정, 삭제) 기능을 인터페이스로 선언하세요.
com.sprint.mission.discodeit.service
[도메인 모델 이름]Service
다음의 조건을 만족하는 서비스 인터페이스의 구현체를 작성하세요.
com.sprint.mission.discodeit.service.jcf
JCF[인터페이스 이름]
data
)를final
로 선언하고 생성자에서 초기화하세요.data
필드를 활용해 생성, 조회, 수정, 삭제하는 메소드를 구현하세요.메인 클래스 구현
JavaApplication
클래스를 선언하고, 도메인 별 서비스 구현체를 테스트해보세요.기본 요구사항 커밋 태그
sprint1-basic
태그를 생성해주세요.심화 요구 사항
서비스 간 의존성 주입
도메인 모델 간 관계를 고려해서 검증하는 로직을 추가하고, 테스트해보세요.
힌트:
Message
를 생성할 때 연관된 도메인 모델 데이터 확인하기피드백 내역
20250604