code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,17 @@
+package lotto
+
+import lotto.service.LottoService
+import lotto.view.Input
+import lotto.view.Output
+
+fun main() {
+ val money = Input.money()
+ val randomNums = Input.getRandomLottoNumsPerMoney(money)
+ val winNums = Input.winNums()
+
+ val lottoService = LottoService()
+ val lottoR... | Kotlin | VO에 대해 알아보고 원시값을 포장해보면 어떨까요? [참고](https://tecoble.techcourse.co.kr/post/2020-05-29-wrap-primitive-type/) |
@@ -0,0 +1,36 @@
+package lotto.view
+
+import lotto.domain.LottoTicket.Companion.TICKET_PRICE
+
+object Input {
+ fun money(): Int {
+ println("구입금액을 입력해 주세요.")
+ return readln().toInt()
+ }
+
+ fun getRandomLottoNumsPerMoney(money: Int): List<List<Int>> {
+ val ticketNumber = money.div(T... | Kotlin | 중첩 컬렉션보다는 의미를 담을 수 있는 객체를 만들어보면 어떨까요? |
@@ -0,0 +1,36 @@
+package lotto.view
+
+import lotto.domain.LottoTicket.Companion.TICKET_PRICE
+
+object Input {
+ fun money(): Int {
+ println("구입금액을 입력해 주세요.")
+ return readln().toInt()
+ }
+
+ fun getRandomLottoNumsPerMoney(money: Int): List<List<Int>> {
+ val ticketNumber = money.div(T... | Kotlin | 구매할 티켓수량을 view에서 구하는것이 적절한 위치일지 고민해보면 좋을 것 같아요! |
@@ -0,0 +1,36 @@
+package lotto.view
+
+import lotto.domain.LottoTicket.Companion.TICKET_PRICE
+
+object Input {
+ fun money(): Int {
+ println("구입금액을 입력해 주세요.")
+ return readln().toInt()
+ }
+
+ fun getRandomLottoNumsPerMoney(money: Int): List<List<Int>> {
+ val ticketNumber = money.div(T... | Kotlin | 매직넘버를 상수화해보면 어떨까요?! |
@@ -9,3 +9,8 @@
- [x] 문자열 계산기에 숫자 이외의 값 또는 음수를 전달하는 경우 RuntimeException 예외를 throw 한다.
- [x] 원시값을 포장한 도메인객체 구현
- [x] 연산자 오버라이딩 구현
+
+## 로또 (자동) 기능 요구사항
+- [x] 로또 구입 금액을 입력하면 구입 금액에 해당하는 로또를 발급해야 한다.
+ - [x] 금액은 0 이상이다.
+- [x] 로또 1장의 가격은 1000원이다. | Unknown | 해당 validation은 어디서 수행해주고 있나요?! |
@@ -0,0 +1,23 @@
+package lotto.service
+
+import lotto.domain.LottoTicketMachine
+import lotto.domain.Rank
+
+class LottoService {
+ fun getLottoRanks(nums: List<List<Int>>, winNums: List<Int>): List<Rank> {
+ return nums.map {
+ val issue = LottoTicketMachine.issue(it)
+ val winLottoTi... | Kotlin | object 사용을 고려해보면 어떨까요? |
@@ -0,0 +1,17 @@
+package lotto.domain
+
+object LottoTicketMachine {
+ fun issue(nums: List<Int>): LottoTicket {
+ require(nums.size == 6) {
+ "로또 개수를 잘못 입력했습니다"
+ }
+
+ val lottoBox = LottoBox()
+
+ val lottoNums = nums.map {
+ lottoBox.getLottoNum(it)
+ }.t... | Kotlin | issue라는 네이밍을 붙이신 이유가 궁금합니다! |
@@ -0,0 +1,24 @@
+package lotto.domain
+
+class LottoBox {
+ private val lottoNums: MutableMap<Int, LottoNum>
+
+ init {
+ val intRange = 1..45
+
+ lottoNums = intRange
+ .map { LottoNum(it) }
+ .associateBy { it.num }
+ .toMutableMap()
+ }
+
+ fun getLottoNum(... | Kotlin | LottoBox만 봤을때 lottoNum이 null이라고해서 중복된 숫자를 입력했다고 보장할 수 있을까요? |
@@ -0,0 +1,28 @@
+package lotto.domain
+
+class LottoNum(num: Int) {
+ val num: Int
+
+ init {
+ require(num in 1..45) {
+ "로또 숫자 범위는 1 ~ 45 입니다."
+ }
+
+ this.num = num
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (... | Kotlin | inline class를 활용해봐도 좋을 것 같아요!! :)
> 래퍼클래스로 inline class와 value class 를 사용하는거 같은데요!
잘 이해가 안가서요~
뭔가 좋은 기능같기도 한데, 실무에서 어떻게, 어떤상황에 사용하면 좋을지 질문드립니다!
사실 저도 잘 사용한다고 말씀드리기는 어렵지만, 저는 아래와 같은 기준을 충족시키는 경우 인라인 클래스를 사용하고 있어요
* 해당 래퍼타입이 여러곳에서 호출되는가?
* 해당 클래스가 data class의 특징을 가지고 있는가?
실무에서 적용은 필수가 아니고 팀원들마다 의견이 다를 수... |
@@ -0,0 +1,28 @@
+package lotto.domain
+
+class LottoNum(num: Int) {
+ val num: Int
+
+ init {
+ require(num in 1..45) {
+ "로또 숫자 범위는 1 ~ 45 입니다."
+ }
+
+ this.num = num
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (... | Kotlin | 여기도 매직넘버를 상수화해보면 어떨까요? |
@@ -0,0 +1,18 @@
+const GATHERING_TYPE = ["DALLAEMFIT", "OFFICE_STRETCHING", "MINDFULNESS", "WORKATION"] as const;
+
+export type ScoresQuery = {
+ gatheringId?: number;
+ type?: (typeof GATHERING_TYPE)[number];
+};
+
+export type ScoresResponse = {
+ teamId: number;
+ gatheringId: number;
+ type?: (typeof GATHERI... | TypeScript | _:warning: Potential issue_
**ScoresQuery의 type 필드 타입이 잘못 정의되어 있습니다.**
현재 `type?: typeof GATHERING_TYPE`는 배열 타입을 의미하며, 이는 의도한 타입이 아닐 것 같습니다.
다음과 같이 수정하는 것을 제안드립니다:
```diff
export type ScoresQuery = {
gatheringId?: number;
- type?: typeof GATHERING_TYPE;
+ type?: (typeof GATHERING_TYPE)[number];
};
```
또는 더 ... |
@@ -0,0 +1,18 @@
+const GATHERING_TYPE = ["DALLAEMFIT", "OFFICE_STRETCHING", "MINDFULNESS", "WORKATION"] as const;
+
+export type ScoresQuery = {
+ gatheringId?: number;
+ type?: (typeof GATHERING_TYPE)[number];
+};
+
+export type ScoresResponse = {
+ teamId: number;
+ gatheringId: number;
+ type?: (typeof GATHERI... | TypeScript | _:warning: Potential issue_
**ScoresResponse에도 동일한 타입 이슈가 있습니다.**
ScoresResponse의 type 필드도 같은 문제를 가지고 있습니다.
다음과 같이 수정해 주세요:
```diff
export type ScoresResponse = {
teamId: number;
gatheringId: number;
- type?: typeof GATHERING_TYPE;
+ type?: (typeof GATHERING_TYPE)[number];
averageScore: number;
oneSt... |
@@ -0,0 +1,31 @@
+import { fetchReviewsScores } from "../_utils/api";
+import ScoreProgressBar from "./ScoreProgressBar";
+import Score from "@/components/Score";
+
+export default async function ReviewsAverage() {
+ const [scores] = await fetchReviewsScores();
+
+ const { averageScore, oneStar, twoStars, threeStars,... | Unknown | _:warning: Potential issue_
**map 함수에 key prop이 필요합니다.**
React 배열 렌더링 시 각 요소를 식별하기 위한 key prop이 누락되었습니다.
다음과 같이 수정하는 것을 제안드립니다:
```diff
{stars.map((count, index) => (
- <ScoreProgressBar score={5 - index} stars={count} total={total} />
+ <ScoreProgressBar
+ key={5 - index}
+ score={5 - index}
+ stars={... |
@@ -0,0 +1,31 @@
+import { fetchReviewsScores } from "../_utils/api";
+import ScoreProgressBar from "./ScoreProgressBar";
+import Score from "@/components/Score";
+
+export default async function ReviewsAverage() {
+ const [scores] = await fetchReviewsScores();
+
+ const { averageScore, oneStar, twoStars, threeStars,... | Unknown | _:warning: Potential issue_
**데이터 로딩 및 에러 상태 처리가 필요합니다.**
비동기 데이터 페칭 시 발생할 수 있는 에러와 로딩 상태에 대한 처리가 누락되었습니다.
다음과 같이 에러 처리를 추가하는 것을 제안드립니다:
```diff
export default async function ReviewsAverage() {
- const [scores] = await fetchReviewsScores();
+ try {
+ const [scores] = await fetchReviewsScores();
+ } catch (e... |
@@ -0,0 +1,18 @@
+const GATHERING_TYPE = ["DALLAEMFIT", "OFFICE_STRETCHING", "MINDFULNESS", "WORKATION"] as const;
+
+export type ScoresQuery = {
+ gatheringId?: number;
+ type?: (typeof GATHERING_TYPE)[number];
+};
+
+export type ScoresResponse = {
+ teamId: number;
+ gatheringId: number;
+ type?: (typeof GATHERI... | TypeScript | 코드래빗 말대로 type이 (typeof GATHERING_TYPE)[number]; 가 되어야 할 것 같습니다. |
@@ -0,0 +1,31 @@
+import { fetchReviewsScores } from "../_utils/api";
+import ScoreProgressBar from "./ScoreProgressBar";
+import Score from "@/components/Score";
+
+export default async function ReviewsAverage() {
+ const [scores] = await fetchReviewsScores();
+
+ const { averageScore, oneStar, twoStars, threeStars,... | Unknown | 여기 key prop이 필요할 것 같습니다... 근데 코드래빗이 이미 리뷰해줬네요 |
@@ -0,0 +1,141 @@
+package com.fourseason.delivery.domain.review.service;
+
+import com.fourseason.delivery.domain.order.entity.Order;
+import com.fourseason.delivery.domain.order.entity.OrderStatus;
+import com.fourseason.delivery.domain.order.repository.OrderRepository;
+import com.fourseason.delivery.domain.review.d... | Java | collect(Collectors.toList()) 보다는 Stream.toList()를 적용하는 것이 어떨까요?
toList()를 사용하면 UnmodifiableList 를 반환해 List 에 대한 변경이 불가능하기 때문에 중간에 수정될 위험을 줄일 수 있을거 같아요! |
@@ -0,0 +1,19 @@
+package com.fourseason.delivery.domain.review.dto.request;
+
+
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.PositiveOrZero;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+public record ReviewRequestDto(
+ String co... | Java | dto의 경우 record로 작성하기로 했던걸로 기억합니당. |
@@ -0,0 +1,17 @@
+package com.fourseason.delivery.domain.review.repository;
+
+import com.fourseason.delivery.domain.order.entity.Order;
+import com.fourseason.delivery.domain.review.entity.Review;
+import com.fourseason.delivery.domain.shop.entity.Shop;
+import org.springframework.data.jpa.repository.JpaRepository;
+
... | Java | 데이터들을 실제로 삭제하지 않고 논리적 삭제 처리 하기로 했던 부분이라
findByIdAndDeletedAtIsNotNull 과 같은 형태로 조회해주셔야...
저도 이 부분 처음에 까먹었습니다. |
@@ -0,0 +1,62 @@
+package com.fourseason.delivery.domain.review.controller;
+
+import com.fourseason.delivery.domain.review.dto.request.ReviewRequestDto;
+import com.fourseason.delivery.domain.review.dto.response.ReviewResponseDto;
+import com.fourseason.delivery.domain.review.service.ReviewService;
+import lombok.Requ... | Java | `String order_id` 는 아직 `Order`를 푸시 안했기 때문에 `UUID` 타입으로 바꾸지 않으신걸까요? |
@@ -0,0 +1,62 @@
+package com.fourseason.delivery.domain.review.controller;
+
+import com.fourseason.delivery.domain.review.dto.request.ReviewRequestDto;
+import com.fourseason.delivery.domain.review.dto.response.ReviewResponseDto;
+import com.fourseason.delivery.domain.review.service.ReviewService;
+import lombok.Requ... | Java | 이 부분은 정확히 잘 모르겠지만, `reviewId` 처럼 카멜케이스로 작성되는 것이 더 좋을 것 같다는 생각이 들어요.
그렇게 생각하는 이유는 `@PathVariable` 에서도 `String review_id` 와 같이 사용되기 때문이에요. |
@@ -0,0 +1,28 @@
+package com.fourseason.delivery.domain.review.controller;
+
+import com.fourseason.delivery.domain.review.dto.response.ReviewResponseDto;
+import com.fourseason.delivery.domain.review.repository.ReviewRepository;
+import com.fourseason.delivery.domain.review.service.ReviewService;
+import lombok.Requi... | Java | `/api/shops` 부분은 공통으로 해도 될 것 같아요!
아니면, `ShopController`와 겹치기 때문일까요? |
@@ -0,0 +1,17 @@
+package com.fourseason.delivery.domain.review.repository;
+
+import com.fourseason.delivery.domain.order.entity.Order;
+import com.fourseason.delivery.domain.review.entity.Review;
+import com.fourseason.delivery.domain.shop.entity.Shop;
+import org.springframework.data.jpa.repository.JpaRepository;
+
... | Java | 소프트 딜리트에 대해 찾아보니까 JPA에서 `@SQLDelte` 나 `@Where`를 엔티티 클래스에 붙임으로써, 쉽게 구현할 수 있는 것 같아요. 같이 논의해보면 좋을 것 같습니다.
모든 삭제 쿼리메서드를 update로 하거나, 조회 시 `DeleteAtIsNotNull` 을 접미사로 붙인다면, 나중에 정책이 바뀌었을 때, 코드 수정이 번거로울 것 같아요.
어느 한 곳에서 삭제 정책에 따라 공통으로 처리되면 좋을 것 같다는 생각이 들었습니다. |
@@ -1,9 +1,100 @@
-function Header(logo, searchBox) {
+import Input from './Input';
+import Button from './Button';
+import { handleSearch } from '../services/handleSeach';
+
+function Header({ logoSrc, logoAlt, onSearch }) {
const headerElement = document.createElement('header');
- headerElement.classList.add(... | JavaScript | 저는 이벤트의 이름이 의미하는게 "행위의 발생" 이라고 생각해요.
가령, `onChange` 는 실제로 change가 일어났을 때이고, `onKeyDown` 은 키를 눌렀을 때 입니다.
`onSearch`는 "검색이 되었을 때 발생" 인데, 이 컴포넌트에서 실제로 "검색"이라는 행위가 일어났다고 할 수 있을까요?
지금은 "검색"이라는 행위를 밖에서 주입해주고, 이 컴포넌트 내부에서 일어난 일은 "엔터키를 눌렀음" 입니다.
즉, 이벤트는 "검색했을 때 발생함"을 이야기하고 있는데 검색이라는 기능은 밖에서 주입해줄 수 밖에 없는 상황인거죠. |
@@ -1,9 +1,100 @@
-function Header(logo, searchBox) {
+import Input from './Input';
+import Button from './Button';
+import { handleSearch } from '../services/handleSeach';
+
+function Header({ logoSrc, logoAlt, onSearch }) {
const headerElement = document.createElement('header');
- headerElement.classList.add(... | JavaScript | 이 부분도 동일합니다! |
@@ -1,9 +1,100 @@
-function Header(logo, searchBox) {
+import Input from './Input';
+import Button from './Button';
+import { handleSearch } from '../services/handleSeach';
+
+function Header({ logoSrc, logoAlt, onSearch }) {
const headerElement = document.createElement('header');
- headerElement.classList.add(... | JavaScript | 여기서 쓰이는 390 이라는 숫자는 상수로 만들어서 사용해주면 어떨까요!? |
@@ -1,9 +1,100 @@
-function Header(logo, searchBox) {
+import Input from './Input';
+import Button from './Button';
+import { handleSearch } from '../services/handleSeach';
+
+function Header({ logoSrc, logoAlt, onSearch }) {
const headerElement = document.createElement('header');
- headerElement.classList.add(... | JavaScript | 잘 보니까 로직이 거의 유사하네요! |
@@ -0,0 +1,33 @@
+import handleMovie from '../services/handleMovie';
+import Button from './Button';
+
+function MainContent(initialPage) {
+ let page = initialPage;
+ const mainElement = document.createElement('main');
+ mainElement.id = 'main';
+
+ mainElement.innerHTML = `
+ <section class="item-v... | JavaScript | ```suggestion
const mainElement = html(`
<main id="main">
<section class="item-view">
<h2>지금 인기 있는 영화</h2>
<ul class="item-list"></ul>
</section>
<main>
`);
```
이렇게 표현할 수 있도록 함수를 하나 만들어주시면 어떨까요!? |
@@ -0,0 +1,33 @@
+import handleMovie from '../services/handleMovie';
+import Button from './Button';
+
+function MainContent(initialPage) {
+ let page = initialPage;
+ const mainElement = document.createElement('main');
+ mainElement.id = 'main';
+
+ mainElement.innerHTML = `
+ <section class="item-v... | JavaScript | 위에서는 html template으로 표현되고 여기서는 이렇게 표현되고 있어서 코드를 읽는 사람 입장에서는 조금 헷갈리지 않을까 싶어요! |
@@ -0,0 +1,47 @@
+import { BASE_URL } from '../constants/api';
+import { APIError } from '../apis/error';
+
+interface ApiClientType {
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
+ endpoint: string;
+ params?: Record<string, string>;
+ headers?: Record<string, string>;
+ body?: Record<string, any>;
+}
+... | TypeScript | 아하.. 이 파일 때문에 tsconfig가 생긴거였군요 |
@@ -0,0 +1,47 @@
+import { BASE_URL } from '../constants/api';
+import { APIError } from '../apis/error';
+
+interface ApiClientType {
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
+ endpoint: string;
+ params?: Record<string, string>;
+ headers?: Record<string, string>;
+ body?: Record<string, any>;
+}
+... | TypeScript | try 구간에서 오류 발생 -> catch로 진입 -> 무조건 status는 400으로 고정하여 다시 error throw
이렇게 됩니다.
유의미한 에러 플로우일까요~? |
@@ -0,0 +1,47 @@
+import { BASE_URL } from '../constants/api';
+import { APIError } from '../apis/error';
+
+interface ApiClientType {
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
+ endpoint: string;
+ params?: Record<string, string>;
+ headers?: Record<string, string>;
+ body?: Record<string, any>;
+}
+... | TypeScript | 그런데 이 파일이 왜 domain 에 해당하는걸까요~?
domain이라고 하기엔 말 그대로 사이드 이펙트(client)를 표현한거라서... 전혀 연관이 없어보여요! |
@@ -0,0 +1,24 @@
+import getMovieList from '../apis/getMovieList';
+import ConfirmModal from '../components/modal/ConfirmModal';
+import { Modal } from '../components/modal/container/Modal';
+import { NOT_MORE_MOVIES_MESSAGE } from '../constants/message';
+import renderMovies from '../view/renderMovies';
+import render... | JavaScript | api에서 발생한 에러 중에 message만 사용하고 있는데, CustomError를 만들어서 쓰는 의미가 있는건가 싶어요! |
@@ -0,0 +1,47 @@
+import { BASE_URL } from '../constants/api';
+import { APIError } from '../apis/error';
+
+interface ApiClientType {
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
+ endpoint: string;
+ params?: Record<string, string>;
+ headers?: Record<string, string>;
+ body?: Record<string, any>;
+}
+... | TypeScript | domain이 apis를 참조하는건 어색해보여요! |
@@ -1,2 +1 @@
export const BASE_URL = 'https://api.themoviedb.org';
-export const IMAGE_BASE_URL = 'https://image.tmdb.org/t/p/w500'; | JavaScript | 이런 정보는 아예 API를 요청하는 쪽에서 가지고 있으면 어떨까요? |
@@ -0,0 +1 @@
+export const NOT_MORE_MOVIES_MESSAGE = '더이상 영화가 존재하지 않습니다.'; | JavaScript | 이런 에러 메세지도 메세지를 사용하는 쪽에서 가지고 있으면 어떨까요?
다른 구간에서는 아예 사용될 것 같지 않아서요! |
@@ -1,14 +1,40 @@
-import React from "react";
-import "./PostList.scss";
+import React, { useEffect, useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import Posts from './components/Posts';
+import './PostList.scss';
const PostList = () => {
+ const [postData, setPostData] = useState([]);
... | JavaScript | import 순서에도 유지보수 및 가독성을 위한 컨벤션이 있습니다.
위코드의 컨벤션은 간략하게 아래와 같고, 참고해서 수정해 주세요!
- 라이브러리
- React 관련 패키지
- 외부 라이브러리
- 컴포넌트
- 공통 컴포넌트 → 먼 컴포넌트 → 가까운 컴포넌트
- 함수, 변수 및 설정 파일
- 사진 등 미디어 파일(`.png`)
- css 파일 (.`scss`) |
@@ -0,0 +1,63 @@
+.postList {
+ margin: 0 auto;
+ display: flex;
+ width: 576px;
+ height: 80vh;
+ padding: 40px 24px;
+ flex-direction: column;
+ align-items: center;
+ border-radius: 16px;
+ border: 1px solid #e5e5e5;
+ background: white;
+
+ .posts {
+ width: 100%;
+ overflow-y: scroll;
+ flex: 1... | Unknown | 부모 선택자(`&`)를 사용해서 해당 요소에만 적용되는 스타일임을 좀 더 깔끔하게 명시할 수 있습니다!
```suggestion
.posts {
overflow-y: scroll;
flex: 1;
&::-webkit-scrollbar {
display: none;
}
}
``` |
@@ -1,7 +1,18 @@
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap');
-
* {
box-sizing: border-box;
font-family: 'Noto Sans KR', sans-serif;
-}
\ No newline at end of file
+}
+
+body {
+ width: 100vw;
+ height: 100vh;
+ display: flex;
+ align-item... | Unknown | 공용 파일을 수정해서 올려주셨는데, 공용 파일의 수정은
1. 팀원과의 충분한 상의 후에
2. 해당 파일만 수정하는 내용의 PR
을 올려주셔야 합니다! |
@@ -0,0 +1,8 @@
+import "./css/reset.css";
+import "./css/common.css";
+import App from "./App";
+
+addEventListener("DOMContentLoaded", async () => {
+ const app = new App();
+ app.init();
+}); | JavaScript | 요 함수가 바로 앱을 구동시키는 Entry 포인트군요!
`controller`를 초기화한다? 보다는 `App`을 초기화한다는 느낌이 어떨까요? |
@@ -0,0 +1,14 @@
+import { apiClient } from "./apiClient";
+import { BASE_URL } from "./constants";
+
+export const fetchPopularMovies = async ({ page = 1 }) => {
+ const param = new URLSearchParams({
+ api_key: process.env.TMDB_API_KEY,
+ language: "ko-KR",
+ page,
+ });
+
+ const response = await apiClien... | JavaScript | 오 좋습니다! |
@@ -0,0 +1,34 @@
+import { ApiError } from "./apiError";
+
+export const apiClient = {
+ get: async (url, headers = {}) => {
+ return apiClient.request("GET", url, null, headers);
+ },
+
+ request: async (method, url, body = null, headers = {}) => {
+ const options = {
+ method,
+ headers: {
+ ... | JavaScript | `request()`와 `get()`의 차이는 무엇이고 나눈 이유는 무엇일까요? |
@@ -0,0 +1,31 @@
+import { ERROR_MSG } from "./constants";
+
+export class ApiError extends Error {
+ constructor(message, details, status = -1) {
+ super(message);
+ this.details = details;
+ this.status = status;
+ }
+
+ static handle(error) {
+ let errMsg;
+ let errDetails;
+
+ switch (parseInt(... | JavaScript | 오 좋은 시도입니다 👍 |
@@ -0,0 +1,16 @@
+import { mainTitle, mainMoreButton, movieCardsList } from "./index";
+
+export const mainSection = {
+ render() {
+ const element = document.createElement("section");
+ element.classList.add("item-view");
+
+ const title = mainTitle.render();
+ const itemList = movieCardsList.render();
+ ... | JavaScript | [append()](https://developer.mozilla.org/en-US/docs/Web/API/Element/append)를 활용해보세요! |
@@ -0,0 +1,46 @@
+describe("API 테스트", () => {
+ it("영화 목록 API를 호출하면 20개씩 영화를 받아온다.", () => {
+ const baseUrl = "https://api.themoviedb.org/3/movie/popular";
+ const param = new URLSearchParams({
+ api_key: Cypress.env("TMDB_API_KEY"),
+ language: "ko-KR",
+ page: 1,
+ });
+
+ cy.request(`${b... | JavaScript | 오호?
`exist`로 검사하면 무엇이 다를까요? |
@@ -0,0 +1,46 @@
+describe("API 테스트", () => {
+ it("영화 목록 API를 호출하면 20개씩 영화를 받아온다.", () => {
+ const baseUrl = "https://api.themoviedb.org/3/movie/popular";
+ const param = new URLSearchParams({
+ api_key: Cypress.env("TMDB_API_KEY"),
+ language: "ko-KR",
+ page: 1,
+ });
+
+ cy.request(`${b... | JavaScript | 40으로 검사하는 이유는 초기 리스트 20 + 추가 더보기 20일까요? |
@@ -0,0 +1,34 @@
+import { ApiError } from "./apiError";
+
+export const apiClient = {
+ get: async (url, headers = {}) => {
+ return apiClient.request("GET", url, null, headers);
+ },
+
+ request: async (method, url, body = null, headers = {}) => {
+ const options = {
+ method,
+ headers: {
+ ... | JavaScript | `request()`는 매개변수로 받는 method를 통해 API 요청을 보내는 함수이고, `get()`은 해당 `request()` 함수에 `GET`요청을 보내는 함수입니다.
이번 과제에서 GET 요청만 존재하여 추가하진 않았지만 추후에 다른 메서드 요청을 추가할 수 있게 작성하였습니다! |
@@ -0,0 +1,46 @@
+describe("API 테스트", () => {
+ it("영화 목록 API를 호출하면 20개씩 영화를 받아온다.", () => {
+ const baseUrl = "https://api.themoviedb.org/3/movie/popular";
+ const param = new URLSearchParams({
+ api_key: Cypress.env("TMDB_API_KEY"),
+ language: "ko-KR",
+ page: 1,
+ });
+
+ cy.request(`${b... | JavaScript | 생성된 `movieCard`에는 썸네일, 별점, 제목 element가 `존재`한다는 의미에서 사용한 것 같습니다!
다시 생각해보니, 해당 element가 존재하지만 보여지지 않거나 어떤 css issue가 생길 수도 있다는 생각에 `be.visible`로 대체하였습니다. |
@@ -0,0 +1,46 @@
+describe("API 테스트", () => {
+ it("영화 목록 API를 호출하면 20개씩 영화를 받아온다.", () => {
+ const baseUrl = "https://api.themoviedb.org/3/movie/popular";
+ const param = new URLSearchParams({
+ api_key: Cypress.env("TMDB_API_KEY"),
+ language: "ko-KR",
+ page: 1,
+ });
+
+ cy.request(`${b... | JavaScript | 네 맞습니다! 이전 테스트에서 20개가 렌더링이 되었고 버튼을 클릭한 후에, 20개가 더 추가되어 40개를 검사하게 하였습니다.
새롭게 렌더링된 20개에 대해서 테스트를 진행하는 것이 더 올바른 검사일까요?
+) 추가로, 단위테스트에서는 샘플 값을 통해 도출되는 값을 검사하는 과정이 테스트의 핵심이었다고 생각되는데,
이번에 e2e에서는 값을 이용하여 검사하는 방향보다 렌더링되는 요소의 개수나 생성 여부를 중심적으로 코드를 작성한 것 같습니다.
그런 과정에서 단위 테스트는 값 중심, e2e는 전체적인 DOM 렌더링 중심 이렇게 자연스레 생각이 이어... |
@@ -1,11 +1,29 @@
import { useState } from "react";
+import Header from "./components/Header/Header";
+import Product from "./pages/Product";
+import GlobalStyles from "./styles/Global.style";
+import Toast from "./components/common/Toast/Toast";
+import { QuantityContext } from "./store/QuantityContext";
+import { cr... | Unknown | 여기 이 `showToast` 상태를 토스트 컴포넌트가 책임을 가질 수 있지 않을까 싶었는데, 그렇다면 createPortal을 사용할 수 없게 되나요..? createPortal을 사용해보지 않아서 잘 모르겠지만, 미리 열어둘 수 있다면 그쪽으로 상태를 옮겨봐도 좋을 것 같아요! |
@@ -0,0 +1,52 @@
+import { generateBasicToken } from "../util/auth";
+import { CART_ITEMS_ENDPOINT } from "./config";
+
+const USER_PASSWORD = import.meta.env.VITE_USER_PASSWORD;
+const USER_ID = import.meta.env.VITE_USER_ID;
+const token = generateBasicToken(USER_ID, USER_PASSWORD);
+
+export async function requestFet... | TypeScript | 필수는 아니지만 반복되는 fetch 로직들은 추상화해보셔도 좋을 것 같아요!ㅎㅎ |
@@ -0,0 +1,52 @@
+import { generateBasicToken } from "../util/auth";
+import { CART_ITEMS_ENDPOINT } from "./config";
+
+const USER_PASSWORD = import.meta.env.VITE_USER_PASSWORD;
+const USER_ID = import.meta.env.VITE_USER_ID;
+const token = generateBasicToken(USER_ID, USER_PASSWORD);
+
+export async function requestFet... | TypeScript | chat GPT한테 '이 코드 추상화 해봐'하면 기가막히게 해주더라구요 |
@@ -0,0 +1,10 @@
+import { generateBasicToken } from "../util/auth";
+
+const API_URL = import.meta.env.VITE_API_URL;
+
+export const PRODUCTS_ENDPOINT = `${API_URL}/products`;
+export const CART_ITEMS_ENDPOINT = `${API_URL}/cart-items`;
+
+export const USER_PASSWORD = import.meta.env.VITE_USER_PASSWORD;
+export const ... | TypeScript | api요청에 필요한 변수들이 잘 모여있어 관리하기 편할 것 같네요! 👍 |
@@ -0,0 +1,87 @@
+import { useContext, useEffect, useRef } from "react";
+import { QuantityContext } from "../../store/QuantityContext";
+import useProductList from "../../hooks/useProductList";
+import useCartItemList from "../../hooks/useCartItemList";
+import ProductItem from "../ProductItem/ProductItem";
+import * ... | Unknown | 페이지네이션 관련 로직도 커스텀 훅으로 분리하면 좋을 것 같아요! |
@@ -0,0 +1,87 @@
+import { useContext, useEffect, useRef } from "react";
+import { QuantityContext } from "../../store/QuantityContext";
+import useProductList from "../../hooks/useProductList";
+import useCartItemList from "../../hooks/useCartItemList";
+import ProductItem from "../ProductItem/ProductItem";
+import * ... | Unknown | 아무래도 이번 미션에서 가장 메인이 되는(?) 컴포넌트인 것 같아요. 비즈니스 로직과 UI 로직이 좀 더 잘 분리되면 더욱 읽기 좋을 것 같습니다! |
@@ -0,0 +1,13 @@
+package msa.customer.exception;
+
+public class DeliveryCustomerException extends RuntimeException {
+
+ public DeliveryCustomerException(String message) {
+ super(message);
+ }
+
+ public DeliveryCustomerException(String message, Throwable cause) {
+ super(message, cause);
+ ... | Java | (C) Exception은 서비스의 `정책 위반`을 나타내는 documentation의 역할을 하기도 합니다.
따라서 Exception을 통해 서비스 정책을 위반하는 경우, 정책을 명확하게 나타낼 수 있는 자체 exception을 정의하곤 하는데 delivery application에 적용해볼만한 exception 몇 개를 간략하게 구성해봤으니 참고해보시고 Exception들을 잘 정의해주시면 좋을 것 같습니다 :) |
@@ -3,6 +3,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import msa.customer.entity.store.Store;
+import msa.customer.exception.store.StoreEmptyException;
import msa.customer.service.store.StoreService;
import org.springframework.web.servlet.HandlerIntercepto... | Java | (C) optional은 벗겨진 상태로 오는게 좋겠지만, 일단 현재 상태를 가정하고 custom exception을 throw 했습니다 |
@@ -6,6 +6,7 @@
import msa.restaurant.dto.store.StoreResponseDto;
import msa.restaurant.entity.store.Store;
import msa.restaurant.dto.store.StoreSqsDto;
+import msa.restaurant.exception.store.StoreCreationFailedException;
import msa.restaurant.service.member.MemberService;
import msa.restaurant.sqs.SendingMessageC... | Java | (C) 여기도 StoreCreationFailedException을 던지지만, storeService.createStore 내부에서 exception 처리를 하고 나오는 것이 더 바람직해보입니다. |
@@ -18,39 +18,30 @@ public OrderService(OrderRepository orderRepository) {
this.orderRepository = orderRepository;
}
- public void createOrder(Order order){
+ public void createOrder(Order order) {
orderRepository.createOrder(order);
}
- public List<Order> getOrderList(String st... | Java | (C) changeOrderStatusTo~ 메서드의 내용이 대부분 중복되어서, 해당 메서드들을 changeOrderStatus라는 메서드로 통합하였습니다.
여기서 새로운 클래스인 OrderStatusUpdatePolicy가 만들어졌는데, ~Policy라는 명칭은 서비스 정책을 표현하기 위해 범용적으로 사용하는 클래스 네이밍 중 하나입니다.
delivery-application에도 서비스 운영에 필요한 여러가지 정책들을 갖고 있을텐데요, 이런 정책들은 클래스로 드러내지 않고 메서드나 로직으로만 나타내면 정책들이 분산되고, 암시적으로 표현되어서 우리 서비스가... |
@@ -0,0 +1,13 @@
+package msa.customer.exception;
+
+public class DeliveryCustomerException extends RuntimeException {
+
+ public DeliveryCustomerException(String message) {
+ super(message);
+ }
+
+ public DeliveryCustomerException(String message, Throwable cause) {
+ super(message, cause);
+ ... | Java | 참고하겠습니다. |
@@ -0,0 +1,152 @@
+package nextstep.subway.acceptance;
+
+import static nextstep.subway.acceptance.FavoritesSteps.즐겨찾기_권한이_없음;
+import static nextstep.subway.acceptance.FavoritesSteps.즐겨찾기_목록_조회_요청;
+import static nextstep.subway.acceptance.FavoritesSteps.즐겨찾기_삭제_요청;
+import static nextstep.subway.acceptance.FavoritesS... | Java | `즐겨찾기 목록을 관리한다` 에서 시나리오 형식으로 잘 작성해주셔서
해당 테스트들은 작성해주지 않아도 괜찮을 것 같아요 😄 |
@@ -0,0 +1,50 @@
+package nextstep.subway.applicaion;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import nextstep.member.application.MemberService;
+import nextstep.member.domain.LoginMember;
+import nextstep.member.domain.MemberRepository;
+import nextstep.subway.applicaion.dto.FavoriteRequest;
+im... | Java | memberRepository 를 사용하고 있지 않는데요,
즐겨찾기 생성, 조회, 삭제 시 유요한 memberId 인지 확인하지 않아도 될까요? 😄 |
@@ -22,10 +22,14 @@ public PathService(LineService lineService, StationService stationService) {
public PathResponse findPath(Long source, Long target) {
Station upStation = stationService.findById(source);
Station downStation = stationService.findById(target);
- List<Line> lines = lineSer... | Java | 접근제어자를 생략하신 이유가 있으신가요? 😄 |
@@ -0,0 +1,39 @@
+package nextstep.subway.applicaion.dto;
+
+import nextstep.subway.domain.Favorite;
+
+public class FavoriteResponse {
+ private Long id;
+ private Long memberId;
+ private StationResponse source;
+ private StationResponse target;
+
+ private FavoriteResponse(Long id, Long memberId,
+ ... | Java | 요구사항에 memberId 는 없네요!
요구사항을 확인해주세요 😄 |
@@ -0,0 +1,49 @@
+package nextstep.subway.ui;
+
+import java.net.URI;
+import java.util.List;
+import nextstep.auth.authorization.AuthenticationPrincipal;
+import nextstep.member.domain.LoginMember;
+import nextstep.subway.applicaion.FavoriteService;
+import nextstep.subway.applicaion.dto.FavoriteRequest;
+import nexts... | Java | 즐겨찾기 생성 후 반환값에 대한 요구사항을 확인해주세요! 😄
 |
@@ -1,5 +1,6 @@
package nextstep.subway.domain;
+import java.util.Optional;
import org.jgrapht.GraphPath;
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
@@ -22,6 +23,11 @@ public Path findPath(Station source, Station target) {
DijkstraShort... | Java | Optional 을 사용하신 이유가 있으신가요?
어떠한 이점이 있나요? 😄
```suggestion
if (Objects.isNull(result)) {
throw new IllegalArgumentException("출발역과 도착역이 연결되어 있지 않습니다.");
}
``` |
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -7,6 +7,7 @@
<title>react-shopping-products</title>
</head>
<body>
+ <div id="toast"></div>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body> | Unknown | 요것도 fileChanged에 올라와서 신기해서 남겨봄 ㅋㅋ |
@@ -0,0 +1,96 @@
+import objectToQueryString, { ObjectQueryParams } from '@/utils/objectToQueryString';
+import { generateBasicToken } from '../utils/auth';
+
+type Method = 'GET' | 'POST' | 'PATCH' | 'DELETE';
+
+type Body = ReadableStream | XMLHttpRequestBodyInit;
+type HeadersType = [string, string][] | Record<strin... | TypeScript | 이 파일에서 각 request를 추상화해준게 아주 인상깊었습니다!!!
배워감 총총총,, |
@@ -0,0 +1,96 @@
+import objectToQueryString, { ObjectQueryParams } from '@/utils/objectToQueryString';
+import { generateBasicToken } from '../utils/auth';
+
+type Method = 'GET' | 'POST' | 'PATCH' | 'DELETE';
+
+type Body = ReadableStream | XMLHttpRequestBodyInit;
+type HeadersType = [string, string][] | Record<strin... | TypeScript | 이거 왜 안함 ㅋㅋㅋ |
@@ -0,0 +1,96 @@
+import objectToQueryString, { ObjectQueryParams } from '@/utils/objectToQueryString';
+import { generateBasicToken } from '../utils/auth';
+
+type Method = 'GET' | 'POST' | 'PATCH' | 'DELETE';
+
+type Body = ReadableStream | XMLHttpRequestBodyInit;
+type HeadersType = [string, string][] | Record<strin... | TypeScript | 여기서 던지는 오류 메시지가 showToast에서 보이는 메시지에서는 활용을 안하고 있는 것 같아서
통일시키는 방식이나 사용자에게 보이는 오류 메시지를 어떻게 관리할지도 고민해보면 좋을 듯요!
(나도 해야함 ㅋ) |
@@ -0,0 +1,75 @@
+import { CartItem } from '@/types/cartItem.type';
+import { BASE_URL } from '../baseUrl';
+import { requestGet, requestPost, requestDelete } from '../fetcher';
+import { ENDPOINT } from '../endpoints';
+
+type ResponseCartItemList = {
+ content: CartItem[];
+ pageable: {
+ sort: {
+ sorted: ... | TypeScript | 사소한 의견인데, 저는 api 응답이 언제든 바뀔 수 있다고 생각해서 요런 타입은 type보다 interface로 선언하려는 편이긴 함다
그러면 pageable 같이 안쓰고 뭔가 다른 정보랑 중복되는 친구들은 안써줄 수도 있어서 오히려 리뷰어에게 쓸 친구들만 interface에 선언해줄 수 있다는 장점도 있다고 생각했슴다.
(interface의 단점은 없을까 생각도 되는데 함 찾아봐야겠다) |
@@ -0,0 +1,29 @@
+.container {
+ position: relative;
+}
+
+.cartIcon {
+ cursor: pointer;
+}
+
+.amountContainer {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ width: 19px;
+ height: 19px;
+ background: #fff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-radius: 50%;
+}
+
+... | Unknown | 이거 갠적인 궁금증인데 이거 두개 필요함?! |
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -7,6 +7,7 @@
<title>react-shopping-products</title>
</head>
<body>
+ <div id="toast"></div>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body> | Unknown | 저도 이게 왜 된지 모르겠네요.... ㅋ.ㅋ |
@@ -0,0 +1,96 @@
+import objectToQueryString, { ObjectQueryParams } from '@/utils/objectToQueryString';
+import { generateBasicToken } from '../utils/auth';
+
+type Method = 'GET' | 'POST' | 'PATCH' | 'DELETE';
+
+type Body = ReadableStream | XMLHttpRequestBodyInit;
+type HeadersType = [string, string][] | Record<strin... | TypeScript | 맞아요. 사실 어디서 던진 오류가 캐치되고 그런걸 확인을 안해서 에러 바운더리와 비슷한 설계로 이를 해결할 수 있지 않을까 싶습니다. 한번 시도해볼게요! |
@@ -0,0 +1,29 @@
+.container {
+ position: relative;
+}
+
+.cartIcon {
+ cursor: pointer;
+}
+
+.amountContainer {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ width: 19px;
+ height: 19px;
+ background: #fff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-radius: 50%;
+}
+
+... | Unknown | 긁어온 것 같네요. 필요 없을듯...! |
@@ -41,7 +41,7 @@ public Object checkReviewGroupAccess(ProceedingJoinPoint joinPoint,
private boolean canMemberAccess(ReviewGroup reviewGroup, HttpServletRequest request) {
GitHubMember gitHubMember = sessionManager.getGitHubMember(request);
- return gitHubMember != null && reviewGroup.getMemberI... | Java | **문제가 되는 부분은 이 부분이었습니다.**
회원이 접근하려는 리뷰 그룹이 "비회원이 만든 리뷰그룹"인 경우,
reviewGroup.getMemberId() 가 null 이기 때문에
long인 gitHubMember.getMemberId() 와의 == 연산을 못하므로 NPE가 발생합니다.
이런 일이 생기지 않게하려면 1차원적으로
`gitHubMember != null && (reviewGroup.getMemberId() != null && reviewGroup.getMemberId() == gitHubMember.getMemberId())` 를 할수... |
@@ -57,6 +57,13 @@ void setUp() {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
}
+ @Test
+ void 존재하지_않는_리뷰에_접근하면_NotFound_예외가_발생한다() {
+ // when & then
+ assertThatCode(() -> aopTestClass.testReviewMethod(1L))
+ .isInstanceOf(Review... | Java | 소소하게 테스트 코드 리팩터링했습니다.
생각해보면 비회원은 자기가 만들지 않았더라도 비밀번호가 일치하면 통과되는거라 "리뷰 그룹을 인증한" 으로 명확한 의미를 전달하려 했씁니다~ |
@@ -0,0 +1,99 @@
+## 우아한 테크코스 프리코스 크리스마스 프로모션
+
+### 진행방식
+- 시작 메시지 출력
+- 방문 날짜 입력
+- 주문 메뉴와 개수 입력
+- 입력 요일 이벤트 메시지 출력
+- 이벤트 혜택 출력
+ - 주문 메뉴
+ - 할인 전 총 주문 금액
+ - 증정 메뉴 여부
+ - 혜택 내역 여부
+ - 할인 후 예상 결제 금액
+ - 12월 이벤트 배지 여부
+
+### 주요 구현 사항
+- [x] 입력 뷰 구현
+- [x] 출력 뷰 구현
+
+- [x] 날짜 입력 및 저장 객체 구현
+- [x] 날짜 입력 시 날짜관련 해... | Unknown | README에 클래스이름을 작성하기보다 어떤 역할의 클래스인지 정도만 작성하시는게 더 좋을 것 같습니다! 아무래도 클래스이름이나 메소드 이름은 가변성이 높다보니 README도 주기적으로 업데이트해야해서 번거로움이 크거든요 |
@@ -0,0 +1,20 @@
+package christmas.exception;
+
+public enum ExceptionMessage {
+ INVALID_INPUT_DATE("유효하지 않은 날짜입니다. 다시 입력해 주세요."),
+ INVALID_INPUT_ORDER("유효하지 않은 주문입니다. 다시 입력해 주세요."),
+ INVALID_MENU_ITEM("해당 메뉴가 존재하지 않습니다."),
+ INVALID_WEEK_DISCOUNT_TYPE("잘못된 주간 할인 타입입니다."),
+ ;
+
+ private static f... | Java | 추가될 enum을 고려하셔서 이렇게 작성한 의도라고 생각은 되지만, 꼼꼼하고 파고들자면 ,;보다 ;로 끝내는게 더 좋지 않을까요?? 개인적인 생각입니다 ㅎㅎㅎ |
@@ -1,7 +1,20 @@
package christmas;
+
+import camp.nextstep.edu.missionutils.Console;
+import christmas.run.PromotionRun;
+import christmas.view.InputView;
+import christmas.view.OutputView;
+
public class Application {
public static void main(String[] args) {
- // TODO: 프로그램 구현
+ try {
+ ... | Java | 뷰를 싱글톤으로 관리하신 이유가 궁금합니다! |
@@ -0,0 +1,20 @@
+package christmas.exception;
+
+public enum ExceptionMessage {
+ INVALID_INPUT_DATE("유효하지 않은 날짜입니다. 다시 입력해 주세요."),
+ INVALID_INPUT_ORDER("유효하지 않은 주문입니다. 다시 입력해 주세요."),
+ INVALID_MENU_ITEM("해당 메뉴가 존재하지 않습니다."),
+ INVALID_WEEK_DISCOUNT_TYPE("잘못된 주간 할인 타입입니다."),
+ ;
+
+ private static f... | Java | 추가적으로 요구사항에 에러메시지는 "[ERROR] 유효하지 않은 주문입니다. 다시 입력해 주세요."으로 통일하라고 기재되어 있어 최종코딩테스트로 가시게 되면 꼼꼼히 보시면 좋을 것 같습니다. |
@@ -0,0 +1,33 @@
+package christmas.model.event;
+
+import christmas.model.date.ReservationDate;
+
+public class ChristmasDiscount {
+ private static final int FIRST_DAY = 1;
+ private static final int CHRISTMAS_DAY = 25;
+ private static final int BASIC_DISCOUNT = 1000;
+ private static final int PLUS_DISC... | Java | ReservationDate에서 스스로 자신이 가진 값에대해 검증하도록 메소드를 구현하시는 것이 더 객체지향적인 코드라고 생각합니다.
date.isChristmasDay() 와 같이 말이죠!! 'getter를 지양하라'는 의미는 VO에게도 동일하게 적용됩니다.
관련 문서를 아래 링크로 달아둘게요!
https://tecoble.techcourse.co.kr/post/2020-04-28-ask-instead-of-getter/ |
@@ -0,0 +1,62 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+
+public class DiscountDetail {
+ private final int totalPriceBeforeDiscount;
+ private final int totalPriceAfterDiscount;
+ private final WeekDiscountType weekDiscountType;
+ private final int chr... | Java | DiscountDetil의 필드로 이 값들을 굳이 가져야 할 이유가 있을까요? 재사용의 여지가 없다면 메소드를 통해 메시지를 전달하는 방식이 더 좋다고 생각해요! |
@@ -0,0 +1,62 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+
+public class DiscountDetail {
+ private final int totalPriceBeforeDiscount;
+ private final int totalPriceAfterDiscount;
+ private final WeekDiscountType weekDiscountType;
+ private final int chr... | Java | 외부 생성을 막기 위해 생성자를 protected로 관리하신 것으로 보이는데, private으로 생성자를 막고 정적팩토리메소드 생성자를 사용하면 더 엄밀하게 캡슐화할 수 있습니다! 관련 자료를 아래 링크로 달아둘게요!
https://hudi.blog/effective-java-static-factory-method/ |
@@ -0,0 +1,91 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+import christmas.model.menu.MenuItem;
+
+import java.util.*;
+import java.util.stream.Stream;
+
+public class EventResult {
+ private static final int MIN_EVENT_AMOUNT = 10_000;
+ private static final in... | Java | 필드 수를 줄여 응집도를 낮추면 좋을 것 같습니다. 버그가 발생하면 리펙토링할부분이 많아져요!! |
@@ -0,0 +1,91 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+import christmas.model.menu.MenuItem;
+
+import java.util.*;
+import java.util.stream.Stream;
+
+public class EventResult {
+ private static final int MIN_EVENT_AMOUNT = 10_000;
+ private static final in... | Java | 이 부분도 getter로 꺼내와서 검증하기보다 객체 내부에서 스스로검증하도록 하면 좋을 것 같습니다 |
@@ -0,0 +1,28 @@
+package christmas.model.event;
+
+public enum SpecialDayDiscount {
+ THIRD_DAY(3, 1000),
+ TENTH_DAY(10, 1000),
+ SEVENTEENTH_DAY(17, 1000),
+ TWENTY_FOURTH_DAY(24, 1000),
+ TWENTY_FIFTH_DAY(25, 1000),
+ THIRTY_FIRST_DAY(31, 1000),
+ OTHER_DAY(0, 0),
+ ;
+
+ private final in... | Java | 1000원이라는 동일한 할인금액을 가지고 있으니 List로 관리하는 방법도 괜찮을 것 같습니다! |
@@ -0,0 +1,55 @@
+package christmas.model.menu;
+
+import christmas.exception.ExceptionMessage;
+import christmas.exception.PromotionException;
+
+import java.util.Arrays;
+
+public enum MenuItem {
+ APPETIZER_MUSHROOM_SOUP("양송이수프", 6_000, MenuCategory.APPETIZER),
+ APPETIZER_TAPAS("타파스", 5_500, MenuCategory.APPE... | Java | MenuCategory, MenuItem에서 중복되는 요소들이 있는데 하나로 묶어도 될 것 같아요! |
@@ -0,0 +1,79 @@
+package christmas.model.menu;
+
+import christmas.exception.ExceptionMessage;
+import christmas.exception.PromotionException;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class OrderMenus {
+ private static final int MIN_ORDER_MENU_NUMBER = ... | Java | Integer도 원시값을 포장하는 것은 어떨까요?? |
@@ -0,0 +1,76 @@
+package christmas.run;
+
+import christmas.controller.PromotionController;
+import christmas.exception.PromotionException;
+import christmas.model.event.dto.EventResultDTO;
+import christmas.model.event.dto.ReservationDateEventDTO;
+import christmas.model.menu.dto.OrderMenusDTO;
+import christmas.view... | Java | 필드주입보다 생성자 주입이 유지보수 관점에서 더 좋을 것 같아요.!! |
@@ -0,0 +1,76 @@
+package christmas.run;
+
+import christmas.controller.PromotionController;
+import christmas.exception.PromotionException;
+import christmas.model.event.dto.EventResultDTO;
+import christmas.model.event.dto.ReservationDateEventDTO;
+import christmas.model.menu.dto.OrderMenusDTO;
+import christmas.view... | Java | 제너릭을 사용하신 부분이 인상깊습니다.! |
@@ -0,0 +1,27 @@
+package christmas.util;
+
+enum EventResultText {
+ ORDER_OUTPUT_REGEX("%s %d%s"),
+ EMPTY_TEXT(""),
+ SPACE(" "),
+ MENU_NUMBER("개"),
+ MENU_PRICE_UNIT("원"),
+ CHRISTMAS_D_DAY_DISCOUNT("크리스마스 디데이 할인"),
+ SPECIAL_DISCOUNT("특별 할인"),
+ GIFT_EVENT("증정 이벤트"),
+ NONE_BENEFIT("없음"... | Java | 연관성이 없는 상수들은 static final로 관리하는 것이 더 가독성 측면에서 좋다고 생각해요 ! |
@@ -0,0 +1,99 @@
+## 우아한 테크코스 프리코스 크리스마스 프로모션
+
+### 진행방식
+- 시작 메시지 출력
+- 방문 날짜 입력
+- 주문 메뉴와 개수 입력
+- 입력 요일 이벤트 메시지 출력
+- 이벤트 혜택 출력
+ - 주문 메뉴
+ - 할인 전 총 주문 금액
+ - 증정 메뉴 여부
+ - 혜택 내역 여부
+ - 할인 후 예상 결제 금액
+ - 12월 이벤트 배지 여부
+
+### 주요 구현 사항
+- [x] 입력 뷰 구현
+- [x] 출력 뷰 구현
+
+- [x] 날짜 입력 및 저장 객체 구현
+- [x] 날짜 입력 시 날짜관련 해... | Unknown | 아 좋은 생각이네요. 이후 관리에는 생각하지 않았던 것 같습니다 |
@@ -1,7 +1,20 @@
package christmas;
+
+import camp.nextstep.edu.missionutils.Console;
+import christmas.run.PromotionRun;
+import christmas.view.InputView;
+import christmas.view.OutputView;
+
public class Application {
public static void main(String[] args) {
- // TODO: 프로그램 구현
+ try {
+ ... | Java | 한번만 생성되면 되고 새로운 객체를 생성할 필요가 없겠다 싶어 적용했는데 컨트롤러, 서비스 모두 적용해야하나 싶다가 뷰만 생성하게 되었습니다.. |
@@ -0,0 +1,20 @@
+package christmas.exception;
+
+public enum ExceptionMessage {
+ INVALID_INPUT_DATE("유효하지 않은 날짜입니다. 다시 입력해 주세요."),
+ INVALID_INPUT_ORDER("유효하지 않은 주문입니다. 다시 입력해 주세요."),
+ INVALID_MENU_ITEM("해당 메뉴가 존재하지 않습니다."),
+ INVALID_WEEK_DISCOUNT_TYPE("잘못된 주간 할인 타입입니다."),
+ ;
+
+ private static f... | Java | 아 해당 예외는 이미 처리된 결과 DTO 들을 가지고 발생되는 예외라서 정상적이라면 터지지 않는 예외 입니다. 일단 제 생각으로는 무슨 짓을 해도 입력에 대해 해당 예외는 터지지는 않을 거라 생각하는데 해당 기능에서만 터지는 예외를 구분하기 위해서 사용했습니다! |
@@ -0,0 +1,33 @@
+package christmas.model.event;
+
+import christmas.model.date.ReservationDate;
+
+public class ChristmasDiscount {
+ private static final int FIRST_DAY = 1;
+ private static final int CHRISTMAS_DAY = 25;
+ private static final int BASIC_DISCOUNT = 1000;
+ private static final int PLUS_DISC... | Java | 예약 일자 객체는 예약된 일자에 대해서만 값을 가지고 있어 할인을 적용하기 위한 유효성 검사를 해당 할인 객체가 수행해야 한다고 생각해서 넣었는데 고민이 되네요.. |
@@ -0,0 +1,62 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+
+public class DiscountDetail {
+ private final int totalPriceBeforeDiscount;
+ private final int totalPriceAfterDiscount;
+ private final WeekDiscountType weekDiscountType;
+ private final int chr... | Java | 객체가 가지고 있는 상태의 객체를 표현하려 하다보니 이렇게 되었는데 아직도 메서드로 메시지를 전달하는 방법은 아직 낯선 것 같습니다.. 중간중간 인지하려해도 놓치는 부분이 많네요.. |
@@ -0,0 +1,62 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+
+public class DiscountDetail {
+ private final int totalPriceBeforeDiscount;
+ private final int totalPriceAfterDiscount;
+ private final WeekDiscountType weekDiscountType;
+ private final int chr... | Java | 여러 객체를 생성하고 static으로 객체를 생성하는 방법보다는 저는 개인적으로 해당 기능은 할인이 없을 경우의 객체를 오버로딩을 통해 생성하는게 좋다고 생각됩니다 |
@@ -0,0 +1,91 @@
+package christmas.model.event;
+
+import christmas.model.event.dto.ReservationDateEventDTO;
+import christmas.model.menu.MenuItem;
+
+import java.util.*;
+import java.util.stream.Stream;
+
+public class EventResult {
+ private static final int MIN_EVENT_AMOUNT = 10_000;
+ private static final in... | Java | 그 부분은 @Dongwoongkim 님의 코드를 보고 확실히 그렇다고 느껴졌던 것 같습니다. 해당 객체 안에 있어야한다고 바라보니 그렇게 생각을 못했던 것 같아요.. EventResult를 파라미터로 객체를 생성하는 방법이 저도 더 올바른 것 같습니다 |
@@ -0,0 +1,28 @@
+package christmas.model.event;
+
+public enum SpecialDayDiscount {
+ THIRD_DAY(3, 1000),
+ TENTH_DAY(10, 1000),
+ SEVENTEENTH_DAY(17, 1000),
+ TWENTY_FOURTH_DAY(24, 1000),
+ TWENTY_FIFTH_DAY(25, 1000),
+ THIRTY_FIRST_DAY(31, 1000),
+ OTHER_DAY(0, 0),
+ ;
+
+ private final in... | Java | 좋은 생각입니다! enum에 자료구조를 넣을 생각을 못했던 것 같아요 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.