Skip to content

[운송 II (주문)] 미션 구현 (신윤철)#8

Open
Shin-Yun-Cheol wants to merge 12 commits intoallrounder-backend:mainfrom
Shin-Yun-Cheol:logistic2_basic
Open

[운송 II (주문)] 미션 구현 (신윤철)#8
Shin-Yun-Cheol wants to merge 12 commits intoallrounder-backend:mainfrom
Shin-Yun-Cheol:logistic2_basic

Conversation

@Shin-Yun-Cheol
Copy link

💡 Summary

구현한 기능

  • 스레드 이용
  • 세마포어 이용

✅ CheckList

  • 기능 구현
  • 단위테스트 실행 및 통과
  • ...

신경써서 구현한 점 / 어려웠던 점

  • 스레드를 직접 처음 이용해봐서 id를 atomicInteger로 처리하는 것과 응용단계 세마포어 이용하는 것이 어려웠다

📚 Retrospective (YWT)

What I did

  • MVC를 통해 의존성 분리
  • 스레드 이용

What I Learned

  • 스레드 이용과 세마포어를 이용한 자원 관리

What I will do next

  • 심화 단계에서의 터미널 제어

✨ Impression

스레드를 처음 이용해보는데 아주 어려운 수준은 아니어서 그나마 할만 했던 것 같고, 스레드를 이용할때 자원관리같은 것에대해 주의해야겠다는 생각이 들었다.

Copy link
Contributor

@moongua404 moongua404 left a comment

Choose a reason for hiding this comment

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

6주차 미션 수고많으셨습니다!

private final AtomicInteger nextId = new AtomicInteger(0);

// 동시 실행 제한: 최대 5개
private final Semaphore capacity = new Semaphore(5, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

개인적인 생각으로는 스레드와 제어에 관한 부분은 서비스나 모델의 역할에 가깝다고 생각합니다. 아래 Thread 부분을 포함해서 스레드의 관리에 필요한 상태와 스레드가 갖는 비지니스 로직이 컨트롤러에 대부분을 구성하면 서비스, 모델, 뷰와의 관계성이라는 컨트롤러의 관심사와 멀어지는 것 같아서요. 컨트롤러가 직접 상태를 갖고 제어하는 것 역시 컨트롤러의 역할을 벗어난다고 생각합니다.

acquired = true;

// 실제 시작 시에만 예상시간 계산/출력
int minutes = deliveryService.estimateMinutes(order.departure(), order.destination());
Copy link
Contributor

Choose a reason for hiding this comment

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

시간 계산을 스레드 내부에 둔 이유가 있나요?
배송 시간 계산주문 및 운송의 관계를 어떻게 생각하고 구현하셨는지 궁금해요!

outputView.printError(ex.getMessage());
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

스레드가 들어가서 그렇겠지만 함수의 볼륨이 너무 큰 것 같아요

if (input == null) {
throw new IllegalArgumentException("입력값이 없습니다.");
}
Pattern p = Pattern.compile("^\\s*(.+?)\\s*-\\s*(.+?)\\s*\\((.+?)\\)\\s*$");
Copy link
Contributor

Choose a reason for hiding this comment

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

\s 이걸 통해서도 공백을 처리할 수 있는지 처음 알았어요
임의 문자 전부를 받는 것에 대해서는 조금 우려되는 부분이 있습니다.
숭실대학교-정보과학관-봉화군청(박호건()dummystr~~이 경우에 각 영역에 숭실대학교, 정보과학관-봉화군청, 박호건( 이렇게 값이 들어갈 수 있기 때문에 1차적인 유효성 검증은 regex 내에서 처리하는게 효율적이라고 생각합니다.

}

try {
DeliveryOrder order = InputParser.parseDelivery(trimmed);
Copy link
Contributor

Choose a reason for hiding this comment

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

제가 파악한게 맞으면 여기서 문자열을 받은 후 주문 스레드에서 장소를 찾는 것 같은데, 이 경우 예외에 취약할 뿐더러 일반적인 관점에서도 플로우(주문을 받고 나서 어디로 가야하는지를 고민한다 라고 생각이 되어서)가 다소 어색할 수 있을 것 같습니다.

double latitude = Double.parseDouble(columns[1].trim());
double longitude = Double.parseDouble(columns[2].trim());

indexMap.put(placeId, new LatLng(latitude, longitude));
Copy link
Contributor

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.

2 participants