Skip to content

[길도현] sprint2 #3

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

Merged
merged 4 commits into from
Jul 26, 2025

Conversation

DoHyunGil
Copy link
Collaborator

요구사항

클래스 구현하기

  • Product 클래스 구현
  • Product 클래스를 상속한 ElectronicProduct 클래스 구현
  • Article 구현
  • 각 클래스의 생성자 구현

Article 요청 함수 구현하기

  • GET 구현
  • POST 구현
  • PATCH 구현
  • DELETE 구현
  • catch로 예외 처리 구현

Product 요청 함수 구현하기

  • GET 구현
  • POST 구현
  • PATCH 구현
  • DELETE 구현
  • catch로 예외 처리 구현
  • getProductList 구현
  • export/import로 모듈화 구현

주요 변경사항

멘토에게

@DoHyunGil DoHyunGil closed this Jul 23, 2025
@DoHyunGil DoHyunGil changed the title 길도현 스프린트 미션 2 pull 요청입니다. [길도현] sprint2 Jul 23, 2025
@DoHyunGil DoHyunGil reopened this Jul 23, 2025
@DoHyunGil DoHyunGil marked this pull request as draft July 23, 2025 04:05
@DoHyunGil DoHyunGil requested a review from mag123c July 23, 2025 06:24
@DoHyunGil DoHyunGil added the 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. label Jul 23, 2025
@shinYeongHyeon shinYeongHyeon requested review from shinYeongHyeon and removed request for mag123c July 26, 2025 11:40
Copy link
Collaborator

@shinYeongHyeon shinYeongHyeon 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 +5 to +19
class Article {
title = '';
content = '';
writer = '';
likeCount = 0;
createAt = '';

constructor(createAt) {
this.createAt = createAt;
}

like() {
this.likeCount++;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

클래스의 캡슐화가 진행되지 않았네요!
private 화 를 진행하기 위해서 # 을 진행하는건 어떨까요,
더불어 getter 와 setter 를 통해서, 변수를 받거나, 건네주는 게 필요해 보입니다

}
}

const link = 'https://panda-market-api-crud.vercel.app/articles';
Copy link
Collaborator

Choose a reason for hiding this comment

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

위 URL 에서 https://panda-market-api-crud.vercel.app 는 반복적으로 사용 되네요.
변수를 따로 생성하여 템플릿 리터럴 을 활용하면 가독성과 유지보수 편이성을 모두 챙길 수 있을듯해요

// 다른파일
export const BASE_URI = 'https://panda-market-api-crud.vercel.app';

// 현재
const link = `${BASE_URI}/articles`;


let result = fetch(address)
.then((res) => {
if(!(res.status >= 200 && res.status < 300)) console.error("응답 코드 에러 : " + res.status);
Copy link
Collaborator

Choose a reason for hiding this comment

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

위와 같이 HttpStatusCode 2xx 대가 아님을 필터하여, 응답을 진행하는 것은 좋아보입니다 👍🏼
여기서 반복적으로 사용되는 !(res.status >= 200 && res.status < 300) 이 조건을 함수로 따로 빼서, 함수화 하여 의미를 쉽게 표현하면 더 좋은 코드가 될 수 있을 것 같아요

createAt = '';

constructor(createAt) {
this.createAt = createAt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

생성자는 createdAt 만 받고 있네요 !
다른 것도 받아서 인스턴스 생성이 편해지는건 어떨가요

export async function deleteProduct() {
let address = url;
address.searchParams.append('productId', 1);
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

github 의 오류일수도 있으나, 만약 실제로 try 의 들여쓰기가 위와 같이 돼있다면, 가독성이 조금 떨어질 것 같습니다 !
이런것들을 편하게 잡기 위해서 eslint 혹은 prettier 같은 정적도구를 활용해보는건 어떨까요 ?

https://eslint.org/

const link = 'https://panda-market-api-crud.vercel.app/products';
const url = new URL(link);

let products = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 변수는 push 만 될 뿐, 변화가 일어나지는 않는 것 같습니다 !
따라서, const 로 선언하는 것은 어떨까요 ?
그리고 사용되는 scope 안에서 선언되는 것이 조금 더 안정적인 프로그래밍 방법이 될 듯 합니다 !

Comment on lines +50 to +69
for(let item of json.list) {
if(!item.tags.includes('전자제품')) {
products.push(new Product(
item.name,
item.description,
item.price,
item.tags,
item.images,
));
}
else {
products.push(new ElectronicProduct(
item.name,
item.description,
item.price,
item.tags,
item.images,
));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

위 부분 for of 을 활용함으로써, 받은 리스트를 배열에 잘 넣어주셨습니다,
다만 여기서 map 을 활용하는 것이 실무에서는 더 좋은 코드라고 말할 수 있겠습니다 !

console.error("에러 발생 : " + e);
}
for(let item of json.list) {
if(!item.tags.includes('전자제품')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

전자제품 과 같은 매직스트링의 경우 변수로 따로 빼서, 그 의미를 설명해준다면 좋을 것 같아요!

Comment on lines +96 to +112
let data = await fetch(url.toString(), {
method: "POST",
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
images: [
"https://example.com/..."
],
tags: [
"전자제품"
],
price: 0,
description: "string",
name: "상품 이름"
}),
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

전체적으로 들여쓰는 부분들이 명확하지 않아, 가독성이 많이 떨어지는 듯 합니다,
해당 부분을 개선하면 보기 쉬운 코드가 될 것 같아요 !

@shinYeongHyeon shinYeongHyeon marked this pull request as ready for review July 26, 2025 11:58
@shinYeongHyeon shinYeongHyeon merged commit 4e9cb20 into codeit-bootcamp-nodejs:길도현 Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants