Skip to content

Conversation

@UJHa
Copy link

@UJHa UJHa commented Aug 17, 2021

📌 과제 설명

과제 페이지(링크)
바우처 생성/조회 기능을 구현했습니다.

👩‍💻 요구 사항과 구현 내용

create

  • 요구사항
    • FixedAmountVoucher, PercentDiscountVoucher를 선택해서 구현해야 합니다.
  • 기능 구현
    • create 형식으로 command 명령을 사용하도록 구현했습니다.
    • class type
      • F : FixedAmountVoucher
      • P : PercentDiscountVoucer
    • 생성 시 VoucherRepository의 구현체에 생성된 인스턴스들을 추가합니다.

list

  • 요구사항
    • create로 생성한 모든 Voucher를 출력합니다.
  • 기능 구현
    • VoucherRepository의 구현체에 저장한 ArrayList를 getter로 가져와서 출력합니다.
      • 출력 시 toString으로 Voucher의 클래스명과 멤버 변수를 출력합니다.

exit

  • 요구사항&구현사항
    • 프로그램을 종료합니다.

✅ PR 포인트 & 궁금한 점

대부분의 기능을 CommandLineApplication.java에서 구현했습니다.
아쉬운 점 피드백 주시면 열심히 반영해보겠습니다!👨‍💻

@LeeJuOh
Copy link
Member

LeeJuOh commented Aug 18, 2021

진환님 멘토님 리뷰어를 안걸으셨네요!!

@UJHa UJHa requested a review from VictoryPark August 18, 2021 09:51
@UJHa UJHa changed the title [1기-엄진환] [3주차] Command-line Application [1기-엄진환] [3주차][W1D2~3] Command-line Application Aug 20, 2021
@UJHa
Copy link
Author

UJHa commented Aug 20, 2021

📌 과제 설명

과제 페이지(링크)
바우처 정보를 File로 추가/조회 기능을 구현했습니다.

👩‍💻 요구 사항과 구현 내용

create

  • 요구사항&기능 구현
    • 프로그램 실행 시 File을 읽어서 VoucherRepository에 저장하기
    • Voucher 추가 시 File에 Voucher 추가하기(쓰기작업)
    • 각 Voucher별로 CSV파일에 저장할 문자열 정보를 가지도록 하기()

✅ PR 포인트 & 궁금한 점

feat:미션2 File 추가/조회 기능 구현 기능 구현내용에 필요한 내용을 수정했습니다.

