code
stringlengths
41
34.3k
lang
stringclasses
8 values
review
stringlengths
1
4.74k
@@ -0,0 +1,102 @@ +import Foundation +import RxSwift + +enum NetworkError: Error, LocalizedError { + case statusCodeError + case unknownError + case urlIsNil + + var errorDescription: String? { + switch self { + case .statusCodeError: + return "정상적인 StatusCode가 아닙니다." + c...
Swift
NetworkProvider().request(api: api) 의 모양이 나올 것 같은데요. 매 케이스마다 다른 NetworkProvider가 필요해 보이지도 않고요. NetworkProvider 를 매번 얻어와야 하는게 번거로와보여요. api.execute()는 어떨까요. excute 안에 NetworkProvider의 로직을 담는거죠. 서로 다른 provider가 필요하다면, APIProtocol 내부에 명시하는 식으로 해결하면 될 것 같고요.
@@ -0,0 +1,102 @@ +import Foundation +import RxSwift + +enum NetworkError: Error, LocalizedError { + case statusCodeError + case unknownError + case urlIsNil + + var errorDescription: String? { + switch self { + case .statusCodeError: + return "정상적인 StatusCode가 아닙니다." + c...
Swift
Observable.create 가 필요하지 않아보입니다.
@@ -0,0 +1,52 @@ +import Foundation + +struct OpenMarketBaseURL: BaseURLProtocol { + var baseURL = "https://market-training.yagom-academy.kr/" +} + +struct HealthCheckerAPI: Gettable { + var url: URL? + var method: HttpMethod = .get + + init(baseURL: BaseURLProtocol = OpenMarketBaseURL()) { + sel...
Swift
var / let 확인 바랍니다.
@@ -0,0 +1,37 @@ +import UIKit + +struct FlowCoordinator { + // MARK: - Properties + weak private var navigationController: UINavigationController? + private var productListViewController: ProductListViewController! + private var productListViewModel: ProductListViewModel! + private var menuSegmentedCont...
Swift
class type을 property로 들고있으니, struct보다는 class가 어울려보입니다.
@@ -0,0 +1,37 @@ +import UIKit + +struct FlowCoordinator { + // MARK: - Properties + weak private var navigationController: UINavigationController? + private var productListViewController: ProductListViewController! + private var productListViewModel: ProductListViewModel! + private var menuSegmentedCont...
Swift
!는 쓰지 않는걸로 해요.
@@ -0,0 +1,37 @@ +import UIKit + +struct FlowCoordinator { + // MARK: - Properties + weak private var navigationController: UINavigationController? + private var productListViewController: ProductListViewController! + private var productListViewModel: ProductListViewModel! + private var menuSegmentedCont...
Swift
FlowCoordinator 가 다르게 말하면 AppLevel의 Coordinator로 이해되는데요. ProductList의 로직과 의존성이 커서 ProductList 전용 Coordinator 처럼 보입니다. 저라면 ProductListCoordinator 정도를 만들어서 ProductList 로직을 모듈화하고요. FlowCoordinator의 rootCoordinator를 ProductListCoordinator 로 두어서 FlowCoordinator와 ProductListCoordinator의 관계를 분리할 것 같습니다.
@@ -0,0 +1,46 @@ +import UIKit + +class ProductDetailImageCell: UICollectionViewCell { + // MARK: - Properties + private let productImageView: UIImageView = { + let imageView = UIImageView() + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.contentMode = .scaleAspectFi...
Swift
이 경우 init에 param이 없으므로, init coder 살려도 될 것 같아요. required init?(coder: NSCoder) { super.init(coder: coder) configureUI() }
@@ -0,0 +1,57 @@ +import Foundation +import RxSwift +import UIKit + +class ProductDetailViewModel { + // MARK: - Nested Types + struct Input { + let invokedViewDidLoad: Observable<Void> + let cellDidScroll: Observable<IndexPath> + } + + struct Output { + let product: Observable<Deta...
Swift
inputObserver 와 fetchProduct 를 flatMap으로 엮어서 product observer를 만들 수 있을 것 같네요. 고민해봐주세요. subscribe는 꼭 필요한 위치에만 해주세요.
@@ -0,0 +1,57 @@ +import Foundation +import RxSwift +import UIKit + +class ProductDetailViewModel { + // MARK: - Nested Types + struct Input { + let invokedViewDidLoad: Observable<Void> + let cellDidScroll: Observable<IndexPath> + } + + struct Output { + let product: Observable<Deta...
Swift
output 파라미터가 많이 보이는데요. 마치 inout 키워드와 비슷한 기능을 하는 것으로 좋은 코드로 보이지 않습니다. output을 하고싶다면 return type을 쓰면 됩니다.
@@ -0,0 +1,53 @@ +import UIKit + +final class BannerCell: UICollectionViewCell { + // MARK: - Properties + private let stackView: UIStackView = { + let stackView = UIStackView() + stackView.style(axis: .vertical, alignment: .fill, distribution: .fill) + return stackView + }() + private ...
Swift
reusable cell은 storable property를 들고있을 이유가 거의 없습니다. cell은 UI 껍데기 일 뿐이지, 특정 데이터를 대표할 수 없습니다. apply쪽에는 UI 세팅을 위한 ViewModel 만 전달 하면 되고요. 이 cell이 어떤 productID로 구성되었는지 궁금하다면, cell의 indexPath를 이용해서 직접 얻어내면 됩니다.
@@ -0,0 +1,53 @@ +import UIKit +import RxSwift +import RxCocoa + +final class FooterView: UICollectionReusableView { + // MARK: - Properties + private let bannerPageControl: UIPageControl = { + let pageControl = UIPageControl() + pageControl.translatesAutoresizingMaskIntoConstraints = false + ...
Swift
bind가 N번 호출되었을 때 subscribe가 N번 될 가능성은 없을지 검토 바랍니다.
@@ -0,0 +1,176 @@ +import UIKit + +final class GridListCell: UICollectionViewCell { + // MARK: - Nested Types + private enum Design { + static let nameLabelTextColor: UIColor = .black + static let stockLabelTextColor: UIColor = .systemOrange + static let priceLabelTextColor: UIColor = .system...
Swift
저는 Design을 파일 최 하단으로 뺴고있습니다. 한 번 작성되면 볼 일이 거의 없는 코드라서요.
@@ -0,0 +1,22 @@ +import UIKit + +extension UIStackView { + func style(axis: NSLayoutConstraint.Axis, + alignment: UIStackView.Alignment, + distribution: UIStackView.Distribution, + spacing: CGFloat = .zero) { + self.translatesAutoresizingMaskIntoConstraints = false +...
Swift
이부분은 프로퍼티를 클로저로 생성하는 부분에서 반복되는 부분이 많아 메서드를 통해 프로퍼티를 set할 수 있도록 했습니다!!
@@ -0,0 +1,24 @@ +import UIKit + +extension UIImageView { + func loadImage(of key: String) { + let cacheKey = NSString(string: key) + if let cachedImage = ImageCacheManager.shared.object(forKey: cacheKey) { + self.image = cachedImage + return + } + + Dispatch...
Swift
말씀해주신대로 메서드이름만 봐서는 Cache 기능을 내포하는 것을 알 수 없어서 loadCachedImage(of key: String)로 수정했습니다!
@@ -0,0 +1,120 @@ +import UIKit + +struct MultipartFormData { + private(set) var boundary: String + let contentType: String + private(set) var body: Data = Data() + + init(uuid: String = UUID().uuidString) { + self.boundary = "Boundary-\(uuid)" + self.contentType = "multipart/form-data; bo...
Swift
createFormData와 createImageFormData 모두 create로 메서드 이름을 변경하고, 매개변수를 통해 구분할 수 있도록 했습니다. 현재 프로젝트에서 Post하는 타입이 product 밖에 없으므로 item은 product라는 이름으로 구체화시켰습니다.
@@ -0,0 +1,52 @@ +import Foundation + +struct OpenMarketBaseURL: BaseURLProtocol { + var baseURL = "https://market-training.yagom-academy.kr/" +} + +struct HealthCheckerAPI: Gettable { + var url: URL? + var method: HttpMethod = .get + + init(baseURL: BaseURLProtocol = OpenMarketBaseURL()) { + sel...
Swift
모두 initializer에서 지정하는 프로퍼티라서 let으로 변경했습니다.
@@ -0,0 +1,22 @@ +package kr.wooco.woocobe.placereview.adapter.out.presistence.entity + +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Id +import jakarta.persistence.Table +import kr.wooco.woocobe.common.infrastructure.storage.Tsid +import kr.wooco.woocobe.common.infra...
Kotlin
`place_Review_id` -> `place_review_id` 대문자 없애주세유
@@ -1,3 +1,5 @@ -import date from './date.svg'; -export * from './Eyes'; +import date from "./date.svg"; +export * from "./Eyes"; export { date }; +import Logo from "./Logo.svg"; +export { Logo };
TypeScript
svg는 import logo from './logo.svg'; export {logo}; 이런 식으로 해주어야할텐데 지금 정상 작동하시나요? 그리고 이미지는 소문자로 네이밍하는 것이 좋습니다.
@@ -0,0 +1,65 @@ +import styled from "styled-components"; +import { Logo } from "../../assets"; +import { useState } from "react"; +import { LoginBtn } from "../header/LoginBtn"; +import { font } from "../../theme"; + +export const Header = () => { + const [isLogined, setIsLogined] = useState<boolean>(false); + + ret...
Unknown
이건 왜 이렇게 불러오시나용
@@ -37,6 +37,8 @@ public PageReviewRes<ReviewRes> getPagedReviewsByTemplestayId(Long templestayId, throw new TemplestayCoreException(ErrorCode.REVIEW_NOT_FOUND); } + Long count = reviewRepository.countByTempleName(templeName); + List<ReviewRes> reviewDtos = reviews.getContent().s...
Java
리뷰 전체 개수를 반환하여 프론트에서 페이징 처리에 도움을 받을 수 있을 것 같습니다! 굿
@@ -0,0 +1,23 @@ +package kdt.prgrms.kazedon.everevent.common; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import kdt.prgrms.kazedon.everevent.domain.user.UserType; +import org.springframework.security.test.context.support.WithSecurityContext; + +@Retention(RetentionPolicy.R...
Java
Long 으로 하는게 더 좋아보이네요 :)
@@ -0,0 +1,23 @@ +package kdt.prgrms.kazedon.everevent.common; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import kdt.prgrms.kazedon.everevent.domain.user.UserType; +import org.springframework.security.test.context.support.WithSecurityContext; + +@Retention(RetentionPolicy.R...
Java
앗 그러네요! 감사함니당 👍👍
@@ -0,0 +1,185 @@ +package kdt.prgrms.kazedon.everevent.domain.like; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.LocalDateTime; +import java.util.Optional; +import kdt.prgrms.kazedon.everevent.domain.event.Event; +import kdt.prgrms.kazedon.everevent.domain.event.repository.EventRepo...
Java
아래서 검증하니깐 이건 괜찮지 않을까요?
@@ -0,0 +1,164 @@ +package kdt.prgrms.kazedon.everevent.domain.review; + +import static org.assertj.core.api.Assertions.*; + +import java.time.LocalDateTime; +import kdt.prgrms.kazedon.everevent.domain.event.Event; +import kdt.prgrms.kazedon.everevent.domain.event.repository.EventRepository; +import kdt.prgrms.kazedon....
Java
assertAll()을 한번 써보면 좋을거 같네요 :)
@@ -0,0 +1,197 @@ +package kdt.prgrms.kazedon.everevent.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.time....
Java
프로젝트가 거대해지면서 테스트에 대해서 중복코드가 굉장히 많아 지죠 :) TestFixture라는걸 한번 적용해보면 어떠신가요?
@@ -0,0 +1,197 @@ +package kdt.prgrms.kazedon.everevent.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.time....
Java
오 한번 적용해보겠습니다!! Fixture 클래스에 static 변수로 객체 생성해놓고 사용하면 코드가 많이 깔끔해지겠네용 😸
@@ -0,0 +1,164 @@ +package kdt.prgrms.kazedon.everevent.domain.review; + +import static org.assertj.core.api.Assertions.*; + +import java.time.LocalDateTime; +import kdt.prgrms.kazedon.everevent.domain.event.Event; +import kdt.prgrms.kazedon.everevent.domain.event.repository.EventRepository; +import kdt.prgrms.kazedon....
Java
넵!
@@ -0,0 +1,185 @@ +package kdt.prgrms.kazedon.everevent.domain.like; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.LocalDateTime; +import java.util.Optional; +import kdt.prgrms.kazedon.everevent.domain.event.Event; +import kdt.prgrms.kazedon.everevent.domain.event.repository.EventRepo...
Java
그러네여..ㅠ 삭제해도 괜찮을 것 같숨다
@@ -1,2 +1,219 @@ -.MainKang { +@mixin center { + display: flex; + justify-content: center; +} + +@mixin middle { + display: flex; + flex-direction: column; +} + +@mixin boxes { + width: 100%; + margin: 5px auto; + border: 1px solid rgb(220, 219, 219); + background-color: white; +} + +.entire-area { + @include...
Unknown
다른 부분에서는 잘 해주셨는데, 선택자 간에는 한 줄 띄워주세요! 그리고 `id` 선택자보다는, `className` 을 활용해주시기 바랍니다. 이유는 다음과 같습니다. - HTML에서 `id` 는 문서 내에서 유일해야 합니다. 이러한 이유로 단일 요소를 다루는 경우 `id`를 사용할 수 있습니다. - 하지만 정말로 해당 요소에 대한 이벤트나 스타일 핸들링이 프로젝트 전체에서 단 한번만 사용 되는지 충분히 고민해야합니다. 일반적으로 컴포넌트는 재사용 될 수 있기 때문에 같은 요소가 여러번 생성될 수 있습니다. 이러한 이유로 보통의 경우에는 `classN...
@@ -1,9 +1,30 @@ import React from 'react'; import './LoginKang.scss'; +import LoginValidation from './components/LoginValidation'; class LoginKang extends React.Component { render() { - return <div className="LoginKang">LoginKang</div>; + return ( + <div className="whole-area"> + <section> + ...
JavaScript
kebab-case와 camelCase를 혼용하고 계시네요! 통일해서 사용해주셔야 합니다.
@@ -1,9 +1,30 @@ import React from 'react'; import './LoginKang.scss'; +import LoginValidation from './components/LoginValidation'; class LoginKang extends React.Component { render() { - return <div className="LoginKang">LoginKang</div>; + return ( + <div className="whole-area"> + <section> + ...
JavaScript
확인 후 수정하였습니다 :)
@@ -1,2 +1,219 @@ -.MainKang { +@mixin center { + display: flex; + justify-content: center; +} + +@mixin middle { + display: flex; + flex-direction: column; +} + +@mixin boxes { + width: 100%; + margin: 5px auto; + border: 1px solid rgb(220, 219, 219); + background-color: white; +} + +.entire-area { + @include...
Unknown
확인 후 수정했습니당
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
송현님, validation을 기본값으로는 false로 주신 뒤 조건 (in.includes('@') && pwd.length>=5) 이 true일 경우 validation도 true로 변해서 버튼이 활성화 되는 기능을 구현하신 것이죠? 저는 render()안의 버튼에 조건에 따라 삼항 연산자로 class명을 주고, 스타일링을 다르게 해서 색상만 변경됐었는데 버튼 활성화 자체를 구현하신 것 보고 많이 배웠습니다👍
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
송현님, 여기서 bind(this)를 사용하신 것은 어떤 의미인지 여쭤봐도 될까요? 꼭 필요한 요소인지 궁금합니다!
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
네 맞아요. form 자체에 submit 이벤트를 발생시키면 추후에 문제가 생길 수 있어서 유효성 검사 함수는 따로 빼주는게 좋습니다.
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
저도 궁금합니다! 펑션 안에서 this 쓸 때, 바깥의 this 받으려고 사용하는 걸로 알고 있었는데 this.setState 때문에 사용하신건가요?
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
리액트 클래스 컴포넌트에서 bind를 사용하지 this는 `undefined`로 인식해요 그래서 이 경우에 this를 알려줘야 하는데 두가지 방법이 있어요. 1. 태그 자체에서 이벤트를 화살표 함수로 써주는 것입니다. ex) `<input onChange={(e) => handleChange(e)} >` 2. 저는 첫 번째 방식이 가독성이 좋지 않아서 차라리 리액트 문서에서 권장하는 두 번째 방식으로 [this를 연결](https://ko.reactjs.org/docs/handling-events.html)했습니다.
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
궁금해서 질문 남깁니다! [event.target.name]은 위에 state 선언할 때 없는데, input 태그에 이름을 주기 위한건가요? 그렇다면, 혹시 처음 render 할때는 'id'를 넣고, 값 변경될때 값을 이름에 넣어주신 이유가 궁금합니다!
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
옆집에서 구경왔습니다:)코드가 정말 섬세하세요!! 덕분에 bind, 유효성 검증 관련해서 배우고 갑니다:)! 감사합니다~
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
송현님, 이해했습니다! 저는 bind를 하지 않고도 잘 실행되어서 의아했는데, arrow function을 사용했었네요~! 링크까지 걸어주시는 상세한 설명에 감동했습니다~ ㅠㅠ
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
맞습니다. input 태그에 name, value 속성을 이용해서 onChange이벤트가 발생하면 원하는 곳에 값을 넣어주기 위해서 입니다. 리액트 사이트에서 [다중 입력 제어하기](https://ko.reactjs.org/docs/forms.htmll) 읽으시면 도움 되실 거 같네요!
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
this에 대해서 잘 고민해보시고 bind 메소드까지 잘 찾아서 적용해주셨네요! - 다만 여기서 handleInput 함수는 이미 arrow function으로 작성을 했기에 내부적으로 this를 가지지않고 상위 스코프의 this를 사용하기에 필수적이지 않습니다 - 함수선언 + bind method로 this가 바인딩된 새로운 함수 재생성 보다는 arrow function 으로 한번 작성하는게 간편하고 가독성이 좋기에 arrow function 사용을 권장드립니다.
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
👍 구조분해할당까지 해주시면 더 깔끔하겠네요 ``` const {name, value} = event; this.setState{{[name] : value}} ```
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
[공식문서 React로 사고하기](https://ko.reactjs.org/docs/thinking-in-react.html#step-3-identify-the-minimal-but-complete-representation-of-ui-state) 를 보시면 어떤 값들이 state가 되어야하는지에 대해 적혀있습니다. > 각각 살펴보고 어떤 게 state가 되어야 하는 지 살펴봅시다. 이는 각 데이터에 대해 아래의 세 가지 질문을 통해 결정할 수 있습니다 > 1. 부모로부터 props를 통해 전달됩니까? 그러면 확실히 state가 아닙니다. > 2. 시...
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
- snake-case를 이용해서 className 부여하고 계시군요, nesting을 위해서 최상위 태그에 부여하는 클래스네임은 클레스네임의 중복을 피하고, 일반적인 클래스네임과 구분하기 위해서 PascalCase로 작성해주는것도 좋아보이네요 - 이런 부분은 컨벤션적인 부분이기에 팀끼리 합의해서 진행해주시면 되지만 위코드내에서는 컴포넌트 이름과 동일하게 PascalCase를 사용하는것을 권장하고있습니다(권장일 뿐 필수는 아니기에 컨벤션은 팀원끼리 합의해서 적용하시면 됩니다.)
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
autoComplete, aria-label 등의 속성까지 세심하게 신경쓰셨네요👍
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
이렇게 자주 사용되는 반복되는 속성은 mixin 형태로 만들어서 사용하는것도 좋습니다.
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
css 속성 순서 가이드라인에 맞춰주세요
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
style을 부여하지 않는 경우에는 굳이 className 부여 및 네스팅 할 필요 없습니다!
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
여기서 부여하고 있었네요 해당 셀렉터의 스타일은 셀렉터 바로 하위에 적어주세요 이렇게 네스팅이 쭉 있고 그 뒤에 있으면 가독성측면에서 좋지않습니다.
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
scss의 extends 문법 활용하면 좋겠네요
@@ -0,0 +1,78 @@ +.login { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + border: 1px solid #bdbdbd; + text-align: center; + background: rgb(250, 250, 250); + + .login-container { + width: 350px; + height: 350px; + padding: 0 40px; + border: 1px solid silver; +...
Unknown
불필요한 주석은 삭제해주세요
@@ -0,0 +1,19 @@ +import React, { Component } from 'react'; + +class Comment extends Component { + render() { + const { profile, name, content } = this.props; + return ( + <li className="feeds-comment__reply"> + <div className="user-feeds__profile--img"> + <img src={profile} alt="피드사진" /> + ...
JavaScript
```suggestion {!this.props.profile && ( <img src={this.props.profile} alt="피드사진" /> ) ``` - !== 연산자 불필요해보입니다, 빈 문자열은 falsy 값이기에 not 연산자와 조합해서 빈문자열이 아닐때를 표현 가능합니다. - true일 경우에만 렌더링되면 된다면 삼항연산자말고 && 연산자를 이용해보세요
@@ -0,0 +1,19 @@ +import React, { Component } from 'react'; + +class Comment extends Component { + render() { + const { profile, name, content } = this.props; + return ( + <li className="feeds-comment__reply"> + <div className="user-feeds__profile--img"> + <img src={profile} alt="피드사진" /> + ...
JavaScript
props 구조분해할당해서 사용하면 좋아보이네요
@@ -0,0 +1,43 @@ +import React, { Component } from 'react'; +import Comment from './Comment/Comment'; +import './CommentList.scss'; + +class CommentList extends Component { + constructor(props) { + super(props); + this.state = { + commentList: [], + }; + } + componentDidMount() { + fetch('http://loc...
JavaScript
data라는 광범위한 변수명보다는 의미가 드러나게 변수명 지어주세요
@@ -1,7 +1,246 @@ -import React from 'react'; +import React, { Component } from 'react'; +import CommentList from './CommentList/CommentList'; +import IconList from './IconList/IconList'; +import userImg from '../../../assets/images/IMG_2625.jpg'; +import feedImg from '../../../assets/images/feed.jpg'; +import './Main....
JavaScript
이렇게 반복되는 UI는 Array.map을 활용해서 표현해보세요 정적인 컨텐츠라면 상수데이터와 조합하면 표현 가능해보입니다.
@@ -1,7 +1,246 @@ -import React from 'react'; +import React, { Component } from 'react'; +import CommentList from './CommentList/CommentList'; +import IconList from './IconList/IconList'; +import userImg from '../../../assets/images/IMG_2625.jpg'; +import feedImg from '../../../assets/images/feed.jpg'; +import './Main....
JavaScript
이 파일에서 반복되는 UI 많이 보이는데 다 한번 Array.map을 이용해서 표현해보세요
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
네 코드 리뷰 적용하겠습니다.
@@ -1,7 +1,77 @@ -import React from 'react'; +import React, { Component } from 'react'; +import './Login.scss'; -function Login() { - return <div>Nav bar</div>; +class Login extends Component { + constructor(props) { + super(props); + this.state = { + id: '', + pwd: '', + }; + } + + handleInput...
JavaScript
감사합니다 ㅎㅎ
@@ -5,16 +5,18 @@ export default class ReviewMapper { constructor(private readonly review: ReviewAllProperties) {} toDomain() { + if (!this.review) return null; + return new Review({ id: this.review.id, - writerId: this.review.writerId, - writer: this.review.writer, - ownerId: this...
TypeScript
저도 이렇게 했는거 같긴 한데 if문 안에서 null 값과 undefined값을 체크해서 리턴문 이후로 옵셔널로 줄 필요는 없는거 같아요
@@ -1,4 +1,5 @@ import { IsInt, IsNotEmpty, IsPositive, IsString, IsUUID } from 'class-validator'; +import { Type } from 'class-transformer'; export class CreateReviewDTO { @IsUUID() @@ -18,3 +19,13 @@ export class CreateReviewDTO { @IsNotEmpty() planId: string; } + +export class GetReviewsQueryDTO { + @...
TypeScript
기본값을 주려면 isOptional이 있어야되지 않나요? 테스트해서 괜찮던가요?
@@ -14,13 +14,13 @@ export interface ReviewProperties { export interface ReviewAllProperties { id?: string; - writerId: string; + writerId?: string; writer?: UserReference; - ownerId: string; + ownerId?: string; owner?: UserReference; rating: number; content: string; - planId: string; + planId?:...
TypeScript
플랜이 삭제되더라도 리뷰는 남아있는 프로세스인가요? 그렇다는 전제하에 저희는 논리삭제라서 planId는 옵셔널이 아니여도 될거같아요. 플랜은 옵셔널로 유지해야겠네요. 여기 createdAt과 updatedAt이 옵셔널이 아니여도 괜찮지 않나요?
@@ -5,16 +5,18 @@ export default class ReviewMapper { constructor(private readonly review: ReviewAllProperties) {} toDomain() { + if (!this.review) return null; + return new Review({ id: this.review.id, - writerId: this.review.writerId, - writer: this.review.writer, - ownerId: this...
TypeScript
리턴문에 옵셔널을 안 넣으면, 예를 들면 지금 PR에 올린 리뷰 목록 조회 때는 writer 데이터는 include를 하지 않고 매핑하니까 값이 없는데 문제 없나요???
@@ -1,4 +1,5 @@ import { IsInt, IsNotEmpty, IsPositive, IsString, IsUUID } from 'class-validator'; +import { Type } from 'class-transformer'; export class CreateReviewDTO { @IsUUID() @@ -18,3 +19,13 @@ export class CreateReviewDTO { @IsNotEmpty() planId: string; } + +export class GetReviewsQueryDTO { + @...
TypeScript
네 다시 테스트해봤는데 문제 없어요! 저 참고로 PlanQueryOptionDTO 참고해서 작성했습니다 ㅎㅎㅎ
@@ -14,13 +14,13 @@ export interface ReviewProperties { export interface ReviewAllProperties { id?: string; - writerId: string; + writerId?: string; writer?: UserReference; - ownerId: string; + ownerId?: string; owner?: UserReference; rating: number; content: string; - planId: string; + planId?:...
TypeScript
사실 이 인터페이스는 실제 프로세스에서 리뷰 객체를 이루는 데에 필요한 필드를 기준으로 만들어서 rating, content 말고는 다 옵셔널입니다.. 예를 들면 지금 만든 API의 경우 plan에 대한 내용이 필요없기 때문에 planId를 db에서 가져오지도 않거든요. 이제 만들게 될 dreamer의 내가 작성한 리뷰 목록에는 필요하고요. 옵셔널이 너무 많아서 타입 안정성이 좀 애매하다면 인터페이스를 아예 나누거나 해야할 것 같습니다.
@@ -5,16 +5,18 @@ export default class ReviewMapper { constructor(private readonly review: ReviewAllProperties) {} toDomain() { + if (!this.review) return null; + return new Review({ id: this.review.id, - writerId: this.review.writerId, - writer: this.review.writer, - ownerId: this...
TypeScript
저 옵셔널은 review가 있는지 체크하는거지 않나요?
@@ -1,4 +1,5 @@ import { IsInt, IsNotEmpty, IsPositive, IsString, IsUUID } from 'class-validator'; +import { Type } from 'class-transformer'; export class CreateReviewDTO { @IsUUID() @@ -18,3 +19,13 @@ export class CreateReviewDTO { @IsNotEmpty() planId: string; } + +export class GetReviewsQueryDTO { + @...
TypeScript
그렇군요,,
@@ -14,13 +14,13 @@ export interface ReviewProperties { export interface ReviewAllProperties { id?: string; - writerId: string; + writerId?: string; writer?: UserReference; - ownerId: string; + ownerId?: string; owner?: UserReference; rating: number; content: string; - planId: string; + planId?:...
TypeScript
이해했습니다
@@ -14,13 +14,13 @@ export interface ReviewProperties { export interface ReviewAllProperties { id?: string; - writerId: string; + writerId?: string; writer?: UserReference; - ownerId: string; + ownerId?: string; owner?: UserReference; rating: number; content: string; - planId: string; + planId?:...
TypeScript
나누기보단 그냥 옵셔널로 타입개수를 줄이죠
@@ -5,16 +5,18 @@ export default class ReviewMapper { constructor(private readonly review: ReviewAllProperties) {} toDomain() { + if (!this.review) return null; + return new Review({ id: this.review.id, - writerId: this.review.writerId, - writer: this.review.writer, - ownerId: this...
TypeScript
this.review에 해당 값이 없으면 undefined 값을 할당한다고 합니다 (혹시나 해서 다시 찾아봤습니다 ㅎㅎㅎ)
@@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".ArchiveReviewFragment" > + + ...
Unknown
여기의 컨텍스트는 .ArchiveReviewFragment로 추정됩니다.
@@ -0,0 +1,22 @@ +package common; + +import domain.gameresult.GameResult; +import domain.gameresult.GameResults; +import domain.player.Player; +import domain.player.Players; + +import java.util.HashMap; +import java.util.Map; + +public class PlayerGameResult { + public static Map<String, String> match(Players player...
Java
이 클래스가 꼭 필요할까요? common 패키지에 위치한 이유와 각 책임을 다른 클래스들로 위임할 수 없을지 고민해보면 좋을 것 같습니다.
@@ -0,0 +1,22 @@ +package common; + +import domain.gameresult.GameResult; +import domain.gameresult.GameResults; +import domain.player.Player; +import domain.player.Players; + +import java.util.HashMap; +import java.util.Map; + +public class PlayerGameResult { + public static Map<String, String> match(Players player...
Java
command + , java code style method chaining multi line 부분에 체크하고 정렬하시면 가독성 좋게 정렬됩니다 ~ 추천드려요
@@ -0,0 +1,22 @@ +package common; + +import domain.gameresult.GameResult; +import domain.gameresult.GameResults; +import domain.player.Player; +import domain.player.Players; + +import java.util.HashMap; +import java.util.Map; + +public class PlayerGameResult { + public static Map<String, String> match(Players player...
Java
get 으로 가져와서 구현하는 것보다 Tell don't ask 원칙을 적용해보면 어떨까요?
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
상태값이 존재하지 않도록 구현해서 static 하게 사용해보면 어떨까요
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
Players 가 아닌 Factory 클래스를 도입했을 때 어떤 장점이 있을까요?
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
controller 에서 input 을 받는게 아니므로 메서드명을 바꿔보면 어떨까요? 심플하게 getGameResultNames() 는 어떨까요
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
null 로 할당하는 것과 ArrayList 로 할당하는 것 중 어느게 더 효율적일까요
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
Ladder 의 생성자를 통해 생성하지 않고 Generator 를 통해 생성하면 어떤 장점이 있을까요
@@ -0,0 +1,46 @@ +package domain.player; + +import domain.line.Line; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Players { + + private List<Player> players; + + public Players(List<Player> players) { + this.playe...
Java
getPlayerNames 는 어떨까요
@@ -0,0 +1,46 @@ +package domain.player; + +import domain.line.Line; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Players { + + private List<Player> players; + + public Players(List<Player> players) { + this.playe...
Java
player.getPositionX(); 로 디미터법칙을 지켜보면 어떨까요
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
getDirectionFlags() 는 어떤가요?
@@ -0,0 +1,28 @@ +package domain.gameresult; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class GameResults { + private List<GameResult> gameResults; + + public GameResults(List<GameResult> gameResults) { + this.gameRes...
Java
객체의 상태를 변환하는게 아니고 반환하는 것이므로 get 이라는 동사어가 어울릴 것 같습니다
@@ -0,0 +1,106 @@ +package controller; + +import common.PlayerGameResult; +import domain.gameresult.GameResultFactory; +import domain.gameresult.GameResultName; +import domain.gameresult.GameResults; +import domain.ladder.Height; +import domain.ladder.Ladder; +import domain.ladder.LadderGenerator; +import domain.player...
Java
Collection 프레임워크 네이밍을 참고해보면 players.contains(playerName) 이 더 자연스럽지 않을까요~?
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
this.points = points 로 하면 어떻게 될까요?
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
unmodifiable 로 한번 감싼 이유가 있으실까요?
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
array out of index 에러는 걱정하지 않아도 되는건가요?
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
find 와 get 메서드 네이밍의 차이가 무엇일까요?
@@ -0,0 +1,32 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Line { + private List<Point> points; + + public Line(List<Point> points) {...
Java
points 를 Line 으로 추상화하신 것 같은데 getPoints() 가 필요한 케이스가 있을까요?
@@ -0,0 +1,21 @@ +package domain.gameresult; + +import domain.player.Position; + +public class GameResult { + private GameResultName name; + private Position position; + + public GameResult(GameResultName name, Position position) { + this.name = name; + this.position = position; + } + + pub...
Java
생성자와 getter 뿐인데 이건 DTO 역할인가요?
@@ -0,0 +1,17 @@ +package domain.gameresult; + +import domain.player.Position; + +import java.util.ArrayList; +import java.util.List; + +public class GameResultFactory { + + public static GameResults from(List<GameResultName> gameResultNames, int positionY) { + List<GameResult> gameResults = new ArrayList<>()...
Java
생성을 Factory 로 모두 위임한 이유가 궁금합니다. Factory 없이 도메인 클래스의 정적 팩토리 메서드를 통해 생성하면 어떤 안 좋은 점이 있을까요? 그리고 GameResultsFactory 가 아닐까요?
@@ -0,0 +1,21 @@ +package domain.ladder; + +public class Height { + private static final String INPUT_POSITIVE_MESSAGE = "[ERROR] 높이는 0 초과를 입력합니다."; + private int height; + + public Height(int height) { + validatePositive(height); + this.height = height; + } + + public void validatePositive...
Java
private 이어야 하지 않을까요~?
@@ -0,0 +1,18 @@ +package domain.ladder; + +import domain.line.Line; +import domain.line.LineGenerator; + +import java.util.ArrayList; +import java.util.List; + +public class LadderGenerator { + + public static Ladder generate(int ladderHeight, int playerCount) { + List<Line> lines = new ArrayList<>(); + ...
Java
Ladder 로 위임하면 어떨까요
@@ -0,0 +1,49 @@ +package domain.line; + +import domain.point.Point; +import domain.point.RandomPointGenerator; + +import java.util.ArrayList; +import java.util.List; + +public class LineGenerator { + + public static Line generate(int playerCount) { + List<Point> points = new ArrayList<>(); + if (playe...
Java
Line 뿐만 아니라 Point, List<Point> 타입까지 생성하고 있는데 각자 위임될만한 도메인 클래스가 있지 않을까요? 한번 고민해보면 좋을 것 같습니다.
@@ -0,0 +1,35 @@ +package domain.player; + +import domain.point.Direction; + +public class Player { + private Name name; + private Position position; + + public Player(Name name, Position position) { + this.name = name; + this.position = position; + } + + public void move(Direction directio...
Java
인터페이스를 활용해서 if 문을 없앨 수 있지 않을까요?
@@ -0,0 +1,46 @@ +package domain.player; + +import domain.line.Line; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class Players { + + private List<Player> players; + + public Players(List<Player> players) { + this.playe...
Java
이 메서드는 어디서 사용되는건가요~?
@@ -0,0 +1,54 @@ +package domain.player; + +import java.util.Objects; + +public class Position { + private static final String NEGATIVE_ERROR_MESSAGE = "[ERROR] Position의 x, y 값은 양수입니다."; + private int x; + private int y; + + public Position(int x, int y) { + validateNegative(x, y); + this.x =...
Java
equals 와 hashcode 를 재정의한 이유를 설명해주시면 좋을 것 같아요~
@@ -0,0 +1,65 @@ +package domain.point; + +public class Point { + private static final String CONTINUOUS_CONNECTION_BRIDGE_ERROR_MESSAGE = "[ERROR] 다리는 연속되어 존재할 수 없습니다."; + + private boolean left; + private boolean right; + private Direction direction; + + public Point(boolean left, boolean right) { + ...
Java
check 라는 메서드는 Direction 을 반환하기에 적절하지 않은 메서드명인 것 같습니다. getConnectedDirection() 은 어떨까요
@@ -0,0 +1,12 @@ +package domain.point; + +import java.util.Random; + +public class RandomPointGenerator { + + private static Random random = new Random(); + + public static boolean generate() { + return random.nextBoolean(); + } +}
Java
역할은 Random 을 감싼 wrapper 클래스인데 Point 라는 제한을 이름으로 주게 되는 것 같습니다. RandomGenerator util 로 보면 어떨까요
@@ -0,0 +1,80 @@ +package domain.line; + +import domain.point.Direction; +import domain.point.Point; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class LineTest { + + ...
Java
good 테스트 잘 작성하셨네요