Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions book/real-world-software-development/chapter4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## 문서 관리 시스템

### 요구사항

기존 환자 정보 파일을 읽어 색인을 추가하고 검색할 수 있는 형태의 정보로 변환

문서의 형태 : 리포트, 우편물, 이미지

각각의 문서는 관리 대상 파일의 경로와 어떤 환자의 기록물인지 나타내는 정보도 포함
다양한 종류의 문서에서 특정 정보를 포함하는 문서를 검색해 찾기를 원함
ex) Joe Bloggs를 포함하는 우편물 문서를 검색하면 그 결과를 반환해야한다.

다른 종류의 문서도 추가할 수 있어야한다.


### 설계 작업

스위치 문의 문제점
- 확장성 낮음, 다른 종류가 추가 될 때 마다 스위치문을 추가해야함.

강한 형식의 원칙
- 데이터 사용 방법을 규제함
- 불변 객체를 활용하면, 오류가 발생 했을 때 오류가 발생하는 원인을 좁힐 수 있고, 불변성 덕분에 안전하게 문서를 색인하거나 캐싱할 수 있따.

도메인 클래스 활용
- 개념에 이름을 붙이고 수행할 수 있는 동작과 값을 제한함.
- 발견성을 개선하고 버그 발생 범위를 줄일 수 있다.

Map의 문제점
- 유지보수성과 가독성을 떨어뜨림

유비쿼터스 언어
- 훌륭한 소프트웨어 개발팀은 유비쿼터스언어로 소프트웨어를 개발함.
- 고객과 대화할 때 사용하는 용어를 응용프로그램의 코드와 같은 의미로 사용함.

문자화 형식

KISS 원칙

리스코프 치환 원칙 : 클래스의 상속과 인터페이스 구현을 올바르게 사용하도록 도와줌.

형식 : 클래스나 인터페이스
하위 형식 : 두 형식이 부모와 자식 관계를 이룸

1. 하위 형식에서 선행조건을 더할 수 없음. 부모가 지정한 것보다 더 많은 선행조건을 요구할 수 없음.
2. 하위 형식에서 후행조건을 약화시킬 수 없음.
3. 슈퍼 형식의 불변자는 하위 형식에서 보존됨.
4. 히스토리 규칙

is a 규칙

코드를 재사용하기 위한 방법 세가지

1. 유틸클래스
2. 상속
3. 도메인클래스

유틸리티 클래스
장점 : 가장 간단한다
단점 : 시간이 흐를 수록 갓 클래스의 모양을 갖춰진다.

상속 사용
일반적으로 상속 관계를 통해 코드를 재사용하는 것은 올바른 방향이 아님.
실제 관계를 반영한게 아니라 상속이 쉽게 깨질 수 있음.

도메인 클래스 사용
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id("java")
}

group = "project"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")

// JUnit 4
testImplementation("junit:junit:4.13.2")

// Hamcrest
testImplementation("org.hamcrest:hamcrest:2.2")
}

tasks.test {
useJUnit()
}
Comment on lines +23 to +25
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using JUnit Platform for test execution.

The build file configures JUnit 4 for test execution with useJUnit(), but the primary dependency is JUnit 5 (Jupiter). This may prevent you from using JUnit 5 features.

tasks.test {
-    useJUnit()
+    useJUnitPlatform()
}

This change allows you to utilize JUnit 5 features while maintaining backward compatibility with JUnit 4 tests through Jupiter's vintage engine.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tasks.test {
useJUnit()
}
tasks.test {
useJUnitPlatform()
}
🤖 Prompt for AI Agents
In
book/real-world-software-development/chapter4/document-management/build.gradle.kts
around lines 23 to 25, the test task is configured to use JUnit 4 with
useJUnit(), but the project primarily depends on JUnit 5. Replace useJUnit()
with useJUnitPlatform() to enable JUnit 5 test execution and support JUnit 4
tests via the vintage engine, ensuring compatibility and access to JUnit 5
features.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@

body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 12pt;
}

body, a, a:visited {
color: #303030;
}

#content {
padding-left: 50px;
padding-right: 50px;
padding-top: 30px;
padding-bottom: 30px;
}

#content h1 {
font-size: 160%;
margin-bottom: 10px;
}

#footer {
margin-top: 100px;
font-size: 80%;
white-space: nowrap;
}

#footer, #footer a {
color: #a0a0a0;
}

#line-wrapping-toggle {
vertical-align: middle;
}

#label-for-line-wrapping-toggle {
vertical-align: middle;
}

ul {
margin-left: 0;
}

h1, h2, h3 {
white-space: nowrap;
}

h2 {
font-size: 120%;
}

ul.tabLinks {
padding-left: 0;
padding-top: 10px;
padding-bottom: 10px;
overflow: auto;
min-width: 800px;
width: auto !important;
width: 800px;
}

ul.tabLinks li {
float: left;
height: 100%;
list-style: none;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
margin-bottom: 0;
-moz-border-radius: 7px;
border-radius: 7px;
margin-right: 25px;
border: solid 1px #d4d4d4;
background-color: #f0f0f0;
}

ul.tabLinks li:hover {
background-color: #fafafa;
}

ul.tabLinks li.selected {
background-color: #c5f0f5;
border-color: #c5f0f5;
}

ul.tabLinks a {
font-size: 120%;
display: block;
outline: none;
text-decoration: none;
margin: 0;
padding: 0;
}

ul.tabLinks li h2 {
margin: 0;
padding: 0;
}

div.tab {
}

div.selected {
display: block;
}

div.deselected {
display: none;
}

div.tab table {
min-width: 350px;
width: auto !important;
width: 350px;
border-collapse: collapse;
}

div.tab th, div.tab table {
border-bottom: solid #d0d0d0 1px;
}

div.tab th {
text-align: left;
white-space: nowrap;
padding-left: 6em;
}

div.tab th:first-child {
padding-left: 0;
}

div.tab td {
white-space: nowrap;
padding-left: 6em;
padding-top: 5px;
padding-bottom: 5px;
}

div.tab td:first-child {
padding-left: 0;
}

div.tab td.numeric, div.tab th.numeric {
text-align: right;
}

span.code {
display: inline-block;
margin-top: 0em;
margin-bottom: 1em;
}

span.code pre {
font-size: 11pt;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
margin: 0;
background-color: #f7f7f7;
border: solid 1px #d0d0d0;
min-width: 700px;
width: auto !important;
width: 700px;
}

span.wrapped pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: break-all;
}

label.hidden {
display: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

#summary {
margin-top: 30px;
margin-bottom: 40px;
}

#summary table {
border-collapse: collapse;
}

#summary td {
vertical-align: top;
}

.breadcrumbs, .breadcrumbs a {
color: #606060;
}

.infoBox {
width: 110px;
padding-top: 15px;
padding-bottom: 15px;
text-align: center;
}

.infoBox p {
margin: 0;
}

.counter, .percent {
font-size: 120%;
font-weight: bold;
margin-bottom: 8px;
}

#duration {
width: 125px;
}

#successRate, .summaryGroup {
border: solid 2px #d0d0d0;
-moz-border-radius: 10px;
border-radius: 10px;
}

#successRate {
width: 140px;
margin-left: 35px;
}

#successRate .percent {
font-size: 180%;
}

.success, .success a {
color: #008000;
}

div.success, #successRate.success {
background-color: #bbd9bb;
border-color: #008000;
}

.failures, .failures a {
color: #b60808;
}

.skipped, .skipped a {
color: #c09853;
}

div.failures, #successRate.failures {
background-color: #ecdada;
border-color: #b60808;
}

ul.linkList {
padding-left: 0;
}

ul.linkList li {
list-style: none;
margin-bottom: 5px;
}
Loading