Skip to content
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

πŸš€ 2단계 - μˆ˜κ°•μ‹ μ²­(도메인 λͺ¨λΈ) #627

Open
wants to merge 23 commits into
base: mingulee-devel
Choose a base branch
from

Conversation

mingulee-devel
Copy link

μ•ˆλ…•ν•˜μ„Έμš”!
μ§€λ‚œλ²ˆμ— ν”Όλ“œλ°± μ£Όμ…¨λ˜ λ‚΄μš©κ³Ό ν•¨κ»˜ 2단계 PR λ“œλ¦½λ‹ˆλ‹€
μ§„μ˜λ‹˜μ΄ 말씀해주신 λŒ€λ‘œ 사닀리 κ²Œμž„μ΄ λλ‚˜κ³  PRλ“œλ¦΄κΉŒ ν•˜λ‹€κ°€ 리뷰 κΈ°λ‹€λ¦¬λŠ” λ™μ•ˆ μ˜¬λ €λ΄…λ‹ˆλ‹€!

μš”κ΅¬μ‚¬ν•­μ— μ νžŒλŒ€λ‘œ ν•œλ‹€κ³  ν–ˆλŠ”λ° μ œκ°€ 객체λ₯Ό 잘 λ‚˜λˆˆκ±΄μ§€ λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€
슀슀둜 해보고 μ‹Άμ–΄μ„œ μ΅œλŒ€ν•œ λ‹€λ₯Έ λΆ„λ“€μ˜ μ½”λ“œλ₯Ό ν™•μΈν•˜μ§€ μ•Šκ³  ν–ˆλŠ”λ°
진전이 μ—†μ–΄μ„œ PR λ“œλ¦½λ‹ˆλ‹€!

ν˜Ήμ‹œ λ³΄μ‹œκ³  힌트λ₯Ό μ£Όμ‹€ 수 μžˆμ„κΉŒμš”?!

μ½”λ“œμ—μ„œ todoλ₯Ό λ‹¬μ•„λ†“μ•˜λŠ”λ°μš”
SessionStrategyλ₯Ό μƒμ†λ°›λŠ” FreeSessionμ΄λž‘ PaidSession λ‚˜λˆ„μ–΄μ„œ PaidSession에 canEnroll이 true일 λ•Œ paymentλ₯Ό 더해주렀고 ν–ˆλŠ”λ° λ­”κ°€ 이 뢀뢄이 μ–΄μƒ‰ν•˜κ²Œ λŠκ»΄μ§‘λ‹ˆλ‹€... 😒

μ˜€λŠ˜λ„ 잘 뢀탁 λ“œλ¦½λ‹ˆλ‹€ πŸ˜„


1단계 ν”Όλ“œλ°± 반영

  • λΆˆν•„μš” setDeleted μ‚¬μš© 제거
  • DeleteHistory μƒμ„±μžκ°€ μ•„λ‹Œ 정적 νŒ©ν† λ¦¬ λ©”μ„œλ“œλ‘œ μƒμ„±ν•˜λ„λ‘ μˆ˜μ •
  • QuestionBody, Deleted, Answers 뢄리

Copy link

@jinyoungchoi95 jinyoungchoi95 left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” λ―Όμ„ λ‹˜ πŸ˜„

λͺ‡κ°€μ§€ μ½”λ©˜νŠΈ λ‚¨κ²¨λ‘μ—ˆλŠ”λ° ν™•μΈλΆ€νƒλ“œλ €μš” :)

κΆκΈˆν•˜κ±°λ‚˜ 고민이 λ˜λŠ” 뢀뢄이 μžˆμœΌμ‹œλ‹€λ©΄ μ–Έμ œλ“  pr μ½”λ©˜νŠΈ λ˜λŠ” dm으둜 μš”μ²­ λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.
κ°μ‚¬ν•©λ‹ˆλ‹€ πŸ™‡β€β™‚οΈ


import nextstep.payments.domain.Payment;

public class FreeSession implements SessionStrategy {

Choose a reason for hiding this comment

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

Sessionμ΄λΌλŠ” 도메인이 이미 있고 ν˜„μž¬ κ΅¬ν˜„μ²΄λŠ” Session에 λ”°λ₯Έ 결제 μ „λž΅μ΄κΈ° λ•Œλ¬Έμ— 넀이밍이 FreeSessionEnrollStrategy와 같이 쑰금 더 λͺ…ν™•ν•˜λ©΄ 쒋을 것 κ°™μ•„μš” :)

Comment on lines +25 to +34
public void enroll(Payment payment){ //todo
if(canEnroll(payment)){
payments.add(payment);
}
}

@Override
public boolean canEnroll(Payment payment) {
return !isFull() && payment.isTuitionPaid(tuitionFee);
}

Choose a reason for hiding this comment

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

