-
Notifications
You must be signed in to change notification settings - Fork 176
1단계 - 리팩터링 (상품) #326
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
Open
seovalue
wants to merge
9
commits into
next-step:seovalue
Choose a base branch
from
seovalue:step1
base: seovalue
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
1단계 - 리팩터링 (상품) #326
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
769540c
refactor: rename Product to ProductRecord
seovalue d1aa49a
feat: implement Product
seovalue acfa03b
refactor: rename to checkBadWordClient
seovalue fbe238c
Rename .java to .kt
seovalue 6615134
refactor: Separate product creation into Request/Response, Product an…
seovalue 90eff4e
refactor: Update product price change logic
seovalue 00b7003
refactor: Update read all products
seovalue 4e513f1
temp: temporary commits
seovalue e7ade81
refactor: Separate updateMenuDisplay
seovalue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ## 도메인 주도 설계 기본 요소 | ||
| ### 1단계 - 리팩터링(상품) | ||
| - 키친포스의 요구 사항과 용어 사전, 모델링을 기반으로 상품 CONTEXT를 리팩터링한다. | ||
| - 상품 CONTEXT의 도메인 계층만 먼저 구현한다. | ||
| - products 패키지 밑에 tobe.domain 패키지를 만들고 거기서부터 구현을 시작한다. | ||
| - 용어 사전과 모델링이 부자연스럽거나 불완전하거나 잘못된 경우 지속적으로 수정한다. | ||
| - 새로운 모델에 맞게끔 클래스, 메서드, 모듈의 이름을 다시 지으면서 코드를 리팩터링한다. | ||
| - REPOSITORY 구현 시 자신에게 익숙하고 편한 것을 선택하여 진행한다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/main/java/kitchenpos/products/domain/JpaProductRepository.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package kitchenpos.products.domain | ||
|
|
||
| import java.math.BigDecimal | ||
| import java.util.* | ||
|
|
||
| data class Product( | ||
| val id: UUID, | ||
| private val name: ProductName, | ||
| private val price: ProductPrice, | ||
| ) { | ||
| fun getName(): String { | ||
| return name.name | ||
| } | ||
|
|
||
| fun getPrice(): BigDecimal { | ||
| return price.price | ||
| } | ||
|
|
||
| fun changePrice(price: BigDecimal): Product { | ||
| return Product( | ||
| id, | ||
| name, | ||
| ProductPrice.create(price) | ||
| ) | ||
| } | ||
|
|
||
| companion object { | ||
| fun create(name: String, price: BigDecimal): Product { | ||
| return Product( | ||
| UUID.randomUUID(), | ||
| ProductName.create(name), | ||
| ProductPrice.create(price) | ||
| ) | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/main/java/kitchenpos/products/domain/ProductJpaRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package kitchenpos.products.domain | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import java.util.* | ||
|
|
||
| interface ProductJpaRepository : JpaRepository<ProductRecord, UUID> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package kitchenpos.products.domain | ||
|
|
||
| class ProductName private constructor( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VO로 분리해주셨네요~! 👍 |
||
| val name: String, | ||
| ) { | ||
| companion object { | ||
| fun create(value: String): ProductName { | ||
| validateNull(value) | ||
| return ProductName(value) | ||
| } | ||
|
|
||
| private fun validateNull(value: String) { | ||
| if (value.isBlank()) { | ||
| throw IllegalArgumentException("Invalid product name: $value") | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이번 미션 항목들은 각 kitchenpos.products.tobe.* 위치해야해요~!