<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Domain Specific Languages</title>
        <link>http://www.ayende.com/Blog/category/547.aspx</link>
        <description>Domain Specific Languages</description>
        <language>en-US</language>
        <copyright>Ayende Rahien</copyright>
        <managingEditor>Ayende@ayende.com</managingEditor>
        <generator>Subtext Version 1.9.3.51</generator>
        <item>
            <title>Open seats for the DSL course</title>
            <link>http://ayende.com/Blog/archive/2008/05/10/Open-seats-for-the-DSL-course.aspx</link>
            <description>&lt;p&gt;There are still open seats for the DSL course in Austin, next week (19th - 20th May).&lt;/p&gt;
&lt;p&gt;You can register here: &lt;a href="http://ayende.eventbrite.com/"&gt;http://ayende.eventbrite.com/&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://ayende.com/Blog/aggbug/10217.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/10/Open-seats-for-the-DSL-course.aspx</guid>
            <pubDate>Sat, 10 May 2008 17:55:12 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10217.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/10/Open-seats-for-the-DSL-course.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10217.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Course: Building Domain Specific Languages in Boo</title>
            <link>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx</link>
            <description>&lt;p&gt;You can &lt;a href="http://ayende.eventbrite.com/"&gt;register here&lt;/a&gt; for a two days course in building DSL with Boo.&lt;/p&gt;
&lt;p&gt;It is going to take place two weeks from today, in Austin. (19 - 20 May)&lt;/p&gt;
&lt;p&gt;I know that this is short notice, but it wasn't something that was planned well in advance. It came out of the ALT.Net conference.&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;&lt;strong&gt;Topics&lt;/strong&gt;:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Creating Domain Specific Languages&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;The Boo Language&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Flexible compiler and malleable language&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Creating applications with embedded DSL&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Management, tracing and debugging&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Tooling support&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;Testing and maintainability concerns&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;There are ten seats open for that.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;I hope we would have fun.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #333333; font-family: Verdana; font-size: 11px;"&gt;I would also like to thank &lt;a href="http://codebetter.com/blogs/jeffrey.palermo/"&gt;Jeffrey Palermo&lt;/a&gt; and &lt;a href="http://www.headspringsystems.com/"&gt;Headspring&lt;/a&gt; for hosting the course.&lt;/span&gt;&lt;/p&gt;
&lt;img src="http://ayende.com/Blog/aggbug/10210.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx</guid>
            <pubDate>Tue, 06 May 2008 01:33:54 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10210.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/05/06/Course-Building-Domain-Specific-Languages-in-BooCourse-Building-Domain-Specific.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10210.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DSL Article on InfoQ</title>
            <link>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx</link>
            <description>&lt;p&gt;&lt;img src="http://www.infoq.com/resource/articles/dsl-on-the-clr/en/smallimage/image_boo.jpg" width="100" height="100" alt="image_boo.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;My DSL article has been published on InfoQ!&lt;/p&gt;
&lt;p&gt;You can get it &lt;a href="http://www.infoq.com/articles/dsl-on-the-clr"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://ayende.com/Blog/aggbug/10189.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx</guid>
            <pubDate>Mon, 21 Apr 2008 16:10:20 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10189.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/04/21/DSL-Article-on-InfoQ.aspx#feedback</comments>
            <slash:comments>13</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10189.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The quote generation DSL</title>
            <link>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx</link>
            <description>&lt;p&gt;I am doing some work on the DSL book right now, and I run into this example, which is simple too delicious not to post about.&lt;/p&gt;  &lt;p&gt;Assume that you have the following UI, which you use to let a salesperson generate a quote for your system. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ThequotegenerationDSL_1A0C/image_2.png"&gt;&lt;img height="278" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/ThequotegenerationDSL_1A0C/image_thumb.png" width="299" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This is much more than just a UI issue, to be clear. You have fully fledged logic system here. Calculating the total cost is the easy part, first you have to understand what you need.&lt;/p&gt;  &lt;p&gt;Let us define a set of rules for the application, is will be clearer when we have the list in front of us:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The Salary module requires a machine per every 150 users. &lt;/li&gt;    &lt;li&gt;The Taxes module requires a machine per 50 users.&lt;/li&gt;    &lt;li&gt;The Vacations module requires the Scheduling Work module.&lt;/li&gt;    &lt;li&gt;The Vacations module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Pension Plans module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Pension Plans module must be on the same machine as the Health Insurance module.&lt;/li&gt;    &lt;li&gt;The Health Insurance module requires the External Connections module.&lt;/li&gt;    &lt;li&gt;The Recruiting module requires a connection to the internet, and therefore requires a fire wall of the recommended list.&lt;/li&gt;    &lt;li&gt;The Employee Monitoring module requires the CompMonitor component&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Of course, this fictitious sample is still too simple, we can probably sit down and come up with fifty or so more rules that we need to handle. Just handling the second level dependencies (External Connections, CompMonitor, etc) would be a big task, for example.&lt;/p&gt;  &lt;p&gt;Assume that you have not a single such system, but 50 of them. I know of a company that spent 10 years and has 100,000 lines of C++ code (that implements a poorly performing Lisp machine, of course) to solve this issue.&lt;/p&gt;  &lt;p&gt;My solution?&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @vacations:
	&lt;font color="#800000"&gt;requires&lt;/font&gt; @scheduling_work
	&lt;font color="#800000"&gt;requires&lt;/font&gt; @external_connections
	
&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @salary:
	&lt;font color="#800000"&gt;users_per_machine&lt;/font&gt; 150
	
&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @taxes:
	&lt;font color="#800000"&gt;users_per_machine&lt;/font&gt; 50

&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @pension:
	&lt;font color="#800000"&gt;same_machine_as&lt;/font&gt; @health_insurance&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why do we need a DSL for this? Isn’t this a good candidate for data storage system? It seems to me that we could have expressed the same ideas with XML (or a database, etc) just as easily. Here is the same concept, now express in XML.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"vacation"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requires&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"scheduling_work"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;requires&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"external_connections"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"salary"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;users&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_per_machine&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"150"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"taxes"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;users&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_per_machine&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"50"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"pension"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;
	&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;same&lt;/span&gt;&lt;span style="color: #ff0000"&gt;_machine_as&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;=&lt;span style="color: #0000ff"&gt;"health_insurance"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;
&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;specification&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a one to one translation of the two, why do I need a DSL here?&lt;/p&gt;

&lt;p&gt;Personally, I think that the DSL syntax is nicer, and the amount of work to get from a DSL to the object model is very small compared to the work required to translate to the same object model from XML.&lt;/p&gt;

&lt;p&gt;That is mostly a personal opinion, however. For pure declarative DSL, we are comparable with XML in almost all things. It gets interesting when we decide that we don’t want this purity. Let us add a new rule to the mix, shall we?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Pension Plans module must be on the same machine as the Health Insurance module, if the user count is less than 500.&lt;/li&gt;

  &lt;li&gt;The Pension Plans module requires distributed messaging backend, if the user count is great than 500.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trying to express that in XML can be a real pain. In fact, it means that we are trying to shove programming concepts into the XML, which is always a bad idea. We could try to put this logic in the quote generation engine, but that is complicating it with no good reason, tying it to the specific application that we are using, and in general making a mess.&lt;/p&gt;

&lt;p&gt;Using our DSL (with no modification needed), we can write it:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;&lt;font color="#0000ff"&gt;specification&lt;/font&gt; @pension: 
	&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; information.UserCount &amp;lt; 500: 
		&lt;font color="#800000"&gt;same_machine_as&lt;/font&gt; @health_insurance 
	&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;: 	
		&lt;font color="#800000"&gt;requires&lt;/font&gt; @distributed_messaging_backend&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;As you can imagine, once you have run all the rules in the DSL, you are left with a very simple problem to solve, with all the parameters well known.&lt;/p&gt;

