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

[남기훈] 1차 과제 제출 #1

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

gikhoon
Copy link
Member

@gikhoon gikhoon commented Sep 21, 2024

No description provided.

Copy link
Member

@yooooonshine yooooonshine left a comment

Choose a reason for hiding this comment

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

잘 읽었습니다!
특히 팩토리로 구성하신 게 인상적이었어요

}
}

/*public void updateQuality() {
Copy link
Member

Choose a reason for hiding this comment

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

불필요한 주석은 삭제하면 좋을 거 같아요!

class GildedRose {
Item[] items;
UpdateLogicFactory updateLogicFactory;
Copy link
Member

Choose a reason for hiding this comment

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

혹시 접근자 private와 제어자 final을 안 넣으신 이유가 있으실까용?

Copy link
Member

Choose a reason for hiding this comment

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

저도 이부분 궁금해요..!

Copy link
Member Author

Choose a reason for hiding this comment

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

바뀔수도 있다고 착각했습니다.. private final 넣어야 합니다..ㅎ

logicMap.put(BACKSTAGE_CONCERT, new BackStageConcertUpdateLogic());
logicMap.put(CONJURED, new ConjuredUpdateLogic());
logicMap.put(OTHERS, new DefaultUpdateLogic());
}
Copy link
Member

Choose a reason for hiding this comment

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

오 아이템별 처리 로직을 팩토리로 관리하는 거 좋네요!


import com.gildedrose.Item;

public interface UpdateLogic {
Copy link
Member

Choose a reason for hiding this comment

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

인터페이스화 좋네요

@Override
public void update(Item item) {
if (item.sellIn <= 0) {
item.quality = Math.max(0, item.quality - 2);
Copy link
Member

@yooooonshine yooooonshine Oct 3, 2024

Choose a reason for hiding this comment

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

2같은 매직넘버는 상수로 처리하면 좋을 거 같아요
https://prodo-developer.tistory.com/118

"Conjured" 아이템은 일반 아이템의 2배의 속도로 품질(Quality)이 저하됩니다.
추후 일반 아이템의 품질 저하가 하루 3씩으로 변경된다면 위 요구 사항은 어떻게 될까요?
이 또한 2 * 3으로 변경되어야 합니다.
따라서 애초에
일반 아이템의 품질 저하량, Conjured의 품질 저하 속도를 모두 전역 상수로 관리하면 추후 유지보수도 훨 좋지 않을까요?

@@ -1,16 +1,29 @@
package com.gildedrose;
Copy link
Member

Choose a reason for hiding this comment

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

image
커밋 단위를 좀 더 신경쓰면 좋을 거 같아요!
특히 맨 위 커밋은 커밋 메세지랑 내용이 많이 다른 거 같아요!
커밋 단위를 기능 단위로 조절하는 것도 좋은 방법이에요!

Copy link
Member

@seoyoung0121 seoyoung0121 left a comment

Choose a reason for hiding this comment

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

잘 읽었습니다 :)

this.nameList = nameList;
}

public static ItemClassification of(Item item) {
Copy link
Member

Choose a reason for hiding this comment

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

item classification을 따로 만들어서 factory와 분리해 놓은게 좋은거 같아요!

@Override
public void update(Item item) {
if (item.sellIn <= 0) {
item.quality = Math.max(0, item.quality - 4);
Copy link
Member

Choose a reason for hiding this comment

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

max로 써서 코드가 더 깔끔해진거 같아요

import java.util.concurrent.ConcurrentHashMap;

public class UpdateLogicFactory {
private final Map<ItemClassification, UpdateLogic> logicMap = new ConcurrentHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

ConcurrentHashMap을 사용하신 특정한 이유가 있을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

ConcurrentHashMap과 HashMap에 차이점은 동시성 제어의 유무에 있습니다. 멀티쓰레드 환경에서 여러 쓰레드가 하나의 공유 자원에 접근하지 못하게 하는 '쓰레드 동기화'가 필수적입니다. 기존의 HashMap은 method/block lock을 통해 감싸주던지 synchronized map을 사용해 thread-safe하게 유지시켰습니다. 하지만 하나의 Thread가 lock을 유지하는 동안 아무도 해당 Map을 사용할 수 없는 상당한 오버헤드가 발생합니다. 이를 해결하기 위한 것이 부분 lock을 사용하는 ConcurrentHashMap입니다!

제가 해당 내용을 공부했을 때 자료입니다. 동작원리랑 자세히 나와있으니 참고하면 좋을 것 같아요!
https://velog.io/@alsgus92/ConcurrentHashMap%EC%9D%98-Thread-safe-%EC%9B%90%EB%A6%AC

updateLogic.update(item);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

주석 지워도 될 것 같아요!

Copy link
Member

@chaen-ing chaen-ing left a comment

Choose a reason for hiding this comment

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

인터페이스와 enum 클래스 사용해서 코드를 잘 분리하신 것 같아서 잘 작성하신 것 같아요. 많이 배워갑니다~!

public class AgedBrieUpdateLogic implements UpdateLogic {
@Override
public void update(Item item) {
if (item.quality < 50) {
Copy link
Member

Choose a reason for hiding this comment

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

50, 0 같은 매직넘버는 상수로 관리해도 좋을 것 같아요

class GildedRose {
Item[] items;
UpdateLogicFactory updateLogicFactory;
Copy link
Member

Choose a reason for hiding this comment

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

저도 이부분 궁금해요..!

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.

4 participants