이 책도 켄트벡의 저술방식을 여실히 드러냅니다. 얇은 책, 이해하기 쉬운 문장, JUnit과 관련된 구체적인 예제. 도입부분은 심도있는 철학을 담고 있지만 구현 패턴의 내용은 평이합니다. 평이하게 느끼도록 하는 것도 그의 재주임에 분명합니다.
컬렉션 부분에서 개인적으로 OCL2.0의 내용과 API들이 표준이 되길 바랍니다. 프레임워크의 진화 부분에서 갑자기 책 내용의 깊이가 달라짐을 느꼈습니다.
책 비평은 주로 프로그래밍 표준에 도움이 될 만한 사항들만을 정리했습니다. 추가적인 정리가 필요한 것은 밑줄로 표시했습니다.
"A program should read like a book."
The goal of this book is to help you communicate your intentions through your code.
p4 그림 1.1
프로그램 뿐이겠습니까? 분석과 설계의 결과 또한 그렇지 않겠습니까? 저는 모든 소프트웨어개발 문서가 책 형태로 작성되어야 한다고 주장합니다. 심지어 코드까지도 말이지요. 주석달지 말고 책으로 설명하기를 원합니다. 프로젝트가 끝나면 개발자들은 자신의 책을 한 권씩 갖게 되는겁니다.
Most programs follow a small set of laws:
- Programs are read more often than they are written.
- There is no such thing as "done". Much more investment will be spent modifying programs than developing them initially.
- They are structured using a basic set of state and control flow concepts.
- Readers need to understand programs in detail and in concept. Sometimes they move from detail to concept, sometimes from concept to detail.
3장. A Theory of Programming중에서
Each pattern carries with it a little bit of theory. there are larger and more pervasive forces at work in programming than are covered in individual patterns, however. They are divided here into two types: values and principles.
The patterns describe what to do. The values provide motivation. The principles help translate motive into action.
Values
Three values that consistent with excellence in programming are communication, simplicity, and flexibility.
Code communicates well when a reader can understand it, modify it, or use it.
Eliminating excess complexity enables those reading, using, and modifying programs to understand them more quickly.
Just as good prose is written with an audience in mind, so good programs are written with an audience in mind. Challenging your audience a little is fine, but too much complexity will lose them.
Programs should be flexible, but only in ways they change.
Principles
Principles can provide an explanation for the motivation behind a pattern, one connected to general rather than specific ideas.
Local Consequences
Structure the code so changes have local consequences.
Minimize Repetition, Logic and Data Together
Symmetry
Once readers understand one half of the symmetry, they can quickly understand the other half.
Symmetry in code is where the same idea is expressed the same way everywhere it appears in the code.
Declarative Expression
Express as much of my intention as possible declaratively.
Rate of Change
Put logic or data that changes at the same rate together and separate logic or data that chnages at different rates. These rates of change are a form of temporal symmetry.
4장. Motivation중에서
The premature attempts to make the code general enough to meet future needs often interfere with the unanticipated changes that turn out to be necessary.
My strategy for reducing overall costs is to ask all programmers to address the cost of understanding code during the maintenace phase by focusing on communicating, programmer-to-programmer.
Conversations about programming are also more interesting when they cover both theory and practice.
5장. Class중에서
여러분의 코드는 도메인 스토리이어야 하고, 도메인의 개념은 클래스이어야 합니다.
인터페이스는 외형으로 외부환경에 대한 특정한 역할에 해당한다. 역할이란 '~을 할 수 있는'으로 'able'이라는 접미어를 갖는게 가장 적당합니다. 단순히 클래스의 선언을 구현으로 부터 분리하는 것이라면 클래스 이름 앞에 접두어 'I'를 사용하는 것이 좋습니다.
추상클래스는 일반화 계층에서의 일반화 클래스에만 사용해야 합니다. 일반화 클래스에 구체적인 행위를 일부 포함할 경우에는 추상클래스로 구현합니다. 그렇지 않은 경우는 인터페이스를 사용합니다.
One way of saying "Here's what I want to accomplish and beyound that are details that shouldn't concern me".
Abstract Class
The super class is abstract in the sense that it can be replaced at runtime with any subclass.
Interfaces and class hierarchies are not mutually exclusive. You can provide an interface which says, "Here's how to access this kind of functionality," and a superclass which says, "Here's one way to implement this functionality." In this case, variables should be declared with the interface as teir type so future maintainers are free to substitute new implementations as necessary.
Versioned Interface
역할을 인터페이스로 구현하였을 경우, 그 역할을 사용하는 client와 구현은 다수일 수 있다. 이 경우 인터페이스를 변경하는 것은 큰 영향을 미칠 수 있다. 이런 경우 versioned interface를 사용한다.
Users who want the new functionality use the extended interface while existing users remain oblivious to the existence of the new interface. Anywhere you want to access the new operation you must explicitly check the type of your object and downcast to the new type.
Value Object
While objects-with-changing-state is one valuable way to think about computation, it is not the only way to think. Mathematics has developed over millennia as a way to think about situations that can be reduced to an abstract wourld of absolute truth and certainty, where statements can be reduced to an abstract world of absolute truth and certainty, where statements can be made about eternal verities.
This functional style of computing never changes any state, it only creates new values. When you have a (perhaps momentarily) static situation about which you'd like to make satements or about which you'd like to ask questions, then the functional style is appropriate.
The beauty of mathematical representations is that sequence seldom matters. You are creating a world in which you can make absolute, timeless statements. Create micro-worlds of mathemetics wherever possible. Manage them from an object with changing state.
The beauty of mathematical representations is that sequence seldom matters.
To implement value-style object, first draw the boundary between the world of state and the world of value.
Having gotten this far, I sense that there is much more to be written about programming with the three main styles - objects, functions, and procedures - and how to blend them effectively.
뭐든 그렇지만 필요한 곳에 올바로 써야 합니다. 잘못된 방법으로 사용하면 그 잘못에 대한 case-by-case적인 해결책들이 등장합니다.
p34부터
6장. State중에서
Rectangle void setWidth(int width)
{
this.width = width;
area = width * height;
}
derived는 간접 액세스
area는 readOnly 속성으로 분리되어야 합니다.
boarded나 unbordered는 optional cardinality를 나타내는 속성입니다. derived속성입니다.
지역변수의 공통 역할들
- collector, count, explaining, reuse, iterated element
복잡한 식을 갖을 때 식의 부분들이 지역변수에 할당 될 수 있다. 지역변수는 한 단계 더 나아가 helper 메소드들이 될 수 있다.
iterated element에는 each를, 개수를 세는 것에는 count를 변수이름으로 사용한다. 같은 이름이 주어져야 한다면 각 이름을 해당 컨텍스트에 맞게 구체화한다. 예를 들어, exchX, rowCount
Lazy initialization says, "Performance is important here."
7장. Behavior중에서
행위적 특징 또한 선언과 정의를 분리해야 합니다. UML은 행위적 특징의 선언을 operation, 정의를 method라 합니다.
오퍼레이션의 body는 수행방법의 전체를 부분의 협력으로 표현할 때는 interaction을 포함한 collaboration으로 한 부분의 상세수행방법을 표현할 때는 수행방법의 특성에 따라 activity 또는 statemachine으로 표현할 수 있습니다.
operation은 해결해야 하는 문제의 관점에서 의도가 표현되어야 하고, method에서는 구체적인 해결방법이 정의되어야 합니다. 하나의 문제를 해결하기 위해 다수의 구체적인 해결방법이 사용될 수 있습니다.
sequence를 통해 소스를 생성할 경우, semetry를 자동으로 맞추어주는 방법을 사용할 수 있습니다.
8장. Methods중에서
Method Object
Helper Method
Conversion Method에 'as' 접두어 사용
Creation 관련
메소드 이름 작성 방법은 'method'란 단어의 의미에 이미 반영되어 있습니다. 어떤 방법을 사용했는지를 드러내야 합니다.
|
Tracked from Younghoe.Info | 2009/08/09 02:23 | DEL
Implementation Patterns를 보고 다 읽지도 않은 책에 대해 한 마디 남긴다. 현남씨 말대로 어려운 영어도 아니고, 켄트 벡 책 답게 얇다. 하지만, 휙 하고 읽어 버리고 싶지 않아 남겨 두었다. 스스로 프로그래밍하는 순간을 모니터링 하는 과정을 통해 나온 지혜다. 그래서, 쉬운 글이라도 쉽게 볼 수는 없다. 경험이 있어야 경험자 이야기를 공감할 수 있다. 언젠가 경험을 하고 나서 다시 읽어보려고 곁에 두고 있다. 매 순간 온힘을 다.. |