ꡬ쑰가 μ–΄μƒ‰ν•΄λ³΄μ΄λŠ” μ΄μœ λŠ” PaidSessionEnrollStrategyλ₯Ό μ–΄λ–»κ²Œ ν™œμš©ν• κ±΄μ§€ λͺ…ν™•ν•˜μ§€ μ•Šμ•„μ„œμΈ 것 κ°™μ•„μš”. μ§€κΈˆ μ„€κ³„ν•œ 객체의 μ—­ν• λ‘œλ³΄λ©΄,

  • κ°•μ˜κ°€ κ²°μ œκ°€λŠ₯ν•œ 상황인지 확인해쀀닀.
    • 이λ₯Ό μœ„ν•΄ ν˜„μž¬ μˆ˜κ°•μƒ 수, μ΅œλŒ€ μˆ˜κ°•μƒ 수, κ°•μ˜λ£Œλ₯Ό 가진닀.
  • 결제λ₯Ό λ°›μ•„ μˆ˜κ°•λ“±λ‘ν•œλ‹€.

라고 바라본닀면 SessionEnrollStrategyλŠ” "μˆ˜κ°• 등둝"μ΄λΌλŠ” λͺ…μ œλ§Œ λ™μž‘ν•΄μ£Όλ©΄λ˜κ³ , canEnroll이 λ˜μ§€ μ•ŠλŠ”λ‹€λ©΄ μ˜ˆμ™Έλ₯Ό ν„°νŠΈλ¦¬λŠ” λ“±κ³Ό 같은 ν–‰μœ„λ‘œ 생각해볼 수 μžˆμ„ 것 κ°™μ•„μš”.

public interface SessionEnrollStrategy {    
    void enroll(Payment payment);
}

κ°€ λ˜μ–΄μ•Όν•˜κ³ ,