&lt;p&gt;In fact, &lt;em&gt;throughout the process&lt;/em&gt;, there isn't a single place of overwhelming complexity.&lt;/p&gt;

&lt;p&gt;I like that.&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10143.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx</guid>
            <pubDate>Sun, 30 Mar 2008 22:51:21 GMT</pubDate>
            <wfw:comment>http://ayende.com/Blog/comments/10143.aspx</wfw:comment>
            <comments>http://ayende.com/Blog/archive/2008/03/31/The-quote-generation-DSL.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10143.aspx</wfw:commentRss>
        </item>
        <item>
            <title>New version of the book out!</title>
            <link>http://ayende.com/Blog/archive/2008/03/14/New-version-of-the-book-out.aspx</link>
            <description>&lt;p&gt;Chapters 5 - 7 are now available, covering a lot of the building of a DSL and integrating that into an application.&lt;/p&gt; &lt;p&gt;This version contains a lot of fixes from reviewers, but I intend to make some chapter shuffling which will put the hard core stuff toward the middle of the book, after we cover more interesting scenarios.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=854_111"&gt;&lt;img alt="Building DSL with Boo Cover" src="http://www.ayende.com/images/rahien_cover150.jpg" border="0" /&gt;&lt;br /&gt;Building Domain Specific Languages with BOO&lt;/a&gt;&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10097.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/03/14/New-version-of-the-book-out.aspx</guid>
            <pubDate>Fri, 14 Mar 2008 10:14:33 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/03/14/New-version-of-the-book-out.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10097.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Building Domain Specific Languages in Boo: Available for early access</title>
            <link>http://ayende.com/Blog/archive/2008/02/17/Building-Domain-Specific-Languages-in-Boo-Available-for-early-access.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/BuildingDomainSpecificLanguagesinBooAvai_1471B/image_2.png"&gt;&lt;img height="188" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/BuildingDomainSpecificLanguagesinBooAvai_1471B/image_thumb.png" width="150" align="right" border="0" /&gt;&lt;/a&gt; Well, this is a big moment. My &lt;a href="http://www.manning.com/rahien/"&gt;book&lt;/a&gt; is now available for as part of the &lt;a href="http://www.manning.com/rahien/"&gt;Manning Early Access Program&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Chapter 1 to 4 are already there, but they are there in their nearly raw format. That means that they have not been edited yet, and I didn't put in the results from the review cycle that we did yet.&lt;/p&gt; &lt;p&gt;The book forum is &lt;a href="http://www.manning-sandbox.com/forum.jspa?forumID=403&amp;amp;start=0"&gt;here&lt;/a&gt;, I eagerly awaits the posts telling me how off base I am :-)&lt;/p&gt; &lt;p&gt;More seriously, I would appreciate any feedback that you have on the book, the topic, the code, etc.&lt;/p&gt; &lt;p&gt;Thanks,&lt;/p&gt; &lt;p&gt;  ~Ayende&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10057.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/02/17/Building-Domain-Specific-Languages-in-Boo-Available-for-early-access.aspx</guid>
            <pubDate>Sun, 17 Feb 2008 21:15:51 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/02/17/Building-Domain-Specific-Languages-in-Boo-Available-for-early-access.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10057.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Fun with DSL - Didja know the CLR allows it?</title>
            <link>http://ayende.com/Blog/archive/2008/02/14/Fun-with-DSL--Didja-know-the-CLR-allows-it.aspx</link>
            <description>&lt;p&gt;I swear that I didn't mean to do it, but it just happened. &lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/FunwithDSLDidjaknowtheCLRallowsit_E927/image_2.png"&gt;&lt;img height="355" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/FunwithDSLDidjaknowtheCLRallowsit_E927/image_thumb.png" width="749" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10051.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/02/14/Fun-with-DSL--Didja-know-the-CLR-allows-it.aspx</guid>
            <pubDate>Thu, 14 Feb 2008 14:34:20 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/02/14/Fun-with-DSL--Didja-know-the-CLR-allows-it.aspx#feedback</comments>
            <slash:comments>14</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10051.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Refactoring for Separation Of Concerns: A real world example</title>
            <link>http://ayende.com/Blog/archive/2008/02/14/Refactoring-for-Separation-Of-Concerns-A-real-world-example.aspx</link>
            <description>&lt;p&gt;I just did a major refactoring to Rhino DSL, to add orthongality to the DslEngine. It was an interesting refactoring, and something that is worth talking about.&lt;/p&gt; &lt;p&gt;Let us take a look at the before image, first:&lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/Orthogonality_D7C7/image_2.png"&gt;&lt;img height="379" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/Orthogonality_D7C7/image_thumb.png" width="508" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;We have two classes that are involved in creating and managing DSL. Notice the FileFormat, CreateInput, GetMatchingUrlsIn and NotifyOnChange methods on the DslEngine? Or the GetFromCache, RemoveFromCache, SetInCache methods?&lt;/p&gt; &lt;p&gt;The firsts are related to the storage of the DSL scripts on disk and the second batch are related to caching, they have nothing to do with the actual work performed by the DslEngine. Those are completely different responsibilities and concerns. I didn't feel the pain of mixing the responsibilities until I had to create a class that wanted to change the storage mechanism of the scripts.  Looking at it, the cache methods especially really want to move to another class. You can tell by their names.&lt;/p&gt; &lt;p&gt;Then I realized that I had to override a bunch of methods and correlate results between them, and I found myself thinking, "Who the hell wrote this nightmare?" *.&lt;/p&gt; &lt;p&gt;Changing the storage mechanism, something that I certainly wanted to support, has gotten fairly involved, and I couldn't see anyone figuring out all the knobs they had to turn without reading the source, carefully. This is a bad situation to be in.&lt;/p&gt; &lt;p&gt;Hence, refactoring.&lt;/p&gt; &lt;p&gt;What was involved in this was mostly moving code around. The technicalities of it where mostly these:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Ask R# to extract super class with the unrelated methods.&lt;/li&gt; &lt;li&gt;Ask R# to extract an interface from the new super class&lt;/li&gt; &lt;li&gt;Remove the inheritance association with the DslEngine&lt;/li&gt; &lt;li&gt;Add a property for the new interface type&lt;/li&gt; &lt;li&gt;Initialize the property to use a default implementation&lt;/li&gt; &lt;li&gt;Fix code that broke as a result (mostly involved adding the property name before the method).&lt;/li&gt; &lt;li&gt;Rename methods to match current location (Removing the "Cache" from the methods in the caching interface).&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The result is this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/Orthogonality_D7C7/image_10.png"&gt;&lt;img height="408" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/Orthogonality_D7C7/image_thumb_4.png" width="643" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Now, changing the storage mechanism doesn't need to affect the DSL implementation. We have a more robust model, and a good example for the blog.&lt;/p&gt; &lt;p&gt;Of course, I just finished writing half a chapter about the old way of doing things... Time for a rewrite. &lt;/p&gt; &lt;p&gt;* I often think thoughts like this, the sad answer is often: "Me".&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10050.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/02/14/Refactoring-for-Separation-Of-Concerns-A-real-world-example.aspx</guid>
            <pubDate>Thu, 14 Feb 2008 13:41:55 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/02/14/Refactoring-for-Separation-Of-Concerns-A-real-world-example.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10050.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Debugging DSL</title>
            <link>http://ayende.com/Blog/archive/2008/01/31/Debugging-DSL.aspx</link>
            <description>&lt;p&gt;Well, that is fairly easy, all you need it to press F11 :-)&lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/DebuggingDSL_222/image_2.png"&gt;&lt;img height="322" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/DebuggingDSL_222/image_thumb.png" width="466" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10032.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/01/31/Debugging-DSL.aspx</guid>
            <pubDate>Wed, 30 Jan 2008 22:08:41 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/01/31/Debugging-DSL.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10032.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Purely declarative DSL</title>
            <link>http://ayende.com/Blog/archive/2008/01/30/Purely-declarative-DSL.aspx</link>
            <description>&lt;p&gt;Let us assume that we need to build a quote generation program. This mean that we need to generate a quote out of the customer desires and the system requirements.&lt;/p&gt; &lt;p&gt;The customer's desires can be expressed in this UI:&lt;/p&gt; &lt;p&gt;&lt;a href="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/PurelydeclarativeDSL_8BAA/image_2.png"&gt;&lt;img height="274" alt="image" src="http://ayende.com/Blog/images/ayende_com/Blog/WindowsLiveWriter/PurelydeclarativeDSL_8BAA/image_thumb.png" width="295" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The system requirements are:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The Salary module is specification is a machine per every 150 users. &lt;/li&gt; &lt;li&gt;The Taxes module requires a machine per 50 users.&lt;/li&gt; &lt;li&gt;The Vacations module requires the Scheduling Work module.&lt;/li&gt; &lt;li&gt;The Vacations module requires the External Connections module.&lt;/li&gt; &lt;li&gt;The Pension Plans module requires the External Connections module.&lt;/li&gt; &lt;li&gt;The Pension Plans module must be on the same machine as the Health Insurance module.&lt;/li&gt; &lt;li&gt;The Health Insurance module requires the External Connections module.&lt;/li&gt; &lt;li&gt;The Recruiting module requires a connection to the internet, and therefore requires a fire wall of the recommended list.&lt;/li&gt; &lt;li&gt;The Employee Monitoring module requires the CompMonitor component&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The first DSL that I wrote for it looked like this:&lt;/p&gt; &lt;blockquote&gt;&lt;pre&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; has( "&lt;span style="color: #8b0000"&gt;Vacations&lt;/span&gt;" ):
	add "&lt;span style="color: #8b0000"&gt;Scheduling&lt;/span&gt;"
	
