E D R , A S I H C RSS

Gof Structure Diagram Considered Harmful

There's a mistake that's repeated throughout the Design Patterns book, and unfortunately, the mistake is being repeated by new patterns authors who ape the GoF style.

Design Pattern μ±… μ „λ°˜μ— 걸쳐 반볡적으둜 잘λͺ» μ΄ν•΄λ˜λŠ” λ‚΄μš©λ“€μ΄ μžˆλŠ”λ°, λΆˆν–‰ν•˜κ²Œλ„ μ΄λŸ¬ν•œ μ‹€μˆ˜λŠ” GoF의 μŠ€νƒ€μΌμ„ λͺ¨λ°©ν•œ λ‹€λ₯Έ Pattern μ±…μ˜ μ €μžλ“€μ—κ²Œμ„œλ„ 반볡적으둜 λ‚˜νƒ€λ‚œλ‹€.

Each GoF pattern has a section called "Structure" that contains an OMT (or for more recent works, UML) diagram. This "Structure" section title is misleading because it suggests that there is only one Structure of a Pattern, while in fact there are many structures and ways to implement each Pattern.

사싀은 각 Pattern을 κ΅¬ν˜„ν•˜κΈ° μœ„ν•œ μ—¬λŸ¬κ°€μ§€ 방법이 μžˆλŠ”λ°, GoF의 OMT diagram을 보노라면 마치 각 Pattern에 λŒ€ν•œ 단 ν•œκ°€μ§€ κ΅¬ν˜„λ§Œμ΄ μžˆλŠ” κ²ƒμœΌλ‘œ 잘λͺ» 이해될 수 μžˆλ‹€.

But inexperienced Patterns students and users don't know this. They read the Patterns literature too quickly, often thinking that they understand a Pattern merely by understanding it's single "Structure" diagram. This is a shortcoming of the GoF Form, one which I believe is harmful to readers.

ν•˜μ§€λ§Œ, Pattern에 λŒ€ν•œ κ²½ν—˜μ΄ λΆ€μ±ν•œ ν•™μƒλ“€μ΄λ‚˜ μ‚¬μš©μžλ“€μ€ 이 사싀을 λͺ¨λ₯΄κ³  μžˆλ‹€. 그듀은 Pattern에 λŒ€ν•œ μ €μˆ λ“€μ„ λ„ˆλ¬΄ 빨리 μ½λŠ”λ‹€. 단지 ν•œ 개의 Diagramλ§Œμ„ μ΄ν•΄ν•˜λŠ” κ²ƒμœΌλ‘œ Pattern을 μ΄ν•΄ν–ˆλ‹€κ³  μ°©κ°ν•˜λŠ” κ²½μš°λ„ μž¦λ‹€. 이게 λ°”λ‘œ ν•„μžκ°€ μƒκ°ν•˜κΈ°μ—λŠ” λ…μžλ“€μ—κ²Œ ν•΄λ‘œμ›Œλ³΄μ΄λŠ” GoF λ°©μ‹μ˜ 단점이닀.

What about all those important and subtle Implementation notes that are included with each GoF Pattern? Don't those notes make it clear that a Pattern can be implemented in many ways? Answer: No, because many folks never even read the Implementation notes. They much prefer the nice, neat Structure diagrams, because they usually only take up a third of a page, and you don't have to read and think a lot to understand them.

