tag:blogger.com,1999:blog-2920276153412796121.comments2011-10-08T22:55:48.241-07:00Exploring the Nature of CodeJoakim Tengstrandhttp://www.blogger.com/profile/16706442856151153934noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2920276153412796121.post-69782009472258956722011-10-08T22:55:48.241-07:002011-10-08T22:55:48.241-07:00A builder and a creator is solving different probl...A builder and a creator is solving different problems. Take a look at the code of my latest pattern State Guard where I use both a builder and a creator. With a builder you can omit some attributes. With the creator you can ensure that all attributes have been set. Also have a look at the very similar pattern Type-Safe builder mentioned in the previous comment.Joakim Tengstrandhttps://www.blogger.com/profile/16706442856151153934noreply@blogger.comtag:blogger.com,1999:blog-2920276153412796121.post-86976433701495244812011-10-08T22:06:25.198-07:002011-10-08T22:06:25.198-07:00So, you have discovered the GoF Builder Pattern. E...So, you have discovered the GoF Builder Pattern. Even tho you have made it slightly more complicated.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2920276153412796121.post-42319146935153263952011-10-07T23:42:53.124-07:002011-10-07T23:42:53.124-07:00Yes they are very similar and they are solving the...Yes they are very similar and they are solving the same problem. I think the pattern Chained Creater does offer some more options such as adding default values at arbitrary position of the parameter list and I also like the syntax, eg: X.create().name("x").age(30).Joakim Tengstrandhttps://www.blogger.com/profile/16706442856151153934noreply@blogger.comtag:blogger.com,1999:blog-2920276153412796121.post-60392467968148896982011-10-07T23:33:43.453-07:002011-10-07T23:33:43.453-07:00The context-switchable classes are tightly coupled...The context-switchable classes are tightly coupled which is used to avoid making unnecessary validations and format conversions when context-switching between the different representations. If there is a need to context-switch between system boundaries a looser coupling needs to be created such such as a CarAsXml or similar "string-based" format.<br />Interesting links, however I need to improve my Scala skills in order to fully understand them!Joakim Tengstrandhttps://www.blogger.com/profile/16706442856151153934noreply@blogger.comtag:blogger.com,1999:blog-2920276153412796121.post-89107313305671694562011-09-29T01:54:19.027-07:002011-09-29T01:54:19.027-07:00Interesting!
An issue I see with this pattern is ...Interesting!<br /><br />An issue I see with this pattern is that it is not extensible to a third-party (since you'd need to both extend the context switcher AND Car itself to provide new context-switch-methods.<br /><br />I'd recommend having a look at the TypeClass pattern(1) and also Lenses (2)<br /><br />1: http://debasishg.blogspot.com/2010/06/scala-implicits-type-classes-here-i.html<br />2: https://gist.github.com/1240480Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2920276153412796121.post-67241533654183238922011-09-29T01:48:16.498-07:002011-09-29T01:48:16.498-07:00Seems isomorphic to http://blog.rafaelferreira.net...Seems isomorphic to http://blog.rafaelferreira.net/2008/07/type-safe-builder-pattern-in-scala.htmlAnonymousnoreply@blogger.com