<?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 Lucas Polonuer on Medium]]></title>
        <description><![CDATA[Stories by Lucas Polonuer on Medium]]></description>
        <link>https://medium.com/@lucaspolonuer?source=rss-da7e4e7fa7df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1ln1nn-tRwQR9uYl1a7q8A.jpeg</url>
            <title>Stories by Lucas Polonuer on Medium</title>
            <link>https://medium.com/@lucaspolonuer?source=rss-da7e4e7fa7df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 19:07:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucaspolonuer/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[Minimalistic Dev setup for your new Mac]]></title>
            <link>https://medium.com/@lucaspolonuer/minimalistic-dev-setup-for-your-new-mac-1992c514da84?source=rss-da7e4e7fa7df------2</link>
            <guid isPermaLink="false">https://medium.com/p/1992c514da84</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[setup]]></category>
            <dc:creator><![CDATA[Lucas Polonuer]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 12:43:01 GMT</pubDate>
            <atom:updated>2024-06-10T18:48:18.921Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*68LkaS2YYf_uqIUw" /><figcaption>Photo by <a href="https://unsplash.com/@nathadej?utm_source=medium&amp;utm_medium=referral">Nat Weerawong</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This guide is based on my personal experience. No BS, let’s go.</p><h3>My workflow</h3><p>My <strong>Mac workflow</strong> for <strong>development</strong> consists of using <strong>workspaces</strong> dedicated to specific tasks and <strong>quickly switching contexts</strong> between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVCxNoIlgpifE9iarutqcg.png" /></figure><ul><li>Workspace Layout:<br> — All <strong>code-related workspaces</strong> are to the <strong>left</strong>.<br> — All <strong>browser/client</strong> workspaces are to the <strong>right</strong>.<br> — The <strong>Terminal</strong> workspace is in the <strong>middle</strong>.</li><li>Quick Access Tools:<br> — <strong>Messaging</strong> apps, Postman, and SQL clients are on the <strong>main desktop</strong> for <strong>quick access</strong> from any workspace via <strong>Mission Control</strong>.</li><li>Tip:<br> — Go to System Preferences &gt; Mission Control, then un-check <em>“Automatically rearrange Spaces based on most recent use”</em> to keep workspaces in the place you left them.</li></ul><p><strong>Keyboard and Trackpad setup</strong></p><ul><li>Trackpad &gt; More gestures &gt; Swipe between pages &gt; <strong>Scroll left or right with two fingers</strong>. <br> — This is for going <strong>back</strong>/<strong>forward</strong> in <strong>web browsing</strong>.</li><li>Trackpad &gt; More gestures &gt; Swipe between pages &gt; Swipe between full-screen applications &gt; <strong>Swipe left or right with three fingers</strong></li><li>Trackpad &gt; More gestures &gt; Mission control &gt; <strong>Swipe up with three fingers</strong><br> — For <strong>quick access</strong> to the <strong>Mission control</strong></li><li>Dock &gt; Automatically hide and show the Dock</li><li>Keyboard &gt; Key repeat &gt; <strong>Fast</strong></li><li>Keyboard &gt; Delay until repeat&gt; <strong>Short</strong></li></ul><p><strong>Security</strong></p><ul><li>System Preferences &gt; Security &amp; Privacy &gt; General: <strong>Require password immediately after sleep or screen saver begins</strong> <br> — You can keep a grace period of a couple minutes if you prefer, but I like to know that my computer locks as soon as I close it</li><li>System Preferences &gt; Security &amp; Privacy &gt; <strong>FileVault</strong>: Make sure FileVault disk encryption is <strong>enabled</strong></li><li>iCloud: Enable <strong>Find My Mac</strong></li><li>File Extensions visible in Finder: Finder &gt; Preferences &gt; Advanced: Check the box for “<strong>Show all filename extensions</strong>”</li><li>macOS Firewall: System Preferences &gt; Security &amp; Privacy &gt; <strong>Firewall</strong>: Click “<strong>Turn On Firewall</strong>” to enable it</li><li>Terminal App Secure Keyboard Entry (same for iTerm): Open Terminal &gt; Terminal &gt; Preferences &gt; Profiles &gt; <strong>Keyboard</strong>: Check the box for “<strong>Secure Keyboard Entry</strong>”</li><li><strong>macOS Automatic Updates</strong>: System Preferences &gt; Software Update &gt; Advanced: Ensure <strong>all checkboxes are checked</strong> for automatic updates</li></ul><p><strong>Terminal</strong></p><ul><li>Download and install <a href="http://www.iterm2.com/">iTerm2</a></li><li>Install <a href="https://ohmyz.sh/#install"><em>oh-my-zsh</em></a></li></ul><pre>sh -c &quot;$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)&quot;</pre><p>If you get a recurring error after installing oh-my-zsh you probably need to set the locale on the terminal:</p><pre>echo &#39;export LANG=en_US.UTF-8&#39; &gt;&gt; ~/.zshrc</pre><p><strong>Homebrew</strong></p><p>Install <a href="https://brew.sh/"><strong>homebrew</strong></a> as a package manager</p><pre>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;<br>export PATH=&quot;/opt/homebrew/bin:$PATH&quot; &gt;&gt; ~/.zshrc</pre><p><strong>Git Configuration</strong>:</p><p>Set Up <strong>SSH</strong> for Git: Using SSH keys is a secure way to authenticate with Git repositories. You can see the instructions <a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account">here</a>.</p><p>Also, set up your global Git configuration:</p><pre>git config --global user.name &quot;Your Name&quot;<br>git config --global user.email &quot;your.email@example.com&quot;</pre><p><strong>Visual Studio Code</strong></p><p>Download and install <a href="https://code.visualstudio.com/Download">VSCode</a></p><p>Press <strong>cmd⌘</strong> + <strong>, </strong>(comma) and click on the document with an arrow icon at the top right corner, that will open the settings.json file.<br>This is my recommended configuration:</p><pre>{<br>  &quot;editor.tabSize&quot;: 2,<br>  &quot;editor.rulers&quot;: [80],<br>  &quot;files.insertFinalNewline&quot;: true,<br>  &quot;files.trimTrailingWhitespace&quot;: true,<br>  &quot;workbench.editor.enablePreview&quot;: true, // for opening files with one click and close them automatically when you click on another file<br>}</pre><p><strong>Docker Desktop</strong></p><p>I’ve found the desktop app for Docker is pretty useful and it has been improved a lot since its release. You can install it <a href="https://www.docker.com/products/docker-desktop/">here</a>.</p><p><strong>Javascript development</strong></p><p>Install <a href="https://marketplace.visualstudio.com/items?itemName=rvest.vs-code-prettier-eslint">vscode-prettier-eslint</a> extension (make sure to have the proper dev dependencies for eslint and prettier in your project, they are also listed on the plugin instructions page)</p><p>Modify the settings.json in VSCode adding the following:</p><pre>{<br>  // ...previous settings,<br>  &quot;editor.defaultFormatter&quot;: &quot;rvest.vs-code-prettier-eslint&quot;,<br>  &quot;editor.formatOnType&quot;: false, // required for vs-code-prettier-eslint<br>  &quot;editor.formatOnPaste&quot;: false, // optional<br>  &quot;editor.formatOnSave&quot;: true, // optional<br>  &quot;editor.formatOnSaveMode&quot;: &quot;file&quot;, // required to format on save<br>  &quot;vs-code-prettier-eslint.prettierLast&quot;: false // set as &quot;true&quot; to run &#39;prettier&#39; last not first<br>}</pre><p>Install <a href="https://github.com/nvm-sh/nvm">nvm</a> for managing node versions, then, in your project(s) folder run nvm install.</p><blockquote>Note: you may be asked to install XCode Command Line Tools at some point during these installs. Just run the wizard normally.</blockquote><h3>Extras</h3><p><strong>BetterTouchTool</strong></p><p>I’ve found this app very useful for mapping quick shortcuts that combine my keyboard and my <strong>external mouse</strong>. I tooked advantage of the left side-buttons on my mouse to use them to quickly switch between workspaces. I mapped the following key combinations:</p><ul><li><strong>ctrl </strong>+<strong> scroll wheel</strong>: Displays Mission Control</li><li><strong>ctrl </strong>+<strong> left side button 1 </strong>of my mouse: Switches workspaces to the left</li><li><strong>ctrl </strong>+<strong> left side button 2 </strong>of my mouse: Switches workspaces to the right</li></ul><p>Download <a href="https://folivora.ai/">BetterTouchTool</a>.</p><p><strong>Alfred</strong></p><p>A powerful productivity application that replaces Spotlight. It allows for quick searches, app launching, and custom workflows.</p><p>Download <a href="https://www.alfredapp.com/">here</a>.</p><p><strong>Spectacle</strong>:</p><p>A simple and free app for window management.</p><p>Download <a href="https://www.spectacleapp.com/">here</a>.</p><p><strong>Backup Solution</strong>:</p><p>Use Time Machine or another backup solution to ensure your data is regularly backed up.</p><p>You can also check and save this guide in <a href="https://github.com/lucaspolonuer/mac-minimal-setup">GitHub</a> if you like!</p><p>These are my own personal recommendations for mac developments. If you have any other tools or configurations that you find indispensable, feel free to share them in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1992c514da84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ruby on Rails: Boost your software design skills with Interactors]]></title>
            <link>https://medium.com/@lucaspolonuer/ruby-on-rails-boost-your-software-design-skills-with-interactors-e07f1f9a711e?source=rss-da7e4e7fa7df------2</link>
            <guid isPermaLink="false">https://medium.com/p/e07f1f9a711e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Lucas Polonuer]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 04:25:36 GMT</pubDate>
            <atom:updated>2020-08-03T05:14:19.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQmpa7zsU4zocFVdilhcZw.jpeg" /><figcaption>Engineering by <a href="https://unsplash.com/@thisisengineering?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/s/photos/whiteboard?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’ve been using Rails for a while and I’ve seen multiple approaches on how to handle <strong>business logic</strong> in applications.</p><blockquote>But wait.. what do you mean by ‘Business logic’?</blockquote><p>Well, <strong>business logic</strong> is.. <em>literally that</em>, it’s the collection of processes that make logical decisions, transformations, and calculations following your business-specific rules.</p><p>Imagine that users can sign up in your app by filling a form in the frontend. The frontend sends a POST request to your <strong>/users</strong> route with the user params in the request body.</p><h4>Let’s take a simple test:</h4><blockquote>Which one of these actions is business logic?</blockquote><blockquote>1- Fetching a request’s body and parsing the JSON content into an object.</blockquote><blockquote>2- Checking that the ‘email’ is actually a valid email string using a Regex</blockquote><blockquote>3- Validating that the user received in the creation request has a unique username and it’s not underage</blockquote><blockquote>4- Saving a new user into our users table in our PostgreSQL database.</blockquote><p>You can see here that options <strong>1</strong>,<strong>2</strong> and <strong>4</strong> are handling <strong>generic logic</strong> such as parsing JSON data, checking the format of an email string, and persisting data in a database. Those are actions that <em>could exist</em> in <strong>any other application</strong>, they are not specific to our business rules, they handle <strong>common mechanics</strong>.</p><p>On the contrary, the <strong>3rd option</strong> is purely <strong>business logic</strong>, it handles some rule that is <strong>specific to our use case</strong>: <em>users should have a username and it should be unique amongst the other users in our database, also, users should be adults (age&gt;18).</em></p><p>Web frameworks like <strong>Rails</strong> aim to simplify our lives solving most of these <em>non-business-logic</em> actions for us and letting us devs focus on coding what’s important to our business.</p><figure><img alt="Photo by Joshua Fuller in Unsplash" src="https://cdn-images-1.medium.com/max/240/1*jf6j6q_8069JpDCRgyYA6A.jpeg" /></figure><p><strong>Ruby on Rails</strong> gives us <strong>Controllers</strong>, in which we will handle requests that are made to our app: <em>grab the input here, do something with it, and send back a response. </em>And it also gives us <strong>ActiveRecord models</strong> where we will handle our persistent models. And that’s cool, you know, even though there is some <a href="https://stackoverflow.com/questions/7864/why-all-the-active-record-hate">hate</a> over ActiveRecord… we won’t get into that for now, it works, for the most cases. But, there is something unclear…</p><h3>Where do we put our Business Logic™?</h3><p>We really shouldn’t put logic in our models since we don’t want to break the single responsibility principle. And we want to avoid having <strong>fat controllers</strong> too.</p><p>For example, we may have this in our <strong>create</strong> action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7add6e23aff5dfdeb1ba82ff900f9ccd/href">https://medium.com/media/7add6e23aff5dfdeb1ba82ff900f9ccd/href</a></iframe><p>That is <em>some amount</em> of logic in there.. and it could grow worse by the time.</p><p>A common practice between Rails developers to solve this is to create <strong>Service Objects</strong>, which are just <strong>POROs </strong>that encapsulate actions.</p><blockquote>PORO: Plain Old Ruby Object</blockquote><p>This is the <a href="https://sourcemaking.com/design_patterns/command"><strong>command pattern</strong></a>, where we encapsulate an operation inside an object, decoupling the object(s) that perform the required actions from the object that was called originally, in our case: <strong>the controller</strong>.</p><p>We could create a <strong>PORO</strong> to handle this operation, but the thing is.. there are no clear guidelines for <em>implementing</em> them, and every developer can come up with a different approach, which could lead to inconsistencies. We opted out for using a gem that implements them and also gives us some <em>special features</em> out-of-the-box.</p><h3>The Interactor gem</h3><p>Let’s take a look at the <a href="https://github.com/collectiveidea/interactor-rails">interactor gem</a>.</p><p>This gem is very simple, for each action or use-case, we create a class named after it, and we call it invoking the call method passing the params for that action as a hash argument. These params are called the context for this task.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0e252de677201b75508ef7717005d8a/href">https://medium.com/media/a0e252de677201b75508ef7717005d8a/href</a></iframe><p>Now, the controller just does what it’s supposed to do, which is to take care of all the controller-y things: <em>Parse the parameters, respond with an error, or a success. </em>And the business-related action is delegated to this <strong>isolated, reusable and testable</strong>CreateUser class, which will return a <strong>result</strong> object with the details of the operation’s success.</p><blockquote>We only have to make sure our interactor is working fine to know that our business logic is behaving as expected</blockquote><p>Let’s say that <strong>users</strong> can sign up in the frontend and <strong>also</strong> we have some API integration with a 3rd party reseller of our product that can create users in our app through a specific endpoint.</p><pre>/v1/frontend/users#create -&gt; Users sign up in the frontend</pre><pre>/v1/integrations/users#create -&gt; A 3rd party reseller creates users through this endpoint</pre><p>We would have <strong>different controllers</strong> calling the<strong> same interactor</strong>, we only have to make sure our interactor is working fine to know that our business logic is behaving as expected, independently of how many routes perform the same action in our app. That’s a great improvement in code maintainability. Cool, right?</p><h3>Before, after and around</h3><p>The gem also provides us <strong>hooks</strong> that we can use to organize our actions inside an interactor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d104bf1694b0a53e0ece85df2f38914a/href">https://medium.com/media/d104bf1694b0a53e0ece85df2f38914a/href</a></iframe><p>Now validations are run in the ‘<strong>before’</strong> <strong>hook</strong>, and the welcome email is sent inside the ‘<strong>after’ hook</strong>, ensuring the operation was completed and it was successful. So our call method only handles the action of creating the user. We also could do something like wrap up all of the call method inside an <strong>ActiveRecord Transaction</strong> using the <a href="https://github.com/collectiveidea/interactor#around-hooks">‘<strong>around’ hook</strong></a>.</p><h3>Organizers and reusability</h3><p>Note here that sending the welcome email could be separated from creating the user because they are two different actions. CreateUser should take care of only one thing: <em>creating the user</em>. So we can create another interactor to send the email, our controller will now have something like:</p><pre>def create<br>  ...<br>  user_result = CreateUser.call(user_params)<br>  ...<br>  email_result = SendWelcomeEmail.call(user: user_result.user)</pre><pre>  ...render result...<br>end</pre><p>Though calling a lot of interactors in the same method could negatively affect our code’s readability and maintainability. To solve this we can <strong>wrap </strong>multiple interactors within an <strong>Organizer class</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65bd281ef052476e104676a79a05238a/href">https://medium.com/media/65bd281ef052476e104676a79a05238a/href</a></iframe><p>And we could also reuse that SignUpUser operation or create new organizers combining other interactors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*cj5pygmSdI8_1xt7iqHh7A.jpeg" /><figcaption>Different controllers reuse an interactor</figcaption></figure><p>Going back to the API integration example, we may have a <em>slightly different way of signing up users</em>, for instance, the users created via the frontend endpoint will receive a <strong>confirmation</strong> email but the ones created within the API endpoint will get just a <strong>welcome</strong> email saying <em>“Thank you for signing up in behalf of our authorized reseller!”</em>. That could translate to having both SignUpAndConfirmUser and SignUpAndWelcomeUser operations which call the same CreateUser interactor underneath.</p><h3>Wrapping up</h3><p>We’ve seen how we can refactor our code by writing interactors, achieving a clearer definition of our business rules, and a strict separation between controllers, models, and business logic. Also, we saw how reusing interactors and grouping them together can result in overall cleaner code.</p><h3>Recommendations</h3><p>Here are some articles that were of great help for me to understand Interactors for the first time.</p><ul><li>The official documentation for the Interactor gem: <a href="https://github.com/collectiveidea/interactor">https://github.com/collectiveidea/interactor</a></li><li>A cool post written by <strong>Tiago Farias</strong>, which explains the interactor gem in detail and also dives into the <strong>advantages</strong>, <strong>caveats</strong>, and <strong>cons</strong> of it: <a href="https://goiabada.blog/interactors-in-ruby-easy-as-cake-simple-as-pie-33f66de2eb78">https://goiabada.blog/interactors-in-ruby-easy-as-cake-simple-as-pie-33f66de2eb78</a></li><li>Another implementation of the Interactor pattern by <strong>dry-rb</strong>: <a href="https://dry-rb.org/gems/dry-transaction/0.13/">https://dry-rb.org/gems/dry-transaction/0.13/</a> (<em>The Dry team is awesome</em>)</li><li>A blog post explaining Service Objects and implementation with <strong>POROs</strong>: <a href="https://blog.appsignal.com/2020/06/17/using-service-objects-in-ruby-on-rails.html">https://blog.appsignal.com/2020/06/17/using-service-objects-in-ruby-on-rails.html</a></li></ul><h3>Happy coding!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e07f1f9a711e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>