GoF μ±…μ˜ 각 Pattern λ§ˆλ‹€ μ²¨λΆ€λ˜μ–΄ μžˆλŠ” κ΅¬ν˜„μ— λŒ€ν•œ 맀우 μ€‘μš”ν•˜κ³  λΌκ°ν•œ ν•΄μ„듀은 μ–΄λ– ν•œκ°€? 이 ν•΄μ„듀을 ν†΅ν•΄μ„œ Pattern이 μ—¬λŸ¬ λ°©λ²•μœΌλ‘œ κ΅¬ν˜„λ  수 μžˆλ‹€λŠ” 사싀을 μ•Œ μˆ˜λŠ” μ—†μ„κΉŒ? μ•Œ 수 없을 것이닀. μ™œλƒν•˜λ©΄ λ§Žμ€ λ…μžλ“€μ΄ μ•„μ˜ˆ κ΅¬ν˜„μ— λŒ€ν•œ ν•΄μ„뢀뢄을 읽지도 μ•Šκ³  λ„˜μ–΄κ°€κΈ° λ•Œλ¬Έμ΄λ‹€. 그듀은 보톡 κ°„λž΅ν•˜κ³  ν›Œλ₯­ν•˜κ²Œ 그렀진 Structure diagram을 더 μ„ ν˜Έν•˜λŠ”λ°, κ·Έ μ΄μœ λŠ” 보톡 Diagram에 λŒ€ν•œ λ‚΄μš©μ΄ μ„Έ νŽ˜μ΄μ§€ 정도 λΆ„λŸ‰ 밖에 λ˜μ§€ μ•Šμ„ λΏλ”λŸ¬ 이것을 μ΄ν•΄ν•˜κΈ° μœ„ν•΄ λ§Žμ€ μ‹œκ°„λ™μ•ˆ κ³ λΌμ„ ν•  ν•„μš”λ„ μ—†κΈ° λ•Œλ¬Έμ΄λ‹€.

Diagrams are seductive, especially to engineers. Diagrams communicate a great deal in a small amount of space. But in the case of the GoF Structure Diagrams, the picture doesn't say enough. It is far more important to convey to readers that a Pattern has numerous Structures, and can be implemented in numerous ways.

μ—”μ§€λ‹ˆμ–΄λ“€μ—κ²Œ μžˆμ–΄μ„œ Diagram은 정말 뿌리치기 νž˜λ“  μœ ν˜Ήμ΄λ‹€. ν•˜μ§€λ§Œ Gof의 Structure diagram의 κ²½μš°μ—” μΆ©λΆ„νžˆ λ§Žμ€ λ‚΄μš©μ„ λ§ν•΄μ„ μˆ˜ μ—†λ‹€. Pattern듀이 λ‹€μ–‘ν•œ StructureλΌ κ°€μ§ˆ 수 있으며, λ‹€μ–‘ν•˜κ²Œ κ΅¬ν˜„λ  수 μžˆλ‹€λŠ” 것을 λ…μžλ“€μ—κ²Œ μ•Œλ €μ£ΌκΈ°μ—” 턱없이 λΆ€μ±ν•˜λ‹€.

I routinely ask folks to add the word "SAMPLE" to each GoF Structure diagram in the Design Patterns book. In the future, I'd much prefer to see sketches of numerous structures for each Pattern, so readers can quickly understand that there isn't just one way to implement a Pattern. But if an author will take that step, I'd suggest going even further: loose the GoF style altogether and communicate via a pattern language, rich with diagrams, strong language, code and stories.


결둠은~ νŒ¨ν„΄μ„ κ΅¬ν˜„ν•˜λŠ”λ°μ— κΌ­ ν•œκ°€μ§€ ν˜•νƒœμ˜ λ‹€μ΄μ–΄κ·Έλž¨κ³Ό ν•œκ°€μ§€ ν˜•νƒœμ˜ κ΅¬ν˜„μ΄ μžˆλ‹€λŠ” 것은 μ•„λ‹ˆλΌλŠ” 이야기. GoF μ—μ„œμ˜ λ‹€μ΄μ–΄κ·Έλž¨ λ˜ν•œ ν•˜λ‚˜μ˜ μ˜ˆλΌλŠ” 것을 κ°•μ‘°.

κ³΅λΆ€ν•˜λŠ” μž…μž₯μœΌλ‘œμ„œ μΈμ‹ν•΄λ‘˜λ§Œν•œ λ‚΄μš©μ΄λΌ 생각이 되λ„μš”.


