Replies: 2 comments 1 reply
-
|
과거에는 ~~list보다는 ~~s를 선호했어요. 다수가 사용하는 컨벤션을 사용한다면 장점이 많기 때문에 코드리뷰에서 변경을 요청받은 경우도 있었습니다. findAll같은건 주로 ORM에서 많이 사용했던 것 같아요. 결국 팀 컨벤션에 맞춰 일관성 있게 사용하는 게 가장 중요한 것 같아요. 어떤 방식이든 팀 전체가 동일하게 사용한다면 문제없을 듯 합니다~ |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
팀원들과 자주하는 고민 같습니다. 저는 이런 경우의 함수 이름은 되도록 데이터 및 타입와 연관 지으려고 노력하는 편인데요. interface Game {
// ...
}
// case 1. Game의 배열을 그냥 Game[] 자체로 사용하는 경우
const getGames = (options?: unknown) => {
// ..
const fetchedGames: Game[] = response.data;
return fetchedGames
}
// case 2. Game의 배열을 별도의 타입(~List)로 관리하는 경우
interface List<D> {
data: D;
pagination: {
currentPage: number;
totalPages: number;
nextPage: number;
previousPage: number;
}
}
type GameList = List<Game>;
const getGameList = (options?: unknown) => {
// ...
return response.data;
}위 처럼, 모델로 관리하는 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
배열의 값을 받아오는 data fetching을 위한 함수를 구현하다 고민이 하나 생겼습니다. 예를 들면,
저는 보통
getGames와 같은 형식으로{http method}+{목적 단위}+{정렬이나 필터}로 정의해서 사용하고 있었는데요, 다른 코드를 보았을 땐getGameList와 같은 형식으로도 사용하더라구요. 또, BE쪽에서는findAll같은 형식을 사용한다고도 들어서 어떤 방식이 직관적인지, 의미적으로 알맞은지 궁금하기도 합니다. 다들 어떻게 사용하시나요?제 나름대로 구분을 지어보긴 했는데 일관성이 없다는 생각도 조금 들고 고민이 되네요.
14 votes ·
Beta Was this translation helpful? Give feedback.
All reactions