tag:blogger.com,1999:blog-12467669.post346344106005236643..comments2023-04-29T07:23:25.825-04:00Comments on Jay Fields' Thoughts: Domain Specific Languages don't follow the Principle of Least SurpriseJayhttp://www.blogger.com/profile/14491442812573747680noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-12467669.post-50100716579430666832008-10-03T09:15:00.000-04:002008-10-03T09:15:00.000-04:00I agree in that modifying the expected behavior of...I agree in that modifying the expected behavior of "include" is bad practice, but IMO the notion that your "data_mapper_resource" gives the user different choices seems a bit backwards in terms of improving readability... In the case of Datamapper, the library is meant for a specific purpose. The more options you provide to do exactly the same would only add to confusion. If I'm new to DM and see both approaches in different codebases I will be rather confused and expect different behaviours.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-3003244503711840672008-09-13T10:17:00.000-04:002008-09-13T10:17:00.000-04:00By the way, it's "its" when talking about DataMapp...By the way, it's "its" when talking about DataMapper's methods.<BR/><BR/>At any rate, nice article! The `become' method is interesting, though I'm still working the internal debate on if I agree with it or not.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-86906044611597442432008-09-11T08:41:00.000-04:002008-09-11T08:41:00.000-04:00@linh, yes.@linh, yes.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-56534840958366138342008-09-11T03:11:00.000-04:002008-09-11T03:11:00.000-04:00Do you expect any module passed to Object#become t...Do you expect any module passed to Object#become to implement the instance_behaviour and class_behaviour methods in your solution?<BR/><BR/>class Object<BR/> def become(mod)<BR/> include mod.instance_behaviors<BR/> extend mod.class_behaviors<BR/> end<BR/>endAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-77584963945145374782008-09-10T10:13:00.000-04:002008-09-10T10:13:00.000-04:00@ymendel, yes, that's probably better.Cheers, Jay@ymendel, yes, that's probably better.<BR/><BR/>Cheers, JayAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-49058057849009642742008-09-10T00:00:00.000-04:002008-09-10T00:00:00.000-04:00Why add these methods to Object instead of Class?Why add these methods to Object instead of Class?Unknownhttps://www.blogger.com/profile/14578777551736290686noreply@blogger.comtag:blogger.com,1999:blog-12467669.post-76283566152172516352008-09-08T09:57:00.000-04:002008-09-08T09:57:00.000-04:00@charly: One obvious problem with that is that you...@charly: One obvious problem with that is that you're telling Speakable to become a Person, which seems arse about face somehow.<BR/><BR/>The obvious method to use there is <B>extend</B>, but that's already taken for a method that would probably be better named <B>extend_with</B> or similar.<BR/><BR/>Ho hum.pdcawleyhttps://www.blogger.com/profile/09681803905544703714noreply@blogger.comtag:blogger.com,1999:blog-12467669.post-6833673342225374022008-09-08T07:14:00.000-04:002008-09-08T07:14:00.000-04:00If the issue is clarity of "what is happening here...If the issue is clarity of "what is happening here?" perhaps you could alias #include to be #include_and_extend which you would use instead to tell the reader that including this module is going to also extend the class?Dr Nichttps://www.blogger.com/profile/17833227514368162020noreply@blogger.comtag:blogger.com,1999:blog-12467669.post-74930683330696995072008-09-08T05:16:00.000-04:002008-09-08T05:16:00.000-04:00I agree with Rick's comment in Ola Bini post. ...I agree with Rick's comment in Ola Bini post. <BR/><BR/>"Why not put the include line in the #do_funky_madness_on (alias become) method?"<BR/><BR/>module Speakable<BR/> def self.become(klass)<BR/> klass.send :include, InstanceMethods<BR/> klass.extend ClassMethods<BR/> end<BR/>end<BR/><BR/>class Person<BR/> Speakable.become(self)<BR/>endAnonymoushttps://www.blogger.com/profile/04049594060358724842noreply@blogger.comtag:blogger.com,1999:blog-12467669.post-87720678613750245822008-09-08T04:47:00.000-04:002008-09-08T04:47:00.000-04:00A quick comment about your mention of "append_feat...A quick comment about your mention of "append_features": Append features is a deprecated precursor to the included method which does not require that you invoke super like append_features did.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-12467669.post-82690765806115811832008-09-08T02:52:00.000-04:002008-09-08T02:52:00.000-04:00I'm afraid the margin of this blog post (or at lea...I'm afraid the margin of this blog post (or at least, it's utility for writing code snippets) is to narrow for the comment I want to write, so I've <A HREF="http://www.bofh.org.uk/articles/2008/09/08/if-youre-going-to-add-a-hook-make-it-a-big-one" REL="nofollow">blogged about it</A> instead.pdcawleyhttps://www.blogger.com/profile/09681803905544703714noreply@blogger.com