Skip to content

2번 과제 제출#28

Open
DongHyeonka wants to merge 5 commits into12th-Likelion-Kit:donghyeonfrom
DongHyeonka:main
Open

2번 과제 제출#28
DongHyeonka wants to merge 5 commits into12th-Likelion-Kit:donghyeonfrom
DongHyeonka:main

Conversation

@DongHyeonka
Copy link

No description provided.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

물론 Repository를 메모리 형태로 사용하지는 않겠지만
그래도 이렇게 컬렉션 객체를 Getter로 가져오면 조금 문제가 되지 않을까요?
컬렉션을 Getter로 가져오면 안의 값들을 바꿀 수 있어서 그렇습니다
싱글톤 계층의 필드의 접근을 조심하셔야 할 거 같아요

어떻게 생각하시나요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞네요 이렇게 작성하게 되면 private으로 설정해둔 store의 값을 변경할 수 있게 되네요 그럼 store에서 값을 가져오는게 아닌 Repository에서 board list를 접근 가능하게
public List AllBoards() return new ArrayList<>(store.values()); 이런식으로 만들어주는게 더 나은 것 같습니다! 혹시 더 나은 방안이 있다면 알려주세요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants