1.1. Aha! ¶
Before launching into our descriptions of specific design patterns, we present a case study of sorts, involving multiple patterns. In the Design Pattern preface, the Gang of Four speak about moving from a "Huh?" to an "Aha!" experience with regard to understanding design patterns. We present here a little drama portraying such a transition. It consists of three vignettes: three days in the life of two Smalltalk programmers who work for MegaCorp Insurance Company. We are listening in on conversations between Don (an object newbie, but an experienced business analyst) and Jane (an object and pattern expert). Don comes to Jane with his design problems, and they solve them together. Although the characters are fictitious, the designs are real and have all been part of actual systems written in Smalltalk. Our goal is to demonstrate how, by careful analysis, design patterns can help derive solutions to real-world problems.
(์ค๊ฐ์ค๊ฐ ๊ตฌ๋ผ์ ๊ฐ๊น์ด ์์ญ์ด๋ผ๋. --;;;)
๋์์ธ ํจํด์ ๋ํ ๊ตฌ์ฒด์ ์ธ ์ค๋ช
์ ๋ค์ด๊ฐ๊ธฐ ์ ์ ์ฐ๋ฆฌ๋ ๋ค์ํ ํจํด๋ค์ด ํฌํจ๋ ๊ฒ๋ค์ ๋ํ ์์๋ค์ ๋ณด์ฌ์ค๋ค. ๋์์ธ ํจํด ์๋ฌธ์์ GoF๋ ๋์์ธ ํจํด์ ์ดํดํ๊ฒ ๋๋ฉด์ "Huh?" ์์ "Aha!" ๋ก ๋ฐ๋๋ ๊ฒฝํ์ ๋ํด ์ด์ผ๊ธฐํ๋ค. ์ฐ๋ฆฌ๋ ์ฌ๊ธฐ ์์ ๋จ๋ง๊ทน์ ๋ณด์ฌ์ค ๊ฒ์ด๋ค. ๊ทธ๊ฒ์ 3๊ฐ์ ์์ ์ด์ผ๊ธฐ๋ก ๊ตฌ์ฑ๋์ด์๋ค : MegaCorp๋ผ๋ ๋ณดํํ์ฌ์์ ์ผํ๋ ๋๋ช
์ Smalltalk ํ๋ก๊ทธ๋๋จธ์ 3์ผ์ ์ด์ผ๊ธฐ์ด๋ค. ์ฐ๋ฆฌ๋ Don ๊ณผ(OOP์ ๋ํด์๋ ์ด๋ณด์ง๋ง ๊ฒฝํ์๋ ์ฌ์
๋ถ์๊ฐ) Jane (OOP์ Pattern ์ ๋ฌธ๊ฐ)์ ๋ํ๋ด์ฉ์ ๋ฃ๊ณ ์๋ค. Don ์ ๊ทธ์ ๋ฌธ์ ๋ฅผ Jane์๊ฒ ๊ฐ์ ธ์ค๊ณ , ๊ทธ๋ค์ ๊ฐ์ด ๊ทธ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค. ๋น๋ก ์ฌ๊ธฐ์ ์ธ๋ฌผ๋ค์ ํ๊ตฌ์ ๊ฒ์ด์ง๋ง, design ์ ์ค์ ์ ๊ฒ์ด๊ณ , Smalltalk๋ก ์ฐ์ฌ์ง ์ค์ ์ ์์คํ
์ค ์ผ๋ถ์ด๋ค. ์ฐ๋ฆฌ์ ๋ชฉํ๋ ์ด๋ป๊ฒ design pattern์ด ์ค์ ์ธ๊ณ์ ๋ฌธ์ ๋ค์ ๋ํ ํด๊ฒฐ์ฑ
์ ๊ฐ์ ธ๋ค ์ฃผ๋๊ฐ์ ๋ํด ์ค๋ช
ํ๋ ๊ฒ์ด๋ค.
Chapter 2
Aha!
2.1 Scene One : State of Confusion
Our story begins with a tired-looking Don approaching Jane's cubicle, where Jane sits quietly typing at her keyboard.
์ฐ๋ฆฌ์ ์ด์ผ๊ธฐ๋ ์ง์นํ์ ์ ์ง์ผ๋ฉฐ ์ ์ธ์ cubicle (์.. ์ฌ๋ฌด์ค์์์ ํํฐํด๋ก ๊ตฌ๋ถ๋ ๊ณณ ์ ๋์ธ๋ฏ. a small room that is made by separating off part of a larger room)๋ก ๊ฐ๋ Don ๊ณผ ํจ๊ป ์์ํ๋ค. ์ ์ธ์ ์์ ์ cubicle์์ ์กฐ์ฉํ ํ์ดํํ๋ฉฐ ์์์๋ค.
Our story begins with a tired-looking Don approaching Jane's cubicle, where Jane sits quietly typing at her keyboard.
์ฐ๋ฆฌ์ ์ด์ผ๊ธฐ๋ ์ง์นํ์ ์ ์ง์ผ๋ฉฐ ์ ์ธ์ cubicle (์.. ์ฌ๋ฌด์ค์์์ ํํฐํด๋ก ๊ตฌ๋ถ๋ ๊ณณ ์ ๋์ธ๋ฏ. a small room that is made by separating off part of a larger room)๋ก ๊ฐ๋ Don ๊ณผ ํจ๊ป ์์ํ๋ค. ์ ์ธ์ ์์ ์ cubicle์์ ์กฐ์ฉํ ํ์ดํํ๋ฉฐ ์์์๋ค.
Don : Hey, Jane, could you help me with this problem? I've been looking at this requirements document for days now, and I can't seem to get my mind around it.
Jane~ ์ด ๋ฌธ์ ์ข ํด๊ฒฐํด์ฃผ์ค๋์? ์ค๋ ํ๋ฃจ์ข ์ผ ์ด ์๊ตฌ๋ฌธ์๋ฅผ ์ณ๋ค๋ดค์ง๋ง, ๋๋ฌด์ง ์์ด๋์ด๊ฐ ์๋ ์ค๋ฅด๋ค์.
Jane~ ์ด ๋ฌธ์ ์ข ํด๊ฒฐํด์ฃผ์ค๋์? ์ค๋ ํ๋ฃจ์ข ์ผ ์ด ์๊ตฌ๋ฌธ์๋ฅผ ์ณ๋ค๋ดค์ง๋ง, ๋๋ฌด์ง ์์ด๋์ด๊ฐ ์๋ ์ค๋ฅด๋ค์.
Jane : That's all right. I don't mind at all. What's the problem?
์ข์์. ์ด๋ค๋ฌธ์ ์ธ๊ฐ์?
์ข์์. ์ด๋ค๋ฌธ์ ์ธ๊ฐ์?
Don : It's this claims-processing workflow system I've been asked to design. I just can't see how the objects will work together. I think I've found the basic objects in the system, but I don't understand how to make sense from their behaviors.
์ ๊ฐ ๋์์ธ๋ถํํ๋ ๊ฒ์ ๋ฐ๋ก ์ด ์๊ตฌ-์งํ ์์ ํ๋ฆ์์คํ ์ ๋๋ค. (๊ทธ๋ฅ ์์ด ๊ทธ๋๋ก ์จ๋ ๋ ๊ฒ ๊ฐ์๋ฐ.. ๋์ฒดํ ์ฉ์ด๊ฐ ์๊ฐ์๋๋ค. ์, ์ดํ ๋ธ๋ ค๋ผ. --;) ์ด ๊ฐ์ฒด๋ค์ด ์ด๋ป๊ฒ ๊ฐ์ง ์์ฉํด์ผ ํ ์ง ๋ชจ๋ฅด๊ฒ ์ด์. ์ ๊ฐ ์๊ฐํ๊ธฐ๋ก , ์ด ์์คํ ์์์ ๊ธฐ๋ณธ์ ์ธ ๊ฐ์ฒด๋ค์ ์ฐพ์ ๊ฒ ๊ฐ์๋ฐ, ๊ฐ ๊ฐ์ฒด๋ค์ ํ์๋ค์ ์ด๋ป๊ฒ ์ดํดํด์ผ ํ ์ง ๋ชจ๋ฅด๊ฒ ์ด์.
์ ๊ฐ ๋์์ธ๋ถํํ๋ ๊ฒ์ ๋ฐ๋ก ์ด ์๊ตฌ-์งํ ์์ ํ๋ฆ์์คํ ์ ๋๋ค. (๊ทธ๋ฅ ์์ด ๊ทธ๋๋ก ์จ๋ ๋ ๊ฒ ๊ฐ์๋ฐ.. ๋์ฒดํ ์ฉ์ด๊ฐ ์๊ฐ์๋๋ค. ์, ์ดํ ๋ธ๋ ค๋ผ. --;) ์ด ๊ฐ์ฒด๋ค์ด ์ด๋ป๊ฒ ๊ฐ์ง ์์ฉํด์ผ ํ ์ง ๋ชจ๋ฅด๊ฒ ์ด์. ์ ๊ฐ ์๊ฐํ๊ธฐ๋ก , ์ด ์์คํ ์์์ ๊ธฐ๋ณธ์ ์ธ ๊ฐ์ฒด๋ค์ ์ฐพ์ ๊ฒ ๊ฐ์๋ฐ, ๊ฐ ๊ฐ์ฒด๋ค์ ํ์๋ค์ ์ด๋ป๊ฒ ์ดํดํด์ผ ํ ์ง ๋ชจ๋ฅด๊ฒ ์ด์.
Jane : Can you show me what you've done?
Don : Here, let me show you the section of the requirements document I've got the problem with:
์ฌ๊ธฐ์. ์๊ตฌ๋ฌธ์์์ ๋ฌธ์ ์ ๋ถ๋ถ์ ๋๋ค.
์ฌ๊ธฐ์. ์๊ตฌ๋ฌธ์์์ ๋ฌธ์ ์ ๋ถ๋ถ์ ๋๋ค.
- Data Entry. This consists of various systems that receive health claims from a variety of different sources. All are logged by assigning a unique identifier. Paper claims and supporting via OCR (optical character recognition) to capture the data associated with each form field.
- Validation. The scanned and entered forms are validated to ensure that the fields are consistent and completely filled in. Incomplete or improperly filled-in forms are rejected by the system and are sent back to the claimant for resubmittal.
- Provider/Plan Match. An automated process attempts to mach the plan (the contract unser which the claim is being paid) and the health care provider (e.g., the doctor) identified on the claim with the providers with which the overall claim processing organization has a contract. If there is no exact match, the program identifies the most likely matches based on soundex technology (an algorithm for finding similar-sounding words). The system displays prospective matches to knowledge workers in order of the likeinhood of the match, who then identify the correct provider.
- Automatic Adjudication. The system determines whether a claim can be paid and how much to pay if and only if there are no inconsistencies between key data items associated with the claim. If there are inconsistencies, the system "pends" the claim for processing by the appropriate claims adjudicator.
- Adjudication of Pended Claims. The adjudicator can access the system for a claim history or a representation of the original claim. The adjudicator either approves the claim for payment, specifying the proper amount to pay, or generates correspondence denying the claim.
Validation. ์ค์บ๋๊ณ ์
๋ ฅ๋์ด์ง form๋ค์ ๊ฐ ํ๋๋ค์ ๋ํด ์ผ๊ด์ฑ๋ณด์ฆ๊ณผ ๋ชจ๋ ํผ์ด ์์ ํ ์ฑ์์ก๋์ง์ ๋ํ ๋ณด์ฆ์ ์ํด ๊ฒ์ฆ์์
์ ๊ฑฐ์น๋ค. ๋ถ์์ ํ๊ฑฐ๋ ์ ์ ์น ๋ชปํ ์
๋ ฅ์ ์์คํ
์ ์ํด reject๋๊ณ , ์ฌํ์ธ์ ์ํด ์๊ตฌ์์๊ฒ ๋๋ก ๋ณด๋ด์ง๋ค.