static VoucherRepository voucherRepository;
public static void main(String[] args) {
var application = new AnnotationConfigApplicationContext(AppConfiguration.class);
voucherService = application.getBean(VoucherService.class);

Choose a reason for hiding this comment

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

domain 로직에 spring 관련 코드가 있는 것은 조금 위험한 구현방식입니다.
그리고 voucherService가 commandLineApplication에
있는 것이 맞는지 한번 고민해보셔용

{
Assert.isTrue(splitList.length == 3, "This command did not receive the required arguments.");
String voucherName = splitList[1];
if (voucherName.equals("F")) {

Choose a reason for hiding this comment

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

F 를 쓰는 것을 사용자가 알고 있을까요?


while (!command.equals("exit")) {
String commandLine = scanner.nextLine();
String[] splitList = commandLine.split(" ");

Choose a reason for hiding this comment

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

사용자가 입력한 값이 적절한지 check 하는 로직이 있으면
더 완벽해질 것 같습니다.

Copy link

@VictoryPark VictoryPark left a comment

Choose a reason for hiding this comment

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

질문 주신대로,
CommandLineApplication 클래스에 모든 기능을 넣어주셨네요!
기능을 분리하려면 어떻게 해야 할까도 한번 고민해보셔요!!

@UJHa
Copy link
Author

UJHa commented Aug 22, 2021

📌 W1D3 피드백 내용 구현

@UJHa
Copy link
Author

UJHa commented Aug 23, 2021

📌 코드 개선 진행

팀원들이 작성한 코드들을 참고하여 구조를 개선했습니다.

  • Console외에 다른 플랫폼 실행이 가능하도록 Input, Output으로 입출력 분리
  • command 비교를 문자열이 아닌 enum 타입으로 받아서 처리도록 변경

@UJHa
Copy link
Author

UJHa commented Aug 26, 2021

📌 과제 설명(W1D4, W1D5)

W1D4 : 블랙리스트 조회 기능 추가, yaml 설정하기(과제 링크)
W1D5 : 파일로 로그 기록, SpringBoot 설정하기, 실행 가능 jar 생성하기(과제 링크)

👩‍💻 요구 사항과 구현 내용

W1D4

customer_blacklist.csv 구조

type(normal/black), uuid, 이름

customers

customer_blacklist.csv 파일의 모든 고객 정보 출력(uuid, 이름, 타입)

blacks

블랙리스트 타입의 고객만 출력(uuid, 이름, 타입)

application.yaml

  • spring.profiles.active: dev로 등록
    • dev : File로 Voucher를 저장
    • local : Memory에만 Voucher를 저장

W1D5

로그 파일(access-2021-08-27.log)

  • access-yyyy-mm-dd.log 포맷으로 매일 새로운 파일로 저장
  • 비정상 커맨드, create의 추가 커맨드 에러 시 log 파일에 기록

jar 파일 생성

  • 프로젝트 디렉토리 하단에 CommandApplication.jar로 실행파일 추가

✅ PR 포인트 & 궁금한 점

블랙리스트의 출력을 위한 기능을 일반 고객과 블랙리스트 고객을 모두 출력해보기 위해서
customers, blacks 커맨드를 추가했습니다.

@UJHa UJHa requested a review from VictoryPark August 26, 2021 16:30
@UJHa UJHa changed the title [1기-엄진환] [3주차][W1D2~3] Command-line Application [1기-엄진환] [3주차][W1D2~5] Command-line Application Aug 26, 2021
@UJHa UJHa changed the title [1기-엄진환] [3주차][W1D2~5] Command-line Application [1기-엄진환] [3주차][W1D2~W1D5] Command-line Application Aug 26, 2021
return voucher;
}

public void printAllVoucher() {

Choose a reason for hiding this comment

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

voucherService 에서 print 를 호출하는 것은
Input, Output 인터페이스를 구현하여 역할 분리를 한 것이 의미가 없어집니다.
다른 방법을 한번 생각해보셔요!!


@Configuration
public class CommandLineApplication implements ApplicationRunner {
private final VoucherOperator voucherOperator;

Choose a reason for hiding this comment

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

여기서 구현체로 타입을 선언하는 것이 아니라 다형성을 위해 인터페이스 타입으로 선언합니다.

voucher.ifPresent(voucherService::saveVoucher);
}

public Optional<Voucher> createVoucher(String[] splitList) {

Choose a reason for hiding this comment

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

validation check 로직이 조금 더 보강되었으면 좋겠네요..^.^

public Optional<Voucher> createVoucher(String[] splitList) {
if (splitList.length != 2) return Optional.empty();

Optional<Voucher> voucher = Optional.empty();

Choose a reason for hiding this comment

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

사실, createVoucher 에서는 Optional일 필요가 없습니다.
Optional 은 select 로직에서 많이 사용됩니다.
왜냐하면 db에 데이터가 없을 경우 nullable하기 때문입니다.

return Arrays.stream(VoucherType.values())
.filter(voucherType -> voucherType.inputCommand.equals(command))
.findAny()
.orElseThrow(IllegalArgumentException::new);

Choose a reason for hiding this comment

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

잘못 입력했을때 예외를 던지는 것 말고 친절하게 다시 command를 작성할 수 있도록 바꿔볼까요?

.orElseThrow(IllegalArgumentException::new);
}

public static Optional<Voucher> getVoucher(String inputCommand, long value) {

Choose a reason for hiding this comment

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

음..비즈니스 로직상 getVoucher 라는 naming 보다는 createVoucher 가 나을 것 같고
그러면 새로 new 하는 로직이니, Optional이지 않아도 됩니다.

Copy link

@VictoryPark VictoryPark left a comment

Choose a reason for hiding this comment

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

CommandLineApp 과 voucherService 간의
결합을 없애기 위해 많이 노력하셨군요!
진환님, 더 자세한 리뷰는 코멘트로 달아드렸습니다,.

확인해주세요😜

kimziou77 added a commit to kimziou77/springboot-basic that referenced this pull request Apr 11, 2022
* On branch : develop
# 유저 생성 : UserFactory
# 유저 저장 : UserRepository
# 유저 타입 : UserType

* Changes to be committed:
                Modified : User.java, UserFactory.java, UserFileRepository.java, UserType.java
kimziou77 added a commit to kimziou77/springboot-basic that referenced this pull request Apr 11, 2022
* On branch : develop
# CSV 파일 읽기 : CSVReader
# CSV 파일 쓰기 : CSVWriter
# 샘플 CSV 파일 : user_allList, user_blackList

* Changes to be committed:
                Modified : CSVReader.java, CSVWriter.java, sample.csv
zxcv9203 added a commit that referenced this pull request Jun 18, 2022
feat : Customer can be added using jdbc template impl
hseong3243 added a commit that referenced this pull request Jul 14, 2023
VoucherJdbcRepository 추가
young970 added a commit that referenced this pull request Jul 22, 2023
fix: printMenu() 출력문 회원으로 통일
aegis1920 pushed a commit that referenced this pull request Oct 22, 2023
refactor : 추상 클래스 수정 및 입력 검증 클래스 정규 표현식 수정
ksy90101 pushed a commit that referenced this pull request Oct 26, 2023
[예림] JdbcCustomerRepository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants