afunms

My Software,My Dream—Forge a more perfect NMS product.

builder 4 report

Completed LinkReport.There are two questions should be improved in the
next version.
  The first,the relevant DAO classes filled with repetitious code.I consider to
reconstruct these DAOs.
  The second,suddenly I am aware that Builder Pattern is the best way to
solve the complex problem of creating a report.

  The code likely be following:
  ReportBuilder builder = new ReportBuilder();
  Director director = new Director( builder );
  director.construct();
  Report report = builder.createReport();

-----------------Builder Pattern------------

The Builder pattern allows a client object to construct a complex object by specifying only its
type and content.The client
is shielded from the details of the object's construction.

It is a pattern for step-by-step creation of a complex object so that the same construction process
can create different
representations is the routine in the builder pattern that also makes for finer
control over the construction process. All
the different builders generally inherit from an abstract
builder class that declares the general functions to be used by the
director to let the builder create
the product in parts.

Builder has a similar motivation to the abstract factory but, whereas in that pattern, the client uses
the abstract factory
class methods to create its own object, in Builder the client instructs the builder
class on how to create the object and
then asks it for the result. How the class is put together is up
to the Builder class. It's a subtle difference.

The Builder pattern is applicable when the algorithm for creating a complex object should be
independent of the parts that
make up the object and how they are assembled and the construction
process must allow different representations for the
object that is constructed.

posted on 2008-01-14 22:25 afunms 阅读(122) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

News

留言簿(18)

随笔档案

相册

搜索

最新评论

阅读排行榜