<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gabriel Cotelli on Medium]]></title>
        <description><![CDATA[Stories by Gabriel Cotelli on Medium]]></description>
        <link>https://medium.com/@g.cotelli.mcp?source=rss-53fec3779bfe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wN4VqBVA1DPEXc6F.</url>
            <title>Stories by Gabriel Cotelli on Medium</title>
            <link>https://medium.com/@g.cotelli.mcp?source=rss-53fec3779bfe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:52:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@g.cotelli.mcp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Conference Report: ESUG 2018]]></title>
            <link>https://medium.com/mercap-tech-blog/conference-report-esug-2018-402d317abce2?source=rss-53fec3779bfe------2</link>
            <guid isPermaLink="false">https://medium.com/p/402d317abce2</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pharo]]></category>
            <category><![CDATA[smalltalk]]></category>
            <dc:creator><![CDATA[Gabriel Cotelli]]></dc:creator>
            <pubDate>Thu, 04 Oct 2018 18:13:29 GMT</pubDate>
            <atom:updated>2018-10-04T18:16:53.895Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Between the 10th and 14th of September I attended the Smalltalk european conference: <a href="https://esug.github.io/2018-Conference/conf2018.html">ESUG 2018</a>, held in Cagliari, Italy, representing <a href="https://www.mercapsoftware.com/">Mercap</a>. It was my first time in Europe and a great experience. There was a lot going on the whole week, so I will highlight my favorites.</p><p>I arrived a few days early, just in time for the Camp Smalltalk and discovering the city. And no, the Camp Smalltalk is not that kind of camp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*fg-fhu2YJdsPB-Tuq3Q5eQ.jpeg" /><figcaption><a href="https://pixabay.com/en/camp-outdoor-travel-adventure-tent-2587926/">Photo credit</a></figcaption></figure><p>It’s something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zofrd7kemyeQyUZdf9bOBA.jpeg" /><figcaption><a href="http://www.a3aan.st/esug2018/index.php/list/">Photo by Adriaan van Os’</a></figcaption></figure><h3>Day 1</h3><p>The conference started officially on Monday. My favorite talks for this day were:</p><ul><li><strong>Open Source, an infinite game by Marcus Denker</strong>: It was mostly a philosophical talk, but really cool.</li><li><strong>Reshaping the development experience</strong>: Tudor Girba showed the <a href="https://github.com/feenkcom/gtoolkit-documenter">GTDocumenter</a> tool that his team is doing (currently in alpha). The basic idea is to deeply integrate the documentation within the development environment and making it interactive with the living objects residing in the image. I think it’s a pretty cool concept that will require further refinement.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__KwC122dTw5fiaQg1pZvw.jpeg" /><figcaption>Photo by Adriaan van Os’</figcaption></figure><p>After the talks it was time to do the demo for the Innovation Awards. I proposed two products: <a href="https://github.com/ba-st/Willow">Willow</a> and <a href="https://www.mercapabbaco.com/">Mercap Abbaco,</a> and when I arrived there were two “stands” (one for each product demo), so I had to bring everything to one place and do a multiple demo. Self-hint for the next time: propose only one project or be more than one person :) .</p><p>It was a looong day and I came back to the hotel for the dinner, but what a great start! I talked to a lot of people and saw a lot of cool stuff.</p><h3>Day 2</h3><p>I started the day by walking to the conference site. Cagliari is a really nice city so it was a pleasure to discover it by walking. By the way, always have a map at hand because the historic center is like a labyrinth.</p><p>A glimpse of my favorite talks:</p><ul><li><strong>Smalltalk Security Landscape:</strong> It was about security in the different distributions and it was a great reminder that as a community we need to be more aware of this stuff.</li><li><strong>Docker and Pharo at ZWEIDENKER by Marcus Denker and Norbert Hartl: </strong>An experience report on how the company is deploying Pharo in docker containers and scaling it. We’re doing something similar at Mercap (deploying not only Pharo but also VA Smalltalk) and it was nice to see other people going the same route and sharing their experience.</li><li><strong>Iceberg 2018: bringing Pharo to git, or git to Pharo? by Guille Polito</strong> Nice update on the latest development of Iceberg. I have to say that the last year it has greatly improved over the previous version.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*7qq6fc4z624wtj9Khh8paA.jpeg" /><figcaption>Photo by Adriaan van Os’</figcaption></figure><p>After the official track was time for <strong>“Show us your projects”. </strong>There were something like 20 projects inscribed so it took a lot of time, my highlights were:</p><ul><li><strong>Pharo Sentry by Peter Uhnak: </strong>Integration between Pharo and sentry.io.</li><li><strong>Git migration tool by Peter Uhnak: </strong>A tool to migrate a codebase including it’s history from Monticello to a git repository.</li><li><strong>Compiler bindings by Marcus Denker</strong>: Marcus showed us some support he added to the Pharo compiler so you can pass it your own bindings. You can use it for example to work on the compiler itself without breaking the version in use. It’s pretty cool and I can imagine other use cases like: <br>1. Using the existing tests for OrderedCollection to test a new implementation but changing the bindings to #OrderedCollection in the tests only without breaking the rest of the system. <br>2. Having an optimized version of some class and using it in specific parts of the code without having to change all the references.</li><li><strong>Docker-API and OpenAPI by Norbert Hartl: </strong>Norbert showed some tooling to control and visualize a Docker Swarm inside Pharo and integration with Open API.</li></ul><h3>Day 3</h3><p>This was a shorter day because of the Social Event in the night. Besides the talk I gave on Willow, it was a nice day:</p><ul><li><a href="https://gemtalksystems.com/">Gemtalk Systems</a> and <a href="http://www.instantiations.com/">Instantiations</a> talked about the latest releases and roadmap for both GemStone/S and VA Smalltalk. BTW Seth Berman was appointed president and CEO of Instantiations. Congrats Seth!</li><li><strong>Seaside Add-Ons: </strong>Cyril Ferlicot showed some <a href="https://github.com/dunest">cool add-ons</a> made on top of Seaside at use in <a href="http://synectique.eu/">Synectique.</a> Including integration with Material Design Lite, prism.js for syntax highlighting , chart. js and Cytoscope for visualizations.</li><li><strong>Willow: the interaction tour: </strong>This was the talk I presented. It went very well. I introduced <a href="https://github.com/ba-st/Willow">Willow</a> and focused the talk on the interaction affordances the library provides. You can check the slides online <a href="https://docs.google.com/presentation/d/e/2PACX-1vQQ0rNfT4b-wjcaz69cE2cKvkRlxdQCG6m1HxAocgJ_adoraVLrDCkhuPFhSPxfBACohL2x5JDRv5mk/pub?start=false&amp;loop=false&amp;delayms=3000">here</a>. The talk had a good repercussion, so I’m very happy with the end result:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*5KBU04EjrelxuBPuPjhPBw.jpeg" /></figure><ul><li><strong>Tools for Smart Contract Analysis, </strong>Santiago Bragagnolo introduced Fog, a driver for the Ethereum blockchain in Pharo.</li></ul><p>The talks ended early so everyone had time to go back to the hotel and prepare for the social event. It was held at night on a beach-side restaurant. The Innovation Awards winners were announced during the social event. Congratulations to all the winners! You can see the list <a href="https://esug.github.io/2018-Conference/awardsSubmissions2018.html">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIUTfxgxivvsNT4Nf3Cyfw.jpeg" /><figcaption>Smalltalkers Bus by Giovanni Corriga</figcaption></figure><h3>Day 4</h3><p>After the Social Event the previous night, the schedule slipped a bit.</p><ul><li><strong>Enjoying Parsing: </strong>John Brant introduced us to some new tooling he’s working on for Pharo and SmaCC, including grammar syntax highlighting, some simple grammar refactorings and templates and a SmaCC aware Debugger mode. Everything built on top of GToolkit. Nice!</li><li><strong>Clap: </strong>Damien Pollet showed the improvements on CLAP (<strong>C</strong>ommand <strong>L</strong>ine <strong>A</strong>rgument <strong>P</strong>arser) for Pharo. It looks like a really clean design and it’s intended to be used as part of the CLI for the next Pharo version.</li><li><strong>Stateful Traits in Pharo:</strong> Pablo Tesone talked about the current iteration on the traits support, now providing state and behavior sharing. It’s an optional package to the Pharo kernel, and it ended up begin similar to Mixins but with an explicit conflict resolution mechanism, putting the developer in control.</li><li><strong>Using system-level tools to debug smalltalk systems</strong>: Jan Vrany gave a really interesting talk. I couldn’t grasp all the fine print, but he basically showed us some tooling to debug a segmentation fault in the VM, rolling back the execution stack and program state until the point where the segmentation fault cause is produced, easily fixing it. Wow! Take a look at the video once it’s made available.</li></ul><p><strong>Day 5</strong></p><p>The last day ended up about lunch time.</p><ul><li>The <a href="https://github.com/PolyMathOrg/PolyMath">PolyMath</a> project reached v1.0.0-alpha, so if you’re interested in doing science with Pharo give it a try.</li></ul><p>In the afternoon we went to the beach and ended up eating into a restaurant there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Qq6I4EVwWOjqMZnCzzPHQ.jpeg" /></figure><h3>Conclusion</h3><p>It was an intense and very productive week. A very good opportunity to meet in person people who I only knew virtually, and to meet interesting people and projects that I didn’t know, besides being able to show and discuss what we do in this little corner at the south of the world.</p><p>I also discovered that apparently we are planning a stealthy invasion of France by sending Argentinians to work at INRIA with <a href="https://www.pharo.org/">Pharo</a> :).</p><p>Bye bye Cagliari, I hope to see you folks again in another year!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meYchYIcYTXtp-7F4FOtMA.jpeg" /><figcaption>Leaving Cagliari</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=402d317abce2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mercap-tech-blog/conference-report-esug-2018-402d317abce2">Conference Report: ESUG 2018</a> was originally published in <a href="https://medium.com/mercap-tech-blog">mercap-blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tabular data in Willow]]></title>
            <link>https://medium.com/mercap-tech-blog/tabular-data-in-willow-d949527f5ba2?source=rss-53fec3779bfe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d949527f5ba2</guid>
            <category><![CDATA[pharo]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[smalltalk]]></category>
            <dc:creator><![CDATA[Gabriel Cotelli]]></dc:creator>
            <pubDate>Fri, 11 May 2018 18:01:01 GMT</pubDate>
            <atom:updated>2018-05-11T20:54:30.723Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gn-OUtqO4tdLI1FLGihIg.png" /><figcaption><a href="https://www.flickr.com/photos/28772513@N07/5281149490">Image credit</a></figcaption></figure><p>The HTML &lt;table&gt; element represents tabular data — that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.</p><p>Willow provides a ready to use component that given a collection can create a table with one row for each object in the collection and one column for each one the user configured.</p><p>So for example given the following collection #(1 2) you can get this table showing if the number is even or not:</p><pre>&lt;table&gt;<br>  &lt;tbody&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;false&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;true&lt;/td&gt;<br>    &lt;/tr&gt;<br>  &lt;/tbody&gt;<br>&lt;/table&gt;</pre><p>by rendering the following table</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/423dffa89e7558b48c38a0c5d7e56139/href">https://medium.com/media/423dffa89e7558b48c38a0c5d7e56139/href</a></iframe><p>So lets dig a bit on this code. Sending the message tableBuilder to the component supplier we get a builder for making tables. Now we can configure the columns we want, in that case we&#39;re adding a column and telling it how to render each cell getting each object in the collection as an argument (number). The only mandatory configuration we need to provide for a column is the rendering action.</p><p>We can send another configuration message to the column:</p><ul><li>titled: allow us to set a title for the column, so now the table will have a header:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a08e944227663a93480a5ec2c2970d4a/href">https://medium.com/media/a08e944227663a93480a5ec2c2970d4a/href</a></iframe><p>will produce:</p><pre>&lt;table&gt;<br>  &lt;thead&gt;<br>    &lt;th&gt;Is even?&lt;/th&gt;<br>  &lt;/thead&gt;<br>  &lt;tbody&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;false&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;true&lt;/td&gt;<br>    &lt;/tr&gt;<br>  &lt;/tbody&gt;<br>&lt;/table&gt;</pre><ul><li>titled:applying: works like titled: but we can send a command to be applied to the header cell.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e1f7a78dcd2c2f07d28480d05c10e1e/href">https://medium.com/media/5e1f7a78dcd2c2f07d28480d05c10e1e/href</a></iframe><p>will produce:</p><pre>&lt;table&gt;<br>  &lt;thead&gt;<br>    &lt;th class=&quot;willow&quot;&gt;Is even?&lt;/th&gt;<br>  &lt;/thead&gt;<br>  &lt;tbody&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;false&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;true&lt;/td&gt;<br>    &lt;/tr&gt;<br>  &lt;/tbody&gt;<br>&lt;/table&gt;</pre><ul><li>summarizedWith: and summarizedWith:applying: allow us to configure a table footer.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/799471c54b4e9fd98655f53c22431fc3/href">https://medium.com/media/799471c54b4e9fd98655f53c22431fc3/href</a></iframe><p>will produce:</p><pre>&lt;table&gt;<br>  &lt;thead&gt;<br>    &lt;th class=&quot;willow&quot;&gt;Is even?&lt;/th&gt;<br>  &lt;/thead&gt;<br>  &lt;tbody&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;false&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;true&lt;/td&gt;<br>    &lt;/tr&gt;<br>  &lt;/tbody&gt;<br>  &lt;tfoot&gt;<br>    &lt;td&gt;false&lt;/td&gt;<br>  &lt;/tfoot&gt;<br>&lt;/table&gt;</pre><p>Now we can add another column:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11a516497c4c0bfa8b23beac37fbb1a5/href">https://medium.com/media/11a516497c4c0bfa8b23beac37fbb1a5/href</a></iframe><p>will produce:</p><pre>&lt;table&gt;<br>  &lt;thead&gt;<br>    &lt;th&gt;&lt;/th&gt;<br>    &lt;th class=&quot;willow&quot;&gt;Is even?&lt;/th&gt;<br>  &lt;/thead&gt;<br>  &lt;tbody&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;1&lt;/td&gt;<br>      &lt;td&gt;false&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>      &lt;td&gt;2&lt;/td&gt;<br>      &lt;td&gt;true&lt;/td&gt;<br>    &lt;/tr&gt;<br>  &lt;/tbody&gt;<br>  &lt;tfoot&gt;<br>    &lt;td&gt;&lt;strong&gt;All even?&lt;/strong&gt;&lt;/td&gt;<br>    &lt;td&gt;false&lt;/td&gt;<br>  &lt;/tfoot&gt;<br>&lt;/table&gt;</pre><p>This component supports two important Willow APIs that we will explain in further posts, but as a reference they are:</p><h3>Container</h3><p>This component supports the Container API so you can:</p><ul><li>Change it’s contents by sending changeContentsTo:</li><li>Get the table elements by sending contents</li><li>Subscribe to receive notifications when the contents change by sending notifyChangesTo:</li></ul><h3>Interaction</h3><p>This component supports the Willow Interaction API by sending to it the onTrigger message, and this will hook in the click event of the table.</p><p>Thank you for reading and feel free to share your impressions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d949527f5ba2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mercap-tech-blog/tabular-data-in-willow-d949527f5ba2">Tabular data in Willow</a> was originally published in <a href="https://medium.com/mercap-tech-blog">mercap-blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supporting team coding standards]]></title>
            <link>https://medium.com/mercap-tech-blog/supporting-team-coding-standards-af270140591d?source=rss-53fec3779bfe------2</link>
            <guid isPermaLink="false">https://medium.com/p/af270140591d</guid>
            <category><![CDATA[team-collaboration]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pharo]]></category>
            <category><![CDATA[smalltalk]]></category>
            <category><![CDATA[automation-tools]]></category>
            <dc:creator><![CDATA[Gabriel Cotelli]]></dc:creator>
            <pubDate>Mon, 26 Mar 2018 20:01:01 GMT</pubDate>
            <atom:updated>2018-03-26T20:01:01.534Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6GKwf7KJqlxy57w3FbrZQ.jpeg" /><figcaption><a href="https://pxhere.com/en/photo/1326397">Image credit</a></figcaption></figure><h3>Supporting team coding standards: Crafting Lint rules</h3><p>In a <a href="https://medium.com/mercap-tech-blog/crafting-automated-verification-of-coding-standards-3ab351144cb8">previous post</a> we learned how to craft a simple check using the already present test facilities of the language. We also mentioned the existence of Lint tools: in <a href="http://www.instantiations.com/products/vasmalltalk/index.html">VA Smalltalk</a> this tool is called <a href="http://www.refactory.com/smalllint">SmallLint</a> and in <a href="https://www.pharo.org/">Pharo</a> it is called Quality Assistant. Both tools — following the open ecosystem philosophy — allow to expand the provided rules in an easy way.</p><p>One advantage of automating the team coding standards is that when a new team member arrives, every time a unit of work is closed these checks are run, and this helps the newcomer adapt to the team idiosyncrasy. In that sense it is essential that every check or rule implemented is accompanied by a rationale explaining why the team considers it a good or bad practice.</p><p>There are some examples of this ideas on the wild. For example the <a href="http://seaside.st/">Seaside</a> web framework comes with its own program checker called <a href="http://book.seaside.st/book/components/slime/program-checker">Slime</a>, which expands the SmallLint rules.</p><p>Let&#39;s see now some of the rules that our team added and their rationale.</p><blockquote>This examples will make use of the <a href="http://www.refactory.com/the-rewritetool">Rewrite Engine Syntax</a>, so a minimal understanding of that is a plus. If you don’t know it: in a nutshell `@variable matches almost any expression in the parse tree.</blockquote><p>The first rules we will see have the same rationale: <a href="http://lambda-the-ultimate.org/node/3186">It is not a good idea to return (or assign) nil</a> as the result of a message send. Because in general it causes a lot of unmaintainable &quot;nil checks&quot; on the senders (or beautiful errors in runtime :P ).</p><h4>Uses #ifTrue: or #ifFalse: individually</h4><p>The rationale here is to avoid using ifTrue: or ifFalse: individually and returning, assigning to a variable or passing as a parameter the result, because in case the block is not evaluated the result will be nil .</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>usesIfTrueOrIfFalseIndividually</pre><pre>  ^self createParseTreeRule: #(<br>    ‘^<strong>`@object</strong> ifTrue: <strong>``@block</strong>’ <br>    ‘^<strong>`@object</strong> ifFalse: <strong>``@block</strong>’<br>    ‘`var := <strong>``@object</strong> ifTrue: <strong>``@block</strong>’ <br>    ‘`var := <strong>``@object</strong> ifFalse: <strong>``@block</strong>’<br>    ‘<strong>``@object</strong> `message: (<strong>``@anotherObject</strong> ifTrue: <strong>``@block</strong>)’<br>    ‘<strong>``@object</strong> `message: (<strong>``@anotherObject</strong> ifFalse: <strong>``@block</strong>)’<br>    ) name: ‘Uses #ifTrue: or #ifFalse: individually’</pre><blockquote>Every line inside the Array is a parse tree matching expression.</blockquote><h4>Uses #ifNotNil: individually</h4><p>The rationale here is similar to the previous case. Because in case the receiver is nil the block is not evaluated and the result will be nil .</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>usesIfTrueOrIfFalseIndividually</pre><pre>^self createParseTreeRule: #(<br>    ‘^<strong>`@object</strong> ifNotNil: <strong>``@block</strong>’ <br>    ‘`var := <strong>``@object</strong> ifNotNil: <strong>``@block</strong>’ <br>    ‘<strong>``@object</strong> `message: (<strong>``@anotherObject</strong> ifNotNil: <strong>``@block</strong>)’<br>    ) name: ‘Uses #ifNotNil: individually’</pre><h4>Returns or assigns #detect:ifFound: result</h4><blockquote>This method is an extension we made to the Collection hierarchy (<a href="https://www.pharo.org/">Pharo</a> includes it now in the base class library) to help when you want to do something with the result of a detect: but just in case a matching object is found.</blockquote><p>The rationale here is similar to the previous case (note that in Pharo it will return the collection and not nil as our original implementation does). In any case if you&#39;re sending this message you shouldn&#39;t be using the result.</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>returnsOrAssignsDetectIfFound</pre><pre>^self createParseTreeRule: #(<br>  &#39;^<strong>`@receiver</strong> detect: <strong>`@detectBlock</strong> ifFound: <strong>`@foundBlock</strong>&#39;<br>  &#39;`var := <strong>`@receiver</strong> detect: <strong>`@detectBlock</strong> ifFound: <strong>`@foundBlock</strong>&#39;<br>  ) name: ‘Return or Assigns #detect:ifFound:’</pre><h3>Intention revealing rules</h3><p>The next cases don&#39;t uncover bugs but improve the readability of the resulting code.</p><h4>Uses #detect:ifNone: instead of #anySatisfy: / #noneSatisfy:</h4><p>This rule catches some newbie mistakes, mostly because they missed some message on the Collection API that better suits the situation.</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>returnsOrAssignsDetectIfFound</pre><pre>^self createParseTreeRule: #(<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) isNil&#39;<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) = nil&#39;<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) == nil&#39;<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) notNil&#39;<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) ~= nil&#39;<br> &#39;(``@col detect: [:`e| |`@temps| ``@.exp] ifNone: [nil]) ~~ nil&#39; ) <br>name: ‘Uses #detect:ifNone: instead of #anySatisfy:/#noneSatisfy:’</pre><p>When we detect something like that in a code review, if it&#39;s possible we add a new rule suggesting the replacement code so it should never happen again.</p><h4>Assignment and testing</h4><p>We found that sometimes it is hard to grasp the code intention when an object is assigned to some variable and then immediately sent a message on the same expression. So for the sake of clarity we prefer to make the assignment first and send the message in the following statement.</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>assignmentAndTesting</pre><pre>^self  createParseTreeRule: #(‘( `var := `@object ) `message’)<br>       name: ‘Assigns and tests an object’</pre><h4>Uses 1 / object instead of #reciprocal</h4><p>This one seems to be superfluous, but in <a href="https://www.mercapsoftware.com/">Mercap</a> we develop financial software and we have a lot of math abstractions besides numbers, like prices, quotes, money measures, etc. Therefore it is clearer to send the reciprocal message to a math object to get the inverse, for example instead of doing 1 / (20.45 ARS/USD) we do (20.45 ARS/USD) reciprocal to get a reverse currency quote. When you have a long financial formula this provides better readability.</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>assignmentAndTesting</pre><pre>^self  createParseTreeRule: #(&#39;1 / `@object&#39;) <br>       name: &#39;Uses 1 / object instead of #reciprocal&#39;</pre><h3>Bugs and Possible Bugs</h3><h4>Uses cascading in Array/OrderedCollection creation. Remove the extra “;”</h4><p>This rule comes from bad experiences converting some #add: cascade to a simpler method send. For example turning:</p><pre><strong>OrderedCollection</strong> new <br>  add:1;<br>  add:2;<br>  add:3;<br>  yourself</pre><p>into</p><pre><strong>OrderedCollection</strong> with: 1 with: 2 with: 3</pre><p>It happened a lot that we did some search for #add: then replaced it with #with: forgetting to remove the ; and only noticed it when some test fails later.</p><pre><strong>ParseTreeLintRule class&gt;&gt;</strong>avoidCascadingAnArrayCreation</pre><pre>^self createParseTreeRule: #(<br>  ‘Array with: `@firstObject ; with: `@secondObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject ; with: `@thirdObject’<br>  ‘Array with: `@firstObject with: `@secondObject ; with: `@thirdObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject with: `@thirdObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject ; with: `@thirdObject ; with: `@fourthObject’<br>  ‘Array with: `@firstObject with: `@secondObject ; with: `@thirdObject ; with: `@fourthObject’<br>  ‘Array with: `@firstObject with: `@secondObject with: `@thirdObject ; with: `@fourthObject’<br>  ‘Array with: `@firstObject with: `@secondObject ; with: `@thirdObject with: `@fourthObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject with: `@thirdObject ; with: `@fourthObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject ; with: `@thirdObject with: `@fourthObject’<br>  ‘Array with: `@firstObject ; with: `@secondObject with: `@thirdObject with: `@fourthObject’<br>)<br>name: ‘Uses cascading in Array/OrderedCollection creation. Remove the extra “;”’</pre><blockquote>The previous example is using Array, but the original rule is a bit more complex including other collections. I&#39;ve simplified it here for didactic reasons.</blockquote><h4>Class implements #doesNotUnderstand: but misses #respondsTo:</h4><p>This rule covers a possible bug and checks that if a class implements #doesNotUnderstand: it probably needs to implement #respondsTo: as well, because these methods are supposed to work in tandem. We don&#39;t use it a lot but found some cases when we missed the #respondsTo: implementation and noticed it too late.</p><pre><strong>BlockLintRule</strong>&gt;&gt;implementorsOfDoesNotUnderstandMustImplementRespondsTo</pre><pre>^self new <br>  resultClass: <strong>ClassEnvironment</strong>;<br>  name: ‘Class implements #doesNotUnderstand: but misses #respondsTo:’;<br>  classBlock: [:context :result | | <strong>currentClass</strong> |<br>    <strong>currentClass</strong> := context selectedClass.<br>    ((<strong>currentClass</strong> includesSelector: #doesNotUnderstand:)<br>     and: [(<strong>currentClass</strong> includesSelector: #respondsTo:) not])<br>        ifTrue: [result addClass: <strong>currentClass</strong>]];<br>  yourself</pre><p>Thank you for reading and feel free to share your own rules or practices. If you haven’t automated these rules so far, start now!.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af270140591d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mercap-tech-blog/supporting-team-coding-standards-af270140591d">Supporting team coding standards</a> was originally published in <a href="https://medium.com/mercap-tech-blog">mercap-blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crafting automated verification of coding standards]]></title>
            <link>https://medium.com/mercap-tech-blog/crafting-automated-verification-of-coding-standards-3ab351144cb8?source=rss-53fec3779bfe------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ab351144cb8</guid>
            <category><![CDATA[smalltalk]]></category>
            <category><![CDATA[coding-style]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[automation-tools]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <dc:creator><![CDATA[Gabriel Cotelli]]></dc:creator>
            <pubDate>Fri, 16 Mar 2018 14:56:01 GMT</pubDate>
            <atom:updated>2018-03-28T21:20:08.608Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wp_jVQTo0IaqKWoIz2VVKg.jpeg" /><figcaption><a href="http://maxpixel.freegreatpicture.com/Sci-Fi-Forward-Robot-Moon-Space-Universe-Planet-2256814">Image credit</a></figcaption></figure><p>In a world where automation is increasingly ubiquitous and inexpensive to produce, we still are maintaining a lot of information about team coding standards in boring documents.</p><p>Every programming language now comes with a <a href="https://en.wikipedia.org/wiki/Lint_(software)">Lint-like</a> tool which checks the language best practices. However, each team has its own coding practices and standards, and these usually end up in a document and not in an executable specification.</p><p>At <a href="https://www.mercapsoftware.com/">Mercap</a> we use Smalltalk (more than one dialect) and one of the advantages of having an open environment with very interesting metaprogramming capabilities is that it allows you to easily build as code many of these practices and rules defined by the team. These checks are then automatically run before closing a unit of work, instead of being dead text in a document.</p><p>This is the first in a series of posts where the idea is to share the team standards and practices we automated and how we did it. We will see that it is not rocket science, when the tools are adequate and allow the programmer to take control of the development environment and make it their own.</p><p>Our first case is a simple one: We have a naming scheme for packages containing the tests of another package: Given a package named P then the corresponding test package must be named P+&#39;Tests&#39; .</p><blockquote>This convention allows us to infer programmatically given a package, the name of the package containing the test cases, and the other way around.</blockquote><p>The check that we are going to implement then is: For all the packages containing tests authored by the Mercap team check the existence of its package under test.</p><blockquote>In <a href="http://www.instantiations.com/products/vasmalltalk/index.html">VA Smalltalk</a> the component representing a package is called an Application an it&#39;s a first class object, we can send it messages and implement new behavior.</blockquote><h4><strong>Getting the packages of our authorship</strong></h4><p>Hands on! We must first be able to discern from all the packages available in the image which ones are authored by the Mercap team, because it makes no sense to run this check on third party packages. We can get all the available packages in the image with:</p><pre>System loadedApplications</pre><p>Now we need a way to filter the packages authored by the team. We can implement it in several ways, let’s start with the easier one:</p><blockquote>Any time we create a new package in VA Smalltalk it creates automatically for us a subclass of Application named like the package and representing it. For example if we create a package “Math”, the system creates a subclass of Application called Math.</blockquote><p>So we will add a new method to Application telling us if the package is authored by Mercap or not:</p><pre>Application class &gt;&gt; #isOwnedByMercap</pre><pre>  ^ false</pre><p>Now we just need to re-implement it in the classes representing the packages authored by us. For example, if we created a “Math” package:</p><pre>Math class &gt;&gt; #isOwnedByMercap</pre><pre>  ^ true</pre><p>Great! Now we can easily filter the packages:</p><pre>System loadedApplications select: [:package | package isOwnedByMercap ]</pre><blockquote>This is just one possible implementation, we can do something similar using the ENVY/Developer functionality that allows us to attach metadata to each software component under version control. Maybe a future post will go this route.</blockquote><p>The methods added are versioned alongside the code of each package. A disadvantage of this implementation is that any time a new package is created we need to remember to implement the #isOwnedByMercap method. This can be improved in several ways, for example we can change the IDE so the “Create Package” action automatically compiles the method (because if anyone at Mercap creates a new package we know that it must be marked as authored by Mercap).</p><blockquote>Usually in Smalltalk the IDE is implemented in the same language and can be changed without effort, so it’s possible to tailor it to our convenience.</blockquote><h4>Implementing the check</h4><p>Now we have all the pieces we need to implement our check. Just create a new TestCase and add the following method:</p><pre>testAllTestPackagesOwnedByMercapHaveACorrespondingPackageUnderTest</pre><pre>| allPackages allPackageNames testPackages failedPackages |</pre><pre>allPackages := System loadedApplications select: [:package | package isOwnedByMercap].</pre><pre>testPackages := allPackages select: [:package | package name endsWith: #Tests].</pre><pre>allPackageNames := allPackages collect: [:package | package name].</pre><pre>failedPackages := testPackages reject: [:testPackage | <br> | expectedPackageName |<br> expectedPackageName := testPackage name withoutLast: #Tests size.<br> allPackageNames includes: expectedPackageName].</pre><pre>self assert: failedPackages isEmpty</pre><p>Voilà! Our first automated check is implemented and ready to be run alongside the rest of our test suite.</p><p>Thanks for reading and see you in the <a href="https://medium.com/mercap-tech-blog/supporting-team-coding-standards-af270140591d">next post</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ab351144cb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mercap-tech-blog/crafting-automated-verification-of-coding-standards-3ab351144cb8">Crafting automated verification of coding standards</a> was originally published in <a href="https://medium.com/mercap-tech-blog">mercap-blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>