CLI 자바 서비스 만들기 - 정용현#7
Open
hoehoeabi wants to merge 68 commits into
Open
Conversation
Added project overview, features, and class structure to README.
- App에서 사용하기위해
- App을 실행
- 뷰를 분리할 예정
- 기존 : case "list" -> articleController.showList(); - 이후 : case "list" -> articleController.showList(rq);
- 유틸클래스에 들어가기엔 page,pageable,Rq 셋다 안어울린다고 생각하였기에
- 명령어가 많아지니 switch문은 가독성이 떨어진다고 판단 - 하여 initCommandMap으로 미리 명령어와 해당 실행 구문을 map에 담고 꺼내오는 방식으로 변경
- ArticleView 분리를 통한 UI 로직 캡슐화 - ArticleController에서 executeWithId를 사용하여 중복로직 제거 - 컨테이너에서 의존성 주입 수정 -> 컨트롤러에 뷰 주 주입 - 테스트 코드 수정
- Msg 클래스를 도입하여 한곳에서 관리하도록 함 - 하드코딩된 문자열을 상수로 대체하여 유지보수성 향상
- https://www.toptal.com/developers/gitignore에서 macOs,inteliJ,Gradle 적용
|
커밋 로그가 상세하게 남아 있어 작업 과정이 잘 드러나는 점이 좋았습니다. |
|
보여주는 부분(View)과 명령을 전달하는 부분(Controller)을 분리하는게 확실히 더 좋을 것 같다는 생각이 들었습니다. 그리고 Rq 파라미터를 통일하여 일관성을 관리하는 부분도 인상깊었습니다! |
|
저도 커밋이 상세하게 남아 있어 작업 내역의 흐름을 잘 살필 수 있는 점이 좋았습니다. 고생하셨습니다! |
|
Pageable과 Page 객체로 페이징을 추상화한 부분이 인상적이고, |
kjh3165
reviewed
Apr 17, 2026
| // 뷰 타이틀 및 헤더 | ||
| public static final String ARTICLE_LIST_TITLE = "전체 목록"; | ||
| public static final String ARTICLE_SEARCH_TITLE_FORMAT = "[%s] 검색 결과 (키워드: %s)"; | ||
| } No newline at end of file |
kjh3165
reviewed
Apr 17, 2026
| } | ||
|
|
||
| @Test | ||
| @DisplayName("명령어 도ㅁ움말 확인") |
kjh3165
reviewed
Apr 17, 2026
kjh3165
left a comment
There was a problem hiding this comment.
페이징 도입, 메시지 사전정의, 강제종료시에도 scanner 해제 고려한 부분 등이 인상깊었습니다. 전체적으로 구조를 잘 잡으신 것 같습니다. 고생하셨습니다~
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📝 CLIPost: Java CLI 기반 텍스트 게시판
🎯 개요
이 프로젝트는 Java 콘솔 환경에서 게시판 시스템입니다.
Java의 기본 문법 객체지향 설계(OOP), 계층형 아키텍처(3-Tier Architecture), 그리고 **테스트 주도적인 개발(Test-Driven Approach)**을 실습하는 데 중점을 두었습니다.
🧩 전체 기능 및 명령어
사용자는 콘솔 입력을 통해 아래 명령어를 수행할 수 있습니다.
URL 쿼리 스트링 형식(
?key=value&...)writelist?page={번호}&pagesize={크기}detail?id={번호}update?id={번호}delete?id={번호}search?target={대상}&keyword={검색어}&page={번호}target옵션:title(제목),content(내용),all(제목+내용 통합, 기본값)helpexit게시글 객체 구조
⚙️ 주요 클래스 및 파일 구조
🧠 계층별 상세 설계
1. ArticleController (View/Controller)
Rq에서 필요한 파라미터를 추출하여 서비스 계층에 전달합니다.2. ArticleService (Business Logic)
getArticle호출 시 데이터가 없으면RuntimeException을 던져 방어적으로 설계했습니다.Optional을 활용한 선언적 프로그래밍을 적용했습니다.(page - 1) * pageSize을 통해 리스트를 슬라이싱하며,Math.ceil을 사용하여 전체 페이지 수를 계산합니다.3. ArticleRepository (Data Access)
HashMap을 사용한 인메모리 데이터 저장소입니다.Optional<Article>을 반환하여 Null 안정성을 확보하고, 최신순 정렬 리스트를 제공합니다.4. Rq & TestUtil (Utilities)
5. Pageable & Page (Paging Abstraction)
getOffset()메서드를 통해 데이터 추출 시작점을 계산합니다.content)와 함께 전체 페이지 수, 현재 페이지 번호 등 페이징 처리에 필요한 메타데이터를 담는 범용 제네릭 객체입니다.💬 실행 예시
🎯 개발 핵심 역량
계층형 아키텍처 적용
Controller-Service-Repository로 분리하여 코드의 유지보수성과 가독성을 챙겼습니다.의존성 주입 (Dependency Injection)
Container클래스와 생성자 주입 방식을 사용하여 클래스 간 결합도를 낮췄으며, 이를 통해 테스트 시 가짜(Mock) 객체나 시뮬레이션용Scanner주입이 용이하도록 설계했습니다.검증된 코드 (Comprehensive Testing)
페이징 추상화(Pagination Abstraction) 구현
자원 및 예외 관리
Shutdown Hook을 활용해 프로그램 강제 종료 시에도 자원(Scanner)이 안전하게 해제되도록 설계했으며,Optional을 도입하여NullPointerException위험을 제거했습니다.