number_of_machines["&lt;span style="color: #8b0000"&gt;Salary&lt;/span&gt;"] = (user_count % 150) +1
number_of_machines["&lt;span style="color: #8b0000"&gt;Taxes&lt;/span&gt;"] = (user_count % 50) +1
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;But this looked like a really bad idea, so I turned to a purely declarative approach, like this one:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;specification @vacations:
	requires @scheduling_work
	requires @external_connections
	
specification @salary:
	users_per_machine 150
	
specification @taxes:
	users_per_machine 50

specification @pension:
	same_machine_as @health_insurance
&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;The problem with this approach is that I wonder, is this really something that you need a DSL for? You can do the same using XML very easily.&lt;/p&gt;
&lt;p&gt;The advantage of a DSL is that we can put logic in it, so we can also do something like:&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;specification @pension: 
	&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; user_count &amp;lt; 500:
		same_machine_as @health_insurance
	&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;:
		requires @distributed_messaging_backend
		requires @health_insurance&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;Which would be much harder to express in XML.&lt;/p&gt;
&lt;p&gt;Of course, then we are not in the purely declarative DSL anymore.&lt;/p&gt;
&lt;p&gt;Thoughts?&lt;/p&gt;&lt;img src="http://ayende.com/Blog/aggbug/10030.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ayende Rahien</dc:creator>
            <guid>http://ayende.com/Blog/archive/2008/01/30/Purely-declarative-DSL.aspx</guid>
            <pubDate>Wed, 30 Jan 2008 08:01:35 GMT</pubDate>
            <comments>http://ayende.com/Blog/archive/2008/01/30/Purely-declarative-DSL.aspx#feedback</comments>
            <slash:comments>15</slash:comments>
            <wfw:commentRss>http://ayende.com/Blog/comments/commentRss/10030.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>