Tuesday, 15 February 2011

java - Understanding the Builder/Factory Pattern -



java - Understanding the Builder/Factory Pattern -

i'm trying clean code have written reading data. have 2 sources of data: database , file. both have separate classes , both classes have optional, non common, parameters in constructors provided (at moment traditional telescoping constructors).both classes implement interface mydata , when instantiate objects instantiate mydata object.

i want merge these classes single class , create instantiation clean possible can't figure out how. im mixture of builder , mill patterns.the user should never have see underlying type mydatabasedata , myfiledata, mydata. can help me sketching out similar illustration set me off in right direction

keep classes separate since different things. combining them create giant mess , violates single responsibility principle.

if don't want users see classes, create classes bundle private.

then create new builder or mill class takes parameters , figures out class instantiate.

hope helps.

java design-patterns factory builder

No comments:

Post a Comment