Open
Conversation
kang20
reviewed
Apr 17, 2024
Comment on lines
10
to
17
|
|
||
| @Getter | ||
| @Repository | ||
| public class BoardRepository { | ||
| private HashMap<Long, BoardEntity> store = new HashMap<>(); | ||
| private Long sequence = 0L; | ||
|
|
||
| public BoardEntity save(BoardEntity boardEntity) { |
Contributor
There was a problem hiding this comment.
물론 Repository를 메모리 형태로 사용하지는 않겠지만
그래도 이렇게 컬렉션 객체를 Getter로 가져오면 조금 문제가 되지 않을까요?
컬렉션을 Getter로 가져오면 안의 값들을 바꿀 수 있어서 그렇습니다
싱글톤 계층의 필드의 접근을 조심하셔야 할 거 같아요
어떻게 생각하시나요
Author
There was a problem hiding this comment.
네 맞네요 이렇게 작성하게 되면 private으로 설정해둔 store의 값을 변경할 수 있게 되네요 그럼 store에서 값을 가져오는게 아닌 Repository에서 board list를 접근 가능하게
public List AllBoards() return new ArrayList<>(store.values()); 이런식으로 만들어주는게 더 나은 것 같습니다! 혹시 더 나은 방안이 있다면 알려주세요
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.