Skip to content

Conversation

@jaechu12
Copy link

@jaechu12 jaechu12 commented May 5, 2025

실습 과제 수행과 함께 DTO, Service, Controller 형식으로 고쳐봤습니다
잘못 수정하거나 형식을 맞추지 못한 부분에 대하여 자세히 알려주세요

Copy link

@DHkimgit DHkimgit left a comment

Choose a reason for hiding this comment

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

연휴 기간 과제하느라 수고하셨습니다. 👍

Comment on lines 22 to 28
}
public void setContent(String content) {
this.content = content;
}



Copy link

Choose a reason for hiding this comment

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

개행이 규칙 없이 적용되어 있습니다. 규칙을 정하고 그것을 지켜주시는 것이 좋습니다. 코딩 컨벤션에 대해서 찾아보세요! 참고

Comment on lines 9 to 11
public void setId(Long id) {
this.id = id;
}
Copy link

Choose a reason for hiding this comment

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

public 메소드로 정의된 setter가 가진 문제점은 무엇일까요? setter를 사용하지 않는다면 객체의 값을 변경해야 할 때 어떻게 해야 할지도 고민해보시면 좋을 것 같아요.

public class ArticleController {

private final Map<Long, Article> articles = new ConcurrentHashMap<>();
private final AtomicLong idGenerator = new AtomicLong(1);
Copy link

Choose a reason for hiding this comment

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

AtomicLong 을 사용해 주셨네요! Long과 어떤 차이가 있나요?

Comment on lines 20 to 23
if (article == null) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok().body(article);
Copy link

Choose a reason for hiding this comment

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

예외 처리, ResponseEntity 사용 좋습니다.
Article 객체가 그대로 반환되고 있는데, dto에 대해서 공부해보시면 좋을 것 같아요. dto를 사용하는 이유가 무엇일까요?

Comment on lines 2 to 3

public class introduce2 {
Copy link

Choose a reason for hiding this comment

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

클래스 이름을 소문자로 하신 이유가 있나요? 이름을 어떻게 지어야 하는지 고민이 되신다면 자바 진영에서 사용하는 명명 규칙(Naming Coonvention)에 대해서 알아보세요!

Comment on lines 13 to 14

private final Map<Long, Article> articles = new ConcurrentHashMap<>();
Copy link

Choose a reason for hiding this comment

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

HashMap 대신 ConcurrentHashMap을 사용하신 이유는 무엇인가요?

@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 5주차 과제 제출합니다 [김예슬_BackEnd] 6주차 과제 제출합니다. May 12, 2025
@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 6주차 과제 제출합니다. [김예슬_BackEnd] 7주차 과제 제출합니다. May 19, 2025
Copy link

@DHkimgit DHkimgit left a comment

Choose a reason for hiding this comment

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

과제하시느라 수고하셨습니다.

Comment on lines 22 to 23
@Autowired
private JdbcTemplate jdbcTemplate;

Choose a reason for hiding this comment

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

사용하지 않는 객체는 제거해주세요. 인텔리제이에서 제거 후 CTRL + ALT + O 를 누르면 사용하지 않는 임포트문이 한번에 제거됩니다.

Comment on lines 38 to 41
public ResponseEntity<ArticleDTO> postArticle(@RequestBody ArticleDTO articleDTO) {
ArticleDTO article = articleService.postArticle(articleDTO);
return ResponseEntity.status(HttpStatus.CREATED).body(article);
}

Choose a reason for hiding this comment

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

request dto와 response dto를 분리하는 것도 고려해보세요.

Comment on lines 24 to 26

public ArticleDTO articlesId(@PathVariable() Long id) {
ArticleDTO articles = jdbcTemplate.queryForObject(

Choose a reason for hiding this comment

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

articlesId 메서드 이름이 모호합니다. 이 메서드가 무슨 역할을 하는지 예측할 수 있도록 동사-명사의 형태(getArticles)로 지어주세요.

Comment on lines 56 to 62

Number key = keyHolder.getKey();
articleDTO.setId(key.longValue());

articleDTO.setDate(LocalDateTime.now());
articleDTO.setRevisedDate(LocalDateTime.now());

Choose a reason for hiding this comment

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

dto와 도메인 객체의 역할을 혼동하고 계시는 것 같아요. 두가지가 어떤 차이가 있는지 찾아보세요.

Copy link
Author

Choose a reason for hiding this comment

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

아직 도메인에 대한 이해가 부족한 것 같습니다.
DTO는 전달만을 담당하고 도메인은 로직의 중심이며 DB와 매핑된다는 이론적인 부분은 조사했습니다.
이후 더 자세히 조사하여 보고서에 정리하도록 하겠습니다
혹시 해당 코드에선 DB에 입력하는 부분을 따로 빼면 그 부분이 도메인이 되는걸까요..?

Comment on lines 3 to 8

public class MemberDTO {
private Long ID;
private String name;
private String email;
private String password;

Choose a reason for hiding this comment

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

dto는 보통 불변 객체로 생성합니다. 자바에서는 14 버전부터 불변 객체를 생성할 수 있는 record 가 추가되었습니다.

@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 7주차 과제 제출합니다. [김예슬_BackEnd] 8주차 과제 제출합니다. May 26, 2025
@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 8주차 과제 제출합니다. [김예슬_BackEnd] 9주차 과제 제출합니다. Jun 2, 2025
@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 9주차 과제 제출합니다. [김예슬_BackEnd] 10주차 과제 제출합니다. Jun 22, 2025
@jaechu12 jaechu12 changed the title [김예슬_BackEnd] 10주차 과제 제출합니다. [김예슬_BackEnd] 11주차 과제 제출합니다. Jun 30, 2025
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