public class PaidSessionEnrollStrategy {
   // ..
   public void enroll(Payment payment) {
        // canEnroll이 μ•„λ‹Œ 경우 μ˜ˆμ™Έ
        // countλ₯Ό 올리고 κ²°μ œμ •λ³΄ μ €μž₯

이 될 수 있겠죠. λ‹€λ§Œ ν•΄λ‹Ή ν΄λž˜μŠ€λ„ μ „λž΅μœΌλ‘œ 뢈리고 있기 λ•Œλ¬Έμ— ν˜Όλ™μ„ 쀄 수 μžˆλŠ”λ°μš”. "μ „λž΅"μ΄λΌλŠ” 것은 μ–΄λ–€ ν–‰μœ„λ₯Ό μ–΄λ–»κ²Œ μ‹€ν–‰ν•˜λŠλƒκ°€ μ£Όμš” 관심사이지 μƒνƒœλ₯Ό λ“€κ³  κ΄€λ¦¬ν•˜λ©΄μ„œ μ „λž΅μ„ μΆ”κ΅¬ν•˜λŠ”κ±΄ μ „λž΅μžμ²΄μ˜ μ±…μž„μ„ ν™•μž₯μ‹œμΌœλ²„λ¦΄ 수 μžˆμ–΄μš”. 좔상화λ₯Ό ν†΅ν•œ 접근은 λ§žμ§€λ§Œ μ „λž΅μ΄λƒλŠ” κ³ λ―Όν•΄λ³΄μ‹œλ©΄ 쒋을 것 κ°™λ„€μš” :)

Comment on lines +5 to +7
public class Sessions {
private List<Session> values;
}

Choose a reason for hiding this comment

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

개인적으둜 λ‹¨μˆœνžˆ λž˜ν•‘λ§Œν•˜λŠ” ν΄λž˜μŠ€λŠ” μΌκΈ‰μ»¬λž™μ…˜μœΌλ‘œ 묢을 ν•„μš”λŠ” μ—†λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. νŠΉμ • 도메인 μ±…μž„ 없이 리슀트이기 λ•Œλ¬Έμ— μΌκΈ‰μ»¬λž™μ…˜μœΌλ‘œ λ‘”λ‹€λŠ” 것은 κ³Όν•œ λž˜ν•‘μ΄ 될 수 μžˆμ–΄μš”.

Comment on lines +12 to +17
public ImageDimensions(int width, int height) {
this.width = width;
this.height = height;
}

public boolean validDimensions() {

Choose a reason for hiding this comment

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

μƒμ„±μžμ—μ„œ validation을 ν•˜μ§€ μ•ŠμœΌμ‹œλŠ” μ΄μœ κ°€ μžˆμ„κΉŒμš”? 객체의 생성은 객체가 λ‹΄λ‹Ήν•˜λŠ” 것이 객체 μƒμ„±μ˜ μ•ˆμ •μ„±μ„ 보μž₯ν•΄μš” :)

BMP;

public static boolean validExtension(ImageExtension extension) {
if (!Arrays.asList(GIF, JPG, JPEG, PNG, SVG).contains(extension)) {

Choose a reason for hiding this comment

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

νŠΉμ • ν™•μž₯자만 κ΄€λ¦¬ν•˜κ³ μ‹Άλ‹€λ©΄ μƒμˆ˜λ‘œ λΉΌλ©΄ 쒋을 것 κ°™λ„€μš” :)

package nextstep.courses.domain.session.coverImage;

public class ImageSize {
private int size;

Choose a reason for hiding this comment

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

λΆˆλ³€μΌ 수 μžˆλŠ” ν•„λ“œλ“€μ€ λͺ¨λ‘ λΆˆλ³€μœΌλ‘œ μˆ˜μ •ν•΄μ£Όμ‹œλ©΄ 쒋을 것 κ°™μ•„μš” :)


import java.time.LocalDate;

public class Session {

Choose a reason for hiding this comment

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

SessionServiceλ₯Ό 톡해 enroll λ‘œμ§μ„ κ΅¬ν˜„ν•˜λŠ”κ²ƒκΉŒμ§€κ°€ λ―Έμ…˜μ˜ μš”κ΅¬μ‚¬ν•­μ΄μ—μš” :)

private SessionStrategy sessionStrategy;

public Session(SessionCoverImage sessionCoverImage, SessionStatus sessionStatus, SessionStrategy sessionStrategy) {
this(null, null, sessionCoverImage, sessionStatus, sessionStrategy);

Choose a reason for hiding this comment

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

λ‘˜λ‹€ null인 μΌ€μ΄μŠ€λ₯Ό μƒμ„±μžμ—μ„œ μ§€μ›ν•˜λŠ” μ΄μœ κ°€ μžˆμ„κΉŒμš”?

Comment on lines +11 to +15
private FreeSession freeSession;

@Test
void μˆ˜κ°•μ‹ μ²­_κ°€λŠ₯μ—¬λΆ€_확인() {
freeSession = new FreeSession();

Choose a reason for hiding this comment

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

ν•„λ“œλ“€μ„ λΆˆλ³€ν•˜κ²Œ κ°€μ Έκ°€μ£Όμ‹œλ©΄ 쒋을 것 κ°™μ•„μš” :) 가변적인 ν•„λ“œλŠ” 가변적일 수 μžˆλ‹€λΌλŠ” μ»¨ν…μŠ€νŠΈλ₯Ό 계속 μ•ˆκ³  μ½”λ“œλ₯Ό 읽게 λ§Œλ“€κΈ° λ•Œλ¬Έμ— κ°€λŠ₯ν•˜λ©΄ μ§€μ–‘ν•΄μ£Όμ‹œλŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€.

Comment on lines +14 to +29
@Test
void μˆ˜κ°•μ‹ μ²­_κ°€λŠ₯μ—¬λΆ€_확인__κ°•μ˜_μˆ˜κ°•λ£Œ_확인() {
paidSession = new PaidSession(3, 2, 20000);
assertTrue(paidSession.canEnroll(new Payment(20000L)));
paidSession = new PaidSession(3, 2, 20000);
assertFalse(paidSession.canEnroll(new Payment(15000L)));
}

@Test
void μˆ˜κ°•μ‹ μ²­_κ°€λŠ₯μ—¬λΆ€_확인__μΈμ›μ΄ˆκ³Ό_확인() {

paidSession = new PaidSession(3, 2, 20000);
assertTrue(paidSession.canEnroll(new Payment(20000L)));
paidSession = new PaidSession(2, 2, 20000);
assertFalse(paidSession.canEnroll(new Payment(20000L)));
}

Choose a reason for hiding this comment

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

μ „λ°˜μ μœΌλ‘œ ν…ŒμŠ€νŠΈμ—μ„œ 어떀것을 ν…ŒμŠ€νŠΈν•˜κ³ μžν•˜λŠ”μ§€κ°€ λͺ…ν™•ν•˜μ§€ μ•Šμ€ 것 κ°™μ•„μš”. ν…ŒμŠ€νŠΈλ‹Ή κ²€μ¦ν•˜κ³ μžν•˜λŠ” λŒ€μƒμ€ λͺ…ν™•ν•˜μ—¬μ•Όν•˜κ³ , 이 기쀀이 μ–΄λ ΅λ‹€κ³  λŠλΌμ‹ λ‹€λ©΄ assertion이 ν•˜λ‚˜μ—¬μ•Όλœλ‹€κ³  μƒκ°ν•΄λ³΄μ‹œλ©΄ νŽΈν•  것 κ°™μ•„μš”.

예λ₯Όλ“€λ©΄ κ°•μ˜ μˆ˜κ°•λ£Œν™•μΈμ—μ„œ κ²€μ¦ν•˜κ³ μžν•˜λŠ” 것은 canEnroll이 true이닀인데 false인걸 ν…ŒμŠ€νŠΈν•  ν•„μš”κ°€ μžˆμ„κΉŒμš”? 또 μΈμ›μ΄ˆκ³Ό 확인인데 canEnroll이 true이닀인걸 ν…ŒμŠ€νŠΈν•  ν•„μš”κ°€ μžˆμ„κΉŒμš”?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants