-
Notifications
You must be signed in to change notification settings - Fork 24
[박인규] sprint2 #66
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?
The head ref may contain hidden characters: "\uBC15\uC778\uADDC-sprint2"
[박인규] sprint2 #66
Conversation
-메세지 전체출력 기능 구현
- Application상 메뉴 구현하여 메서드로 캡슐화 - 사용자 생성/수정/삭제/조회기능 구현
- Application상 메뉴 구현하여 메서드로 캡슐화 - 사용자 생성/수정/삭제/조회기능 구현
- 사용자 관리에 5번 사용자변경 추가 - 채널입장 세부메뉴 구현 ㄴ채널 내부에서 메세지 관련 기능 모두 구현
- 메세지 도메인 채널 도메인에 연결
ㄴ채널삭제 기능 미구현
ㄴMessageControl.java : 메세지 관리 컨트롤 패널 ㄴChannelControl.java : 채널 관리 컨트롤 패널 ㄴUserControl.java : 유저 관리 컨트롤 패널 - Channel명 변경시 중복검사 로직 추가함 - 전체 메세지 표시 포맷 변경 - 날짜 표시 포맷 yyyy.MM.dd hh.mm.ss로 변경
ㄴMessageControl.java : 메세지 관리 컨트롤 패널 ㄴChannelControl.java : 채널 관리 컨트롤 패널 ㄴUserControl.java : 유저 관리 컨트롤 패널 - Channel명 변경시 중복검사 로직 추가함 - 전체 메세지 표시 포맷 변경 - 날짜 표시 포맷 yyyy.MM.dd hh.mm.ss로 변경
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
… into 박인규-sprint1
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
- IntelliJ로 프로젝트 생성시 src\main\java\main.java 구조를 만들지 않고 src\main.java로 바로 생성하는데 그레이들에서 src\main\java\ 구조가 없으면 빌드를 안해주는 문제 확인 - src\ 아래 있는 모든 구조 및 클래스를 src\main\java 디렉토리 하위로 이동, 정상 런 확인
ㄴ1. {break;} 등의 컨벤션, 줄바꿈, 들여쓰기 등 전반적인 문법 통일 ㄴ2. Channel entity가 MessageService 객체를 필드값으로 가지는 부분 수정. MessageList 컬렉션을 Channel객체의 UUID를 키값으로 갖는 Map 형태로 구조변경함. ㄴ3. 불필요한 호출, 메서드 선언 등 삭제 ㄴ4. 메서드 호출 시 넘기는 파라미터값을 필요최소로 조정함.예시 : (User user -> String user.getName()) ㄴ5. 부모 클래스에서 자식 클래스의 메서드를 참조하는 등 잘못된 상속관계 수정.
… 변경하여 ThreadSafe 구현
ㄴFileJavaApplication.java에서 구현 ㄴsrc/files/user.ser,channel.ser,messages.ser 파일로 저장 ㄴ각 컨트롤에서 int값이 아닌 값을 읽은 경우 다시 재입력 활성화하도록 변경.
ㄴFileJavaApplication.java에서 구현 ㄴsrc/files/user.ser,channel.ser,messages.ser 파일로 저장 ㄴ각 컨트롤에서 int값이 아닌 값을 읽은 경우 다시 재입력 활성화하도록 변경.
- Repository 정의하며 Message구조 전반적인 리팩터링
import com.sprint.mission.discodeit.FileJavaApplication; | ||
import com.sprint.mission.discodeit.entity.User; | ||
|
||
public class FileUserControl extends FileJavaApplication { |
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 static final JCFUserService userService = new JCFUserService(); | ||
public static final JCFMessageService messageService = new JCFMessageService(); | ||
public static final JCFChannelService channelService = new JCFChannelService(); |
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.
저번에 말씀드린대로 인터페이스로 변수를 써주세요.
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public class MessageControl extends JavaApplication { |
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.
나머지 Control 부분도 다 해당하는 내용인데요. Switch 하나하나가 너무 길어요. 각각 메서드로 분리할 수 있으면 가독성이 올라갈거 같아요.
|
||
|
||
public class Channel implements Serializable { | ||
private static final long serialVersionUID = 1L; |
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.
serialVersionUID
은 직렬화, 역직렬화 할때 쓰는 클래스 버전별 고유한 ID값입니다.
그래서 클래스마다 모두 다른 값을 가져야 합니다.
JVM에 있던 User를 직렬화하면 어떤 바이트 데이터로 변환 될텐데, 그 걸 파일로 저장했습니다.
그 파일을 읽어서 나중에 다시 객체를 만들려고 할때, 그 때 어떤 객체인지 명확하게 알 수 있어야 합니다.
이때 필요한게, serialVersionUID 입니다.
제가 알기론 원칙적으론 필드를 추가하거나 삭제거나 할때마다 달라야 하는게 맞습니다.
하지만 현업에서는 필드가 추가되거나 삭제 될때, 거의 안바꾸더라구요. 그러니 최소한 클래스마다는 다른 값으로 설정해야합니다.private static final long serialVersionUID = 1L
를 지우면 intellij에서 자동으로 겹치지 않는 값으로 생성해줄겁니다.
private int msgNumber; | ||
private String author; | ||
private String textMsg; | ||
|
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.
이 메시지가 어느 채널에 속한 메시지인지 알기 위해서
UUID로 channelId가 필요할거 같아요
그리고 누가 쓴건지 알기 위해서도
UUID로 userId가 필요할거 같아요.
void printAllChannels(); // Read 전체 채널 리스트 읽기 | ||
Channel findChannelByName(String name); // Read 이름으로 단일채널 읽기 | ||
|
||
void UpdateChannel(Channel channel, String channelName, String channelDescription); // Update 채널 정보 수정 |
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 interface MessageService{ | ||
void createMsg(UUID channelId, String uploaderName, String txtMsg); // Create 새 메세지 생성 | ||
|
||
Message findMessageByNum(UUID channelId,int num); // Read 채널 내 단일 메세지 조회 |
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.
Num이라는게 MsgNum이던데, MsgNum이 의미하는게 뭔가요?
메시지를 단건으로 조회할 필요가 있는지도 궁금하네요.
Message findMessageByNum(UUID channelId,int num); // Read 채널 내 단일 메세지 조회 | ||
List<Message> getMessagesList(UUID channelId); // Read 채널 내 전체 메세지 조회 | ||
|
||
void updateMsg(UUID channelId, String editerName, Message message, String Msg); // Update 메세지 수정 |
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.
UUID channelId는 왜 필요한건가요?
|
||
void updateMsg(UUID channelId, String editerName, Message message, String Msg); // Update 메세지 수정 | ||
|
||
void deleteMessage(UUID channelId, String deleterName, Message message); // Delete 단일 메세지 삭제 |
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.
UUID channelId가 왜 필요한지 여기서도 잘 이해가 안돼요.
channels.remove(channel); | ||
channelRepository.fileSaveChannels(); |
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.
39번째 라인으로
리스트에 있던 채널을 삭제하고
40번째 라인이 호출되면 메모리의 있는 private final List<Channel> channels
와 디스크에 있는 파일이 동일한 상태를 가지고 있는게 맞나요? 저는 아닌거 같아서요.
안녕하세요. 인규님. 제가 이미 코멘트로 남긴 내용이랑 동일한 내용이어서 굳이 남기지 않은 것들도 많아서요. |
기본 요구사항
File IO를 통한 데이터 영속화
[x] 다음의 조건을 만족하는 서비스 인터페이스의 구현체를 작성하세요.
[x] 클래스 패키지명: com.sprint.mission.discodeit.service.file
[x] 클래스 네이밍 규칙: File[인터페이스 이름]
[x] JCF 대신 FileIO와 객체 직렬화를 활용해 메소드를 구현하세요.
[x] Application에서 서비스 구현체를 File*Service로 바꾸어 테스트해보세요.
서비스 구현체 분석
[x] JCFService 구현체와 FileService 구현체를 비교하여 공통점과 차이점을 발견해보세요.
[x] "비즈니스 로직"과 관련된 코드를 식별해보세요.
레포지토리 설계 및 구현
[x] "저장 로직"과 관련된 기능을 도메인 모델 별 인터페이스로 선언하세요.
[x] 인터페이스 패키지명: com.sprint.mission.discodeit.repository
[x] 인터페이스 네이밍 규칙: [도메인 모델 이름]Repository
[x] 다음의 조건을 만족하는 레포지토리 인터페이스의 구현체를 작성하세요.
[x] 클래스 패키지명: com.sprint.mission.discodeit.repository.jcf
[x] 클래스 네이밍 규칙: JCF[인터페이스 이름]
[x] 기존에 구현한 JCF*Service 구현체의 "저장 로직"과 관련된 코드를 참고하여 구현하세요.
[x] 다음의 조건을 만족하는 레포지토리 인터페이스의 구현체를 작성하세요.
[x] 클래스 패키지명: com.sprint.mission.discodeit.repository.file
[x] 클래스 네이밍 규칙: File[인터페이스 이름]
[x] 기존에 구현한 File*Service 구현체의 "저장 로직"과 관련된 코드를 참고하여 구현하세요.
심화 요구 사항
관심사 분리를 통한 레이어 간 의존성 주입
[ ] 다음의 조건을 만족하는 서비스 인터페이스의 구현체를 작성하세요.
[ ] 클래스 패키지명: com.sprint.mission.discodeit.service.basic
[ ] 클래스 네이밍 규칙: Basic[인터페이스 이름]
[ ] 기존에 구현한 서비스 구현체의 "비즈니스 로직"과 관련된 코드를 참고하여 구현하세요.
[ ] 필요한 Repository 인터페이스를 필드로 선언하고 생성자를 통해 초기화하세요.
[ ] "저장 로직"은 Repository 인터페이스 필드를 활용하세요. (직접 구현하지 마세요.)
[ ] BasicService 구현체를 활용하여 테스트해보세요.
[ ] JCFRepository 구현체를 활용하여 테스트해보세요.
[ ] File*Repository 구현체를 활용하여 테스트해보세요.
[ ] 이전에 작성했던 코드(JCFService 또는 FileService)와 비교해 어떤 차이가 있는지 정리해보세요.
-----------------------------------------------------------------------------심화요구사항의 Basic은 구현하지 못했습니다 ㅠㅠ