Execute Around Method

id:kakutani:20040909#p1 より
Execute Around MethodはKent Beckの『Smalltalkベストプラクティス・パターン』に書かれているものですよね。
C2には以下のようなサンプルが載っています(http://www.c2.com/cgi/wiki?ExecuteAroundMethod)

Instead of:

 aFile open.
 self doSomethingWith: aFile.
 aFile close.

We have:

 aFile openDuring: [self doSomethingWith: aFile].

The implementation of File>>openDuring would look something like this:

 File>>openDuring: aBlock
  self open.
  aBlock value.
  self close.

duringですか。なるほど。『Smalltalkベストプラクティス・パターン』にもopenDuringのサンプルが書かれていました。ただこの命名クロージャやブロックをサポートしている言語でないとしっくり来ないかもしれませんね。Javaでやってみるとなんとなく違和感があります。だからTemplateなのかもしれません。私の場合はまだまだ修行が足りないだけかもしれませんが...