비단 νŒ¨ν„΄λ§Œμ΄ κ·Έλ ‡μ§€λŠ” μ•ŠμŠ΅λ‹ˆλ‹€. μ‘°κΈˆμ€ λ‹€λ₯Έ μ΄μ•ΌκΈ°λΌ ν•΄λ³΄κ³ λ‘ ν•˜μ§€μš”. μ‚¬λžŒμœΌλ‘œλΆ€ν„° λ‚˜μ˜¨(derived) μ–΄λ–€ 유-λ¬΄ν˜•μ˜ 것듀은 그것을 λ§Œλ“  μ‚¬λžŒ, 또 κ·Έ μ‚¬λžŒμ΄ λͺΈλ‹΄κ³  μžˆλŠ” ν™˜κ²½μ„ 반영(reflection) ν•©λ‹ˆλ‹€. 예λΌλ“€μ–΄, μ‹€μ„Έκ³„μ—μ„œ 집을 μ§“λŠ”λ‹€κ³  ν•΄λ΄…μ‹œλ‹€. κ±°κΈ°μ—” μˆ˜λ§Žμ€ 곡법이 μ‘΄μž¬ν•©λ‹ˆλ‹€. 또 ν•˜λ‚˜μ˜ 곡법을 μ΄μ•ΌκΈ°ν•œλ‹€κ³ ν•΄λ„ μ‹€μ œλ‘œ νˆ¬μž…λ˜λŠ” μ‚¬λžŒλ“€μ—λ”°λΌ λ‹€μ–‘ν•˜κ²Œ λ‚˜μ˜¬ 수 μžˆμŠ΅λ‹ˆλ‹€.(μ§€λ‚œ 2002λ…„ 1μ›” 8일 λ‰΄μŠ€μ—μ„œλŠ” μΈ‘λŸ‰ν• λ•Œλ§ˆλ‹€ λ‹€λ₯Έ 토지 계산이 λ‚˜μ˜€λ”κ΅°μš”) μ‘°κΈˆλ” μ—‰λš±ν•œ μ΄μ•ΌκΈ°λΌ ν•΄λ³ΌκΉŒμš”. ν•˜λ‚˜λ‹˜μ˜ 말씀은 ν•˜λ‚˜μ΄κ² μ§€λ§Œ, 성경은 ν•΄μ„ν•˜κΈ°μ— 따라 λ‹€λ¦…λ‹ˆλ‹€. 또 κ·Έ ν•˜λ‚˜ν•˜λ‚˜μ˜ 성경은 ν•˜λ‚˜μ§€λ§Œ κ·ΈλΌ λΏλŠ” μ‚¬λžŒμ΄ 받아듀이기에 따라 λ‹€μ–‘ν•΄μ§‘λ‹ˆλ‹€.

ν•™λ¬Έ, 더 λ„“ν˜€μ„œ 살아감에 μžˆμ–΄ ν•˜λ‚˜μ˜ μ‚¬μ‹€μ΄λ‚˜ μ˜κ²¬μ„ μ ‘ν• λ•Œ, μ ˆλŒ€μ μ΄λž€ 것은 "λͺ…μ œ" λ‚˜ "진리" 같은 것 μ™Έμ—λŠ” μ—†μŒμ„ 생각해보면 닡을 μ°ΎλŠ”λ° 도움이 될 것 μž…λ‹ˆλ‹€. λ‹€λ§Œ, λˆˆμ— λ³΄μ΄λŠ” ν˜•νƒœμ—μ„œλŠ” μ΄λΌ κΈˆλ°© μΈμ§€ν•˜κΈ° μ‰¬μš°λ‚˜, λˆˆμ— 보이지 μ•ŠλŠ” ν˜•νƒœμ΄κ±°λ‚˜(예λΌλ“€λ©΄ 지식), μŠ΅κ΄€μ μœΌλ‘œ λΏμ„λ§Œν•˜λ‹€κ³  μƒκ°λ˜λŠ” λ§€μ²΄μ—μ„œ 얻은 μ •λ³΄λ‚˜ 이야기에 λŒ€ν•΄ "κ²½κ³„μ˜ λ ˆμ΄λ”"λΌ κΊΌλ†“κ±°λ‚˜ λΈμ²˜ μ•Œμ•„μ°¨λ¦΄ 경황이 μ—†κ²Œ λ˜λŠ” κ²½μš°λΌ μ‘°μ‹¬ν•˜λ©΄ 되겠죠.

μ•„.. λˆˆμΉ˜λΌ μ±„μ…¨λ‚˜μš”? 이 글도 κ·Έλƒ₯ κ·ΈλŸ°κ°€λ³΄λ‹€ ν•˜κ³  읽어야 ν•˜λŠ” 글쀑 ν•˜λ‚˜μž…λ‹ˆλ‹€. :) -- μ΄μ„ μš°


늘 ForeverStudent μ—¬μ•Ό 함을 μƒκ°ν•˜κ²Œ λœλ‹€λŠ”. --1002

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:18
Processing time 0.0383 sec