星期二, 5月 25, 2004

Builder Pattern...

From Design Pattern Java workbook, it mentions that a builder can be written as:

Builder b = new Builder() ;
new Parser(b).parse();
result = b.build();

I have spent whole day to design these two classes. It looks like very simple to implement, but test-case is a little bit hard to code. parse() itself is a very coarse-grained method. there are too many assertXxxx() for this method. Another approach is that following JUnit in Action's practice, using package-private instead of full-private for each fine-grained method. By this, one may test every single step if making test-case place in the same package.

Which one is best ? still no idea....

0 Comments:

張貼留言

<< Home