2023년 1월 1일
08:00 AM
Buffering ...

최근 글 👑

20240830_캠프 7주차 5일_TIL_Spring 숙련 개인과제 회고

2024. 8. 30. 14:13ㆍ내배캠_Java 6기

 

https://github.com/mylotto0626/Sparta_Spring_todoApp

 

GitHub - mylotto0626/Sparta_Spring_todoApp: 스파르타 내일배움캠프 스프링 숙련 주차 개인과제 레포지토리

스파르타 내일배움캠프 스프링 숙련 주차 개인과제 레포지토리. Contribute to mylotto0626/Sparta_Spring_todoApp development by creating an account on GitHub.

github.com

 

 

📌 피드백 받은 내용

1) TodoService에서 의존시 Autowired 방식 말고 @RequiredArgsConstructor 의 롬복방식으로 final 객체로 안전하게 선언할 수 있도록 변경

 

2) API설계시 단수보다는 복수로 설계 예시) /api/todo -> /api/todos

 

3) Entity에서는 setter를 지양하자

➡️ 명확한 값의 의도 파악이 어려움, 캡슐화 원칙의 위배, 객체의 불변성 위배 등 이유가 존재

 

예시)

@Builder public Todo(Long todoId, User user, String title, String content, LocalDateTime createdAt, LocalDateTime updatedAt, String weather, Set<Comment> comments, Set<User> assignedUsers) { 
	this.todoId = todoId; 
    this.user = user; 
    this.title = title; 
    this.content = content; 
    this.createdAt = createdAt; 
    this.updatedAt = updatedAt; 
    this.weather = weather; 
    this.comments = comments; 
    this.assignedUsers = assignedUsers; 
 }

 

 

4) updatedAt, createAt 해당 엔티티 필드는 별도의 공통 엔티티로 만들어서 다른 엔티티들이 상속받아서 사용할 수 있게!

public class BaseEntity { 
	@Column(nullable = false) 
    private LocalDateTime createdAt; 
    
    @Column(nullable = false) 
    private LocalDateTime updatedAt; 
} 

public class Todo extends BaseEntity { ... }

 

 

 5) Exception 처리는 별도의 Custom Exception 처리 방식 

 

잘한점

Optional을 통해 NPE 방지를 잘 했고, 10단계까지 단계별 구현을 완료.

 

공부해야 할 점

✅ 비지니스 로직에 대한 validation 체크, 예외처리

로직들에 대한 주석처리

README가 더 상세하게 정리 되었다면 더욱 좋은 코드!

 

오늘 한 일 


✅ Spring 숙련 주차 강의 마저 듣기

✅ 포트폴리오 정리 사이트를 업데이트 했다 

 

https://www.tj-dev.com/

 

포트폴리오 | My Site 1

About Me. This is your About section. Every website has a story and users want to hear yours. This is a great opportunity to give a full background on who you are and what your site has to offer. Double click on the text box to edit the content and add all

www.tj-dev.com

 

 

728x90