<?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 yarn_rp on Medium]]></title>
        <description><![CDATA[Stories by yarn_rp on Medium]]></description>
        <link>https://medium.com/@yansarorodriguezpaez?source=rss-9570cbf63864------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gzMXy-u2fp_iLWFOzaXWfw.jpeg</url>
            <title>Stories by yarn_rp on Medium</title>
            <link>https://medium.com/@yansarorodriguezpaez?source=rss-9570cbf63864------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:20:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yansarorodriguezpaez/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[How Alex Turns a Support Fire Drill Into a Ready-to-Work Ticket]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/how-alex-turns-a-support-fire-drill-into-a-ready-to-work-ticket-2c7505b1536c?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c7505b1536c</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[meetings]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 13:41:13 GMT</pubDate>
            <atom:updated>2025-11-17T13:41:13.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*jtEZ18R327MBHAZcgampCw.png" /></figure><p>In the last story, <a href="https://www.blueprint2.me/"><strong>Alex</strong></a> stayed with the team through a feature’s life cycle: from idea in Slack to user story to tickets.</p><p>Here’s the same idea, but on the support side:</p><blockquote><em>- A real </em><strong><em>bug shows up</em></strong><em>.<br>- </em><strong><em>Support</em></strong><em> feels the heat.<br>- </em><strong><em>Engineers</em></strong><em> jump in.<br>- </em><strong><em>Alex</em></strong><em> stays with everyone from first ping to final ticket.</em></blockquote><p>We’ll keep using the same example:<br>items disappearing from a board after reconnecting an integration.</p><h3>1. Support Brings the Problem to the Team</h3><p>The customer has already talked to a support agent. They’ve shared their screen, explained the problem, maybe reproduced it once.</p><p>After that call, the support agent comes into the internal Slack channel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZzBGKuKGe5ZSB9mIfCh9w.png" /></figure><p>They add <strong>more context</strong>: which customer is affected, which board it hits, how often it happens. <strong>Alex</strong> is already in that channel, tracking the thread from the very first message. Engineers jump in with <strong>questions</strong>, log snippets, and <strong>early theories</strong>. Support drops a direct quote from the customer — it hits harder than any metric. Someone flags a <strong>recent change</strong> in the sync flow that might be related.</p><p>The thread heats up. This isn’t a one-off glitch anymore; it’s a real issue the team needs to fix fast. So someone says:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwyTbngwkd68LsV8gp-1dg.png" /></figure><h3>2. One Call, Everyone + Alex</h3><p>Now the support agent, a few engineers, and whoever owns that area are all in a meeting. <strong>Alex</strong> joins too, with all the <strong>context</strong> already loaded from <strong>Slack thread</strong>. It carries everything from the channel into the call: the summary, the logs people mentioned, the hypotheses, the links.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-T2sUjjD_xLSwdXLq_S-YQ.png" /></figure><p>On the call, they line everything up:</p><p><strong>Support</strong> retells what the customer saw. They try to <strong>reproduce</strong> the bug again on a test workspace. Engineers <strong>check logs</strong> and metrics live as it happens. They tweak the scenario until they find the pattern.</p><p>Eventually, it clicks:</p><blockquote><em>“It only happens when the integration is reconnected while a background sync is running. When both overlap, some items get marked wrong and disappear from the board.”</em></blockquote><p><strong>They agree</strong> on what needs to change to fix it. Normally, this is where someone volunteers to “write the ticket later. Here, they don’t.</p><h3>3. “Hey Alex, Create a Ticket for Our Squad”</h3><p>When they’re ready to commit, someone just says:</p><blockquote><strong><em>James</em></strong><em>: “Hey </em><strong><em>Alex</em></strong><em>, create a ticket for our squad to fix this: items disappearing from the board after reconnecting integration X. Use everything from the Slack thread and this call — the exact conditions, what we think is causing it, and what we agreed to change.”<br></em><strong><em>Alex AI</em></strong><em>: “Sure! I’ll include everything from the slack thread that we initially discovered, plus the logs and information shared on this meeting. Sounds good?<br></em><strong><em>Team</em></strong><em>: “Yes!”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*U-zlPidokrx3ld_Jm9STpA.gif" /></figure><p>That’s it. Alex takes the task to the background so your team can move on with the conversation. No one needs to open Jira or Linear in the call.<br>No one stays after to reconstruct the conversation in ticket form.</p><p><strong>Alex</strong> has:</p><ul><li>The original support summary</li><li>The Slack discussion with logs, questions, and links</li><li>The live debugging call</li><li>The final understanding of the root cause and the plan</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQjBtUUsQr-RClQRDYWG9w.png" /></figure><p>On summary, <strong>Alex</strong> sends every single action item discussed, containing the whole conversation. When the squad later checks their board, the ticket is already there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GM0l_6zUeRFk4ao_NDqaCw.png" /></figure><ul><li>The <strong>title is specific</strong>, not vague.</li><li>The description tells the story in the team’s own language: what the customer saw, where it happens, under which conditions.</li><li>The steps to reproduce match what they actually did on the call.</li><li>The suspected cause and direction for the fix are written down.</li></ul><p>All from one line:</p><blockquote><em>“</em><strong><em>Hey</em></strong><em> </em><strong><em>Alex</em></strong><em>, create a ticket for our squad to solve the issue.”</em></blockquote><h3>Why This Matters</h3><p>The <strong>support agent</strong> doesn’t lose <strong>another 20–30 minutes</strong> writing a perfect bug report. They focus on understanding the customer and bringing a clear signal to the team.</p><p>Engineers don’t get <strong>a vague “integration broken” card.</strong><br>They get a ticket that reflects the real conversation and the real debugging session.</p><p>And as a team, you stop burning energy on the translation layer between:</p><blockquote>support → Slack → call → ticket.</blockquote><p><a href="http://www.blueprint2.me/"><strong>Alex</strong></a> doesn’t fix the bug for you. It makes sure that once you <em>do</em> <strong>understand</strong> the bug if you work on it a week after, getting it into a shape the squad can execute on is the easiest part.</p><p>Now, we do automate all the process of shipping features and bugs, using <a href="http://www.blueprint2.me/"><strong>Alex</strong></a>, Github, Cursor and Linear on a natural pipeline. If we get to <strong>100</strong> people interested in this, I’ll drop the secret sauce on how to setup this entirely, so if you are interested leave a comment down below that says “Full AI Automation” if you are interested in knowing more about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c7505b1536c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Alex Stays With Your Team From Idea to Action]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/how-alex-stays-with-your-team-from-idea-to-action-a8c8f16efe09?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8c8f16efe09</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[meetings]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 13:39:32 GMT</pubDate>
            <atom:updated>2025-11-17T13:42:51.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*GqkDFpGCSEO7z1ggFditEg.png" /><figcaption>Alex, from ideas to action</figcaption></figure><p>In the first story, I introduced <a href="http://www.blueprint2.me/"><strong>Alex</strong></a> as an <strong>AI coworker</strong> that lives where your team already works — in <strong>Slack</strong>, in your <strong>meetings</strong>, plugged into your project tools. A kind of <strong>Cursor for Project Managers</strong> that turns conversations into work.</p><p>Now let’s zoom into one specific loop:</p><blockquote><em>How </em><a href="http://www.blueprint2.me/"><strong><em>Alex</em></strong></a><em> stays with your team through a feature’s life cycle — <br>from the </em><strong><em>first idea</em></strong><em> in </em><strong><em>Slack</em></strong><em>,<br>to a </em><strong><em>user story</em></strong><em>,<br>to a broken-down </em><strong><em>set of tickets</em></strong><em> ready for engineering</em></blockquote><p>We’ll use a single example:<br><strong>“Next Step after onboarding”</strong> — helping new users know what to do right after setup.</p><h3>1. Idea in Slack → User Story</h3><p>It starts in #product , where most of your features are started. Someone posts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bp6VYmw0Scn_2VO0AmBc0Q.png" /><figcaption><em>“We’re seeing users complete onboarding, connect their first tool… and then stall. There’s no clear next step.”</em></figcaption></figure><p>Replies come in fast:</p><ul><li><strong>Customer Support</strong> drops a customer quote: “Okay, I did the setup… now what?”</li><li><strong>Designer</strong> shares a Loom of a session where the user just stares at the empty state.</li><li>An engineer links a chart showing drop-off right after the “integration connected” event.</li></ul><p><strong>Alex</strong> is already in <strong>that channel</strong>, quietly following the thread: who’s talking, what the problem is, which ideas are being thrown around.</p><p>Once there’s enough signal, I type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrf_nQ6W2r8a-tl94Rr5Xw.png" /><figcaption><strong><em>“@Alex AI</em></strong><em>, write a user story for this ‘</em>Next Step after onboarding<em>’ idea using everything we’ve just discussed in this thread.”</em></figcaption></figure><p><a href="http://www.blueprint2.me/"><strong>Alex</strong></a> pulls from the entire conversation and drafts a user story in our project tool that sounds like <em>us</em>, not like a generic template:</p><ul><li><strong>Problem:</strong> users finish onboarding and don’t know what to do next.</li><li><strong>Context:</strong> analytics, recordings, and quotes mentioned in the thread.</li><li><strong>Goal:</strong> guide new users to a meaningful first action.</li><li><strong>Initial ideas:</strong> a “first win” checklist, suggested actions, better empty state.</li></ul><p>We skim, tweak a sentence or two, and move on.</p><p>In a few seconds, “<strong><em>Slack noise</em></strong>” became a proper user story — without anyone opening a blank ticket and trying to reconstruct everything from memory or copy/paste.</p><h3>2. Planning Session → Tickets</h3><p>A few days later, we decide that this user story is in scope for the next cycle, so we set up a planning session with PM, design, and engineering — and we invite <strong>Alex </strong>as always<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTH3t32Osqfp0_Cm3-xibQ.png" /></figure><p>At the beginning of the call, I say:</p><blockquote><em>“Alright guys, we’re planning the ‘Next Step after onboarding’ user story Alex wrote not so long ago. Here are the details…”</em></blockquote><p><strong>Alex</strong> already knows which story we’re talking about, where it came from, and who’s in the room.</p><p>We <strong>agree</strong> that success means a new user taking at least one meaningful action after setup, not just connecting a tool and stopping there.<br>We talk about scope so it doesn’t balloon into a huge “onboarding 2.0” project.</p><p>As we go, the work naturally breaks down:</p><ul><li><strong>Backend</strong> needs a small change to provide recommended actions.</li><li><strong>Frontend</strong> needs a panel on the post-onboarding screen.</li><li><strong>Design</strong> needs to update the empty state and layout.</li><li>We want <strong>analytics</strong> events for the new flow.</li><li><strong>QA</strong> needs to cover how this behaves for new vs existing users.</li></ul><p>We are just <strong>talking</strong> like a normal team. We are not dictating tickets or filling out a form for Alex. It listens and tracks what sounds like separate pieces of work.</p><p>We <strong>don’t stop the meeting</strong> to open Linear or Jira and start typing.<br> We stay in the conversation.</p><p>When we’re done and everyone is happy with the plan, I hand it off:</p><blockquote><strong><em>Me</em></strong><em>: “Alex, create the tickets we just described for the ‘Next Step after onboarding’ story: backend, frontend, design, analytics, and QA. Use this discussion and the user story for the descriptions and basic acceptance criteria, and assign them to the right people.”<br></em><strong><em>Alex</em></strong><em>: “Got it. Will create 5 tickets to cover this work and add the link to the user story. Sounds good?”<br></em><strong><em>Me</em></strong><em>: “Go for it!”</em></blockquote><p>Then we end the call.</p><p><strong>No one stays behind</strong> to “do the tickets.”<br><strong>No one</strong> has to <strong>swap</strong> from the <strong>meeting</strong> to a <strong>board and play scribe.</strong></p><h3>Why This Matters for Product Teams</h3><p>This little loop changes more than it looks like:</p><ul><li><strong>Discovery</strong> doesn’t get lost <strong>between Slack and a ticket</strong>.</li><li><strong>Planning</strong> stays <strong>focused on decisions</strong>, not on typing into tools.</li><li>The story and the tickets stay connected instead of living in separate islands.</li><li><strong>PMs</strong> and leads <strong>stop </strong>acting as the <strong>human glue</strong> between conversations and the backlog.</li></ul><p><strong>Alex</strong> doesn’t replace anyone on the team.<br>It <strong>removes</strong> the drag between “<strong>we know what we want to do</strong>” and “it’s <strong>actually structured</strong> so we can <strong>build it</strong>.”</p><h3>What’s Next in the Series</h3><p>In the <a href="https://medium.com/@yansarorodriguezpaez/how-alex-turns-a-support-fire-drill-into-a-ready-to-work-ticket-2c7505b1536c">next story</a>, we’ll look at the same pattern from another angle:<br>how Alex joins support calls and turns what happens there into <strong>ready-to-work bug reports</strong>, without support agents spending another 20–30 minutes writing everything up by hand</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8c8f16efe09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet Alex: The AI Coworker That Turns Conversations Into Work]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/meet-alex-the-ai-coworker-that-turns-conversations-into-work-7978e2f48053?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/7978e2f48053</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[meetings]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 13:38:33 GMT</pubDate>
            <atom:updated>2025-11-17T13:43:19.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jlv-p9DI2s1bQA9icMy3gQ.png" /></figure><p><a href="http://www.blueprint2.me/"><strong>Alex</strong></a> is an AI coworker that lives where your team already works.<br> It <strong>plugs</strong> into your <strong>tools</strong>, <strong>joins</strong> your <strong>meetings</strong>, follows <strong>Slack</strong>, and turns <strong>conversations</strong> into <strong>tickets, tasks, </strong>and<strong> calendar</strong> moves — automatically. From the first message in a channel to the last minute of a call, <strong>Alex</strong> <strong>captures</strong> what’s decided and <strong>takes</strong> <strong>action</strong> in Jira, Linear, Azure DevOps, Google Calendar, and more, without anyone leaving the flow of work.</p><p>If ChatGPT is the assistant you visit in another tab, Alex is closer to <strong>Cursor for Project Managers</strong>: it sits inside your real workflow, sees the full context of the conversation, understands who said what and who owns what, and helps unblock work in real time — without you having to re-explain everything.</p><p>I’m Yan Rodriguez, co-founder of <a href="http://www.blueprint2.me/">Blueprint</a>, and this first story is a simple one: what <strong>Alex</strong> is, and what it can do for your <strong>team</strong>.</p><h3>AI Has Gotten Really Good — But Mostly for Individuals</h3><p>Over the past few years, AI has gotten <em>really</em> good at helping individuals:</p><ul><li>Developers get code suggestions and refactors in their editor.</li><li>Writers draft blog posts and emails in minutes instead of hours.</li><li>Knowledge workers ask questions in natural language and get decent answers back.</li><li>Busy people use AI to summarize articles, clean up notes, or rewrite messages.</li></ul><p>All of that is useful. But almost all of it is <strong>you + AI in a separate box</strong>.</p><p>Even when AI is “inside” tools — like a Copilot sidebar, or a “generate summary” button — it still feels like a personal assistant bolted onto a product. It helps <em>you</em> move faster, but it doesn’t really understand your <strong>team</strong>, your <strong>meetings</strong>, your <strong>tickets</strong>, or the messy, shared context where collaboration actually happens.</p><p>That gap is where <strong>Alex</strong> comes in.</p><h3>The Human Glue Problem</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F93-9vMEoPz18g9e" /><figcaption>Photo by <a href="https://unsplash.com/@scottsanker?utm_source=medium&amp;utm_medium=referral">Scott Sanker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The moment that pushed me to build <strong>Alex</strong> is one I’ve seen again and again.</p><p>A PM (or tech lead, or founder) runs a meeting:</p><ul><li>They <strong>keep track</strong> of the discussion.</li><li>They try to <strong>capture decisions, trade-offs, and edge cases</strong>.</li><li><strong>After the call</strong>, they still need to turn all of that into <strong>structured work</strong>.</li></ul><p>I’ve watched PMs do the “AI pipeline” dance:</p><ol><li>Use a <strong>meeting summarizer</strong> to get rough notes.</li><li><strong>Paste</strong> those notes into <strong>ChatGPT</strong> to turn them into tickets.</li><li><strong>Copy/paste </strong>that output into Linear or Jira.</li><li><strong>Tweak</strong>, reassign, fix missing context, add ACs, add links.</li></ol><p>On paper, this sounds not that bad. In reality, the human becomes the <strong>glue</strong> between a bunch of <strong>disconnected tools</strong>. It’s still a very <strong>time consuming</strong> process for PMs to reflect discussion into tickets.</p><p>You:<br>- lose the <strong>real-time moment. </strong><br>- Lose a ton of <strong>context</strong> as things hop between platforms.<br>- End up with tickets often <strong>feel generic</strong> — ACs that don’t quite match what was actually said in the meeting, missing constraints, missing edge cases.</p><p>It’s still <strong>manual</strong> project management. Now it just has fewer steps.</p><blockquote>I got tired of watching smart people act as manual integrations.I didn’t want the PM to be the glue. I wanted the AI to be the glue.</blockquote><h3>Alex: Cursor for Project Managers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qbHY8cXsGsSnfRTv" /><figcaption>Photo by <a href="https://unsplash.com/@getrodeo?utm_source=medium&amp;utm_medium=referral">Rodeo Project Management Software</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="http://www.blueprint2.me/"><strong>Alex</strong></a> is our answer to that problem.</p><p>Instead of being “another tab with an LLM,” <strong>Alex</strong> is a <strong>teammate</strong> that:</p><ul><li>Sits in your <strong>Slack</strong></li><li><strong>Joins</strong> your <strong>meetings</strong></li><li><strong>Talks</strong> to your project <strong>tools</strong> and <strong>calendar</strong></li><li>Understands who is who and who owns what</li><li><strong>Takes action</strong> when you ask it to</li></ul><p>The mental model I like is:</p><blockquote><strong><em>ChatGPT is an assistant you visit.<br>Cursor is a code assistant that lives where you work.<br>Alex is Cursor — but for project managers and teams.</em></strong></blockquote><p>Cursor understands your project through your code.<br>Alex understands your project through your <strong>conversations</strong> and your <strong>tools</strong>.</p><h3>What This First Story Is (and Where to Go Next)</h3><p>This is the first story of a series we prepared to explain how teams use Alex to get the most out of it. If you want to see how that actually plays out in practice, you can jump into the follow-up stories:</p><ul><li><strong>How product teams use Alex to leave meetings with a ready-to-build backlog</strong><br> → <a href="https://medium.com/@yansarorodriguezpaez/how-alex-stays-with-your-team-from-idea-to-action-a8c8f16efe09"><em>Read the product use case ›</em></a></li><li><strong>How support teams use Alex to turn support calls into ready-to-work bug reports</strong><br> → <a href="https://medium.com/@yansarorodriguezpaez/how-alex-turns-a-support-fire-drill-into-a-ready-to-work-ticket-2c7505b1536c"><em>Read the support use case ›</em></a></li></ul><p>If you’ve ever felt like you’re the one holding Slack, meetings, and Jira/Linear together by sheer effort —</p><p>Alex exists so you don’t have to be that glue anymore.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7978e2f48053" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart ‘const’ and the dilemma of the Equatable and 100% code coverage]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/dart-const-and-the-dilemma-of-the-equatable-and-100-code-coverage-44178d6c91cc?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/44178d6c91cc</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 19:41:10 GMT</pubDate>
            <atom:updated>2023-08-02T22:15:58.461Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MzZfGj-0kUUIlxuI" /><figcaption>Photo by <a href="https://unsplash.com/@siora18?utm_source=medium&amp;utm_medium=referral">Siora Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>100% code coverage is a “gold standard” in software development. Though not always feasible or necessary, its benefits are manifold. It offers quality assurance, ensuring more code is tested and verified, which enhances application reliability and decreases bugs in production. High coverage also aids maintainability, facilitating codebase changes and refactoring with confidence. Moreover, it serves as comprehensive documentation, outlining code functionality and usage. It helps mitigate risks by identifying edge cases and potential issues early on. And the list goes on and on.</p><p>Full test coverage can benefit any program, regardless of the language or framework used. However, as a Dart developer, I often find the pursuit of 100% coverage a bit “annoying”. Today, I want to delve into an specific issue that’s not often discussed: the interaction between const constructors and value equality in Dart using Equatable.</p><h3>Dart’s `const` constructors</h3><p>Dart’s const keyword allows you to create compile-time constants. When you declare a const variable, Dart will create in compile time some sort of table where is going to store all the consts used in the program. Every time you use a const in your code, Dart will create a ‘representation’ of it in the table and keep the reference to it. That ‘representation` is called the <em>canonicalization </em>of the object.</p><h4>Canonicalization</h4><p>Canonicalization can be seen as an injective function that converts a const member into a representation, based on its type and arguments. Consequently, two const members are considered equal if they share the same type and identical sets of arguments.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e31da60a4a5b2c8a6dcf30ef79b76e15/href">https://medium.com/media/e31da60a4a5b2c8a6dcf30ef79b76e15/href</a></iframe><p>While the exact process of Dart’s canonical representation differs from this one, this should provide a clear understanding of the underlying principle. In this case, a and b share the same canonical representation, while c possesses a distinct one. This differentiation translates into the following “canonicalization table”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*Icq5YJCjBc8wIKL8sylYCA.png" /></figure><p>With this, a and b are are in fact the exact same object, as they both point to the same reference. If we wouldn’t use the const constructor, Dart would instead create two distinct instances with two separate references, so even they do have the same arguments and type, they would be different objects due to Dart’s referential equality.</p><h3>Equatable package</h3><p>The <a href="https://pub.dev/packages/equatable">Equatable</a> package is a commonly used Dart package that assists developers in simplifying equality comparisons. By extending your class with Equatable, you can override the props method to implement value-based equality. This means that two instances will be considered equal if their props are the same, even if they are distinct instances in memory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c3016c7eb38246f794538efefb68f4d/href">https://medium.com/media/6c3016c7eb38246f794538efefb68f4d/href</a></iframe><p>Here, two MyClass objects with the same id will be considered equal, thanks to Equatable. To achieve this, the package overrides the == and the hashCode so, instead of comparing the references, will compare based on the given props.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f30603b7315ea30ced8f28964347e645/href">https://medium.com/media/f30603b7315ea30ced8f28964347e645/href</a></iframe><p>The identical function exposes whether two object references refer to the *same* object (i.e., share the same memory reference). So basically, twoEquatable instances are equal if they share the reference, or they are the same type and have the same props.</p><h3>Testing and Code Coverage</h3><p>When it comes to testing, particularly if you are using a package like coverage to measure your code coverage, you may find that the line containing the Equatable props isn’t covered when testing with const instances.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8b2a0fd0bfcfb579bff5b6b0bab9af7/href">https://medium.com/media/a8b2a0fd0bfcfb579bff5b6b0bab9af7/href</a></iframe><p>Since 2 consts will evaluate identical if they have the same arguments, the props comparison will never be executed. So, the override of Equatable will work, Dart will execute the override over the == method, but will stop when the identical returns true so the props line is never called. This ends up with the props line being not covered by the test, making impossible to achieve the 100% code coverage.</p><h3>Removing the const then</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cfoEp1Muc-rVwxmE" /><figcaption>Photo by <a href="https://unsplash.com/@jeshoots?utm_source=medium&amp;utm_medium=referral">JESHOOTS.COM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Well, do we really want the const? Testing value equality with const seems like super <a href="https://randycoulman.com/blog/2016/12/20/tautological-tests/">tautological</a>, since 2 consts are already equal if they have the same properties. Of course, you could use a subset of those properties to define equality, but thats not the case most of the time.</p><p>Ok, lets try to remove that const in the above test. Instantly you will receive a <em>prefer_const_constructors </em>warning, because the dart team don’t want you to do this 😢. Since the const constructor is super cool, why not using it, right? We are receiving this because the class has a const constructor and we decided to use the regular one, even tough we could have used the const because all dependencies are known in compiling time.</p><p>You could ignore the rule, and that will work, but seems kinda off. We shouldn’t need to ignore a good rule to achieve 100% code coverage. The coverage is a good metric, but also are the lint rules. I like to see the rules like a very strict mother. You probably don’t want to ignore your mother when she’s giving you advice. Same happens with the linter. I think that if you can avoid ignoring a rule, it’s less annoying.</p><p>The following trick is actually that. Is not more than a trick, but IMO think is more expressive than ignoring your “programmer strict mom”. Instead of creating objects calling directly the constructor (which will trigger the const constructor rule), we can create a new function that receives all the parameters of the constructor, and create an object with the given arguments.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef67d2a56c5aeaae492e128cf0b87c49/href">https://medium.com/media/ef67d2a56c5aeaae492e128cf0b87c49/href</a></iframe><p>Since the parameters are know received via function arguments, these are no longer compile-time-known, so the rule won’t show up, no need to use the const constructor (you actually can’t use it). a and b are no constants but regular instances, so even they are not identical (according to the identical function), they are equals.</p><h4>I know…this isn’t cool either 😒</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b6ORgqTVEbrCDiXN" /><figcaption>Photo by <a href="https://unsplash.com/@rutzsepp?utm_source=medium&amp;utm_medium=referral">Sepp Rutz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Yeah, honestly it’s not beautiful, but if you want to have compile time constants that work super cool and at the same time support value equality, then you will have to do something similar to this. I prefer the later cause ignoring lines is super tedious, and ignoring the entire file might be dangerous as there could be instances where you’d prefer the use of const. Also, I found it more expressive as the code explicitly communicates that it’s not a constant what you are instantiating.</p><p>While const and Equatable are powerful tools, their unique characteristics could lead to some coverage pitfalls. If you have another way of achieving the same, please share it on the comments. We (the community, but specially me included) would love to do this in a more elegant way.</p><p>Whichever trick you pick to dodge the problem, I hope that you’ve got a solid grip on why it’s happening now! If you like this type of stories consider subscribing. Happy coding, see ya! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44178d6c91cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving Domain with expressive errors]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/improving-domain-with-expressive-errors-293689f37393?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/293689f37393</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 08 Aug 2022 23:01:11 GMT</pubDate>
            <atom:updated>2022-08-10T22:35:29.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HfUZisrH6B9BlkLo" /><figcaption>Photo by <a href="https://unsplash.com/@lazycreekimages?utm_source=medium&amp;utm_medium=referral">Michael Dziedzic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve been doing Flutter apps for a while, and every time I show my friends an app made by me, the first thing they do is test it. It’s like: “Congrats dude, the app is great, look at this beautif… ups…there’s another bug”.<br>Shit happens, there’s no human way to completely avoid this, but as a software engineer, you are expected to minimize the “amount of shit” coming out of your app.</p><p>Small projects are usually more controllable and easier to debug =&gt; easier to maintain; but rule #1, all of this is temporary. There is no such a thing like “small projects”, they are just “newborns”, and as “newborns”, they don’t know the number of things they can do, but they will grow up …and as they grow up, you better be prepared for it or things will get really messy and you’ll finish with a huge uncontrollable boilerplate.</p><p>That’s when crashes and weird behaviors come in, manifestations of the unmaintainable code that most of the time, are caused by under-estimated or absent error handling. So, what’s the best way to handle errors? How can I build expressive code that minimizes the amount of crashes? Well, you can follow some patterns that can help you with that.</p><h3>Don’t throw exceptions</h3><p>It’s actually a little more complex than that. You should avoid throwing exceptions in your internal code, more known as your Domain layer. The main reason for this is that<strong> from a method’s type signature perspective,</strong> <strong>throwing exceptions is adding non-value.</strong></p><p>Let’s see an example of this using Dart language. Imagine we want to take the max-age number of a list of ages:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0518efd4dfb9a3d85ed4d811a12d326e/href">https://medium.com/media/0518efd4dfb9a3d85ed4d811a12d326e/href</a></iframe><p>Take a look at <strong><em>maxAge</em></strong> method. The <a href="https://en.wikipedia.org/wiki/Fold_%28higher-order_function%29"><strong><em>reduce function</em></strong></a> will throw an exception if the list is actually empty, so we want to provide a custom error to determine with a cool message in UI, that the list is empty. That’s why we create <strong><em>maxAgeAvoidEmpty</em></strong> function.</p><p>The problem is, that both two methods have the same signature. They both return a <strong><em>num</em></strong> and receive a <strong><em>Iterable&lt;num&gt;</em></strong>parameter, even knowing that <strong><em>maxAgeAvoidEmpty</em></strong> will throw an exception if <strong><em>ages</em></strong> is empty.</p><p>So, if you call each of these methods, you will only know in runtime, that something could actually break your code and return something different than the maximum of the ages. This is not cool, right?</p><p>There has to be a way to move the <strong>responsibility of handling the error to the caller</strong>, in a <strong>more secure</strong> way, but more important, in a <strong>more expressive</strong> way.</p><h3>Making the return type nullable</h3><p>A first approach could be to make the return type nullable, returning null if something wasn’t ok, in this case, if the ages list is empty. Let’s see the code using Dart:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eff63220616145c1bbff8e4997c730db/href">https://medium.com/media/eff63220616145c1bbff8e4997c730db/href</a></iframe><p>Now, the caller knows that <strong><em>maxAgeAvoidEmpty </em></strong>has 2 possibles return types, <strong><em>num OR null </em></strong>which gives the caller more control over what happened inside that method.</p><p>Despite this solution works for our specific use case, imagine that we want to return different types of errors, and as we’ve been doing, we want to propagate the error.</p><p>Now, returning <strong>null</strong> every time something goes wrong, doesn’t work, because it’s not providing enough information about what’s happening behind that. Actually, from a methods signature perspective, using null is considered an “anti-pattern” and you should avoid it if you want to make your code as expressive as possible.</p><p>Speaking at a software conference in 2009, <a href="https://en.wikipedia.org/wiki/Tony_Hoare#Quotations">Tony Hoare</a>, inventor of the <a href="https://en.wikipedia.org/wiki/Null_pointer">null reference</a>, apologized for inventing it:</p><blockquote><em>I call it my billion-dollar mistake. It was the invention of the null reference in 1965(…) But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.</em></blockquote><h3>All for one and one for all</h3><p>So, if not null, what then? Well, the following idea is actually pretty trivial, because it’s a very “human” thought. We have, a main type of return, which is the type expected if everything works properly; and a set of different possible errors. Let’s say we have expected return type <strong><em>TypeA </em></strong>and a set of errors which contains <strong><em>ErrorA, ErrorB, ErrorC ,</em></strong>…<strong>ErrorK</strong>.</p><p>What we really want is to somehow, be able to tell the compiler, that a method can return an instance of <strong><em>TypeA or ErrorA, ErrorB, ErrorC, …ErrorK</em></strong>. This concept is known as <a href="https://en.wikipedia.org/wiki/Union_type">Union Type</a> or Sum Type, and it comes built-in in some languages like TypeScript, but the main idea could be achieved in almost any language.</p><p>Unfortunately, Dart doesn’t provide a built-in way to Union types like TypeScript, but you can create your own Union Wrappers / Sealed classes or you can make use of <a href="https://pub.dev/packages/freezed">freezed package</a> by <a href="https://medium.com/u/c0530952c459">Remi Rousselet</a>. It’s important to notice that this package makes use of codegen, so we will focus only on the declaring part.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73b7756f4363ad0db5dbc6fe3e5158ad/href">https://medium.com/media/73b7756f4363ad0db5dbc6fe3e5158ad/href</a></iframe><p>Look at how expressive the above code becomes. Now, the caller is aware of different return types, because they are included in the method’s signature.</p><p>Union Type covers many use cases, not only proper methods signature. The problem is that “vanilla” Union Type isn’t enough in some cases, specifically when we truly want to propagate the error and make it a core part of our Domain.</p><h3>Either&lt;L,R&gt; as a “scalable” solution.</h3><p><a href="https://www.scala-lang.org/">Scala</a>, a very famous language for combining OOP and FP paradigms, resumes this in the <a href="https://www.scala-lang.org/api/2.13.6/scala/util/Either.html">Either class</a>. This is just a way of sealing the return type of the method, in a class that accepts any of these 2 types. Conventionally, the Left part of the Either, is used for the Failure, while the Right part, is used for the expected type in case everything goes properly.</p><p>So, yeah, this looks a lot like we did above, what’s the “scalability” of Either? Well, if you really want to understand the power of this, I suggest getting deeper inside <a href="https://en.wikipedia.org/wiki/Monad_%28functional_programming%29">Monads</a> and functional programming thingies, but let’s try to see why this is awesome and necessary.</p><p>Imagine we need to execute several tasks successfully or execute none of them if at least one fails. This is known in software engineering as <a href="https://docs.microsoft.com/en-us/dynamicsax-2012/developer/transaction-integrity">Transaction Integrity</a>, and it’s a very common problem. For example, let’s say that a Real State agency wants to register a transfer of a property from one user to another. You will want to absolutely give the property to the new owner and remove it from the older, or do nothing, otherwise, you could end up with both users with the same property, or both users without the property.</p><p>Let’s see how can we simulate this situation using <strong>Either </strong>from <a href="https://pub.dev/packages/fpdart">fpdart library</a>, a library for managing functional programming stuff in Dart language.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf3134e2bf976bbb64d84a7fef75d64/href">https://medium.com/media/7cf3134e2bf976bbb64d84a7fef75d64/href</a></iframe><p>Let’s explain what we are doing first. There are some shortcuts at the top of the file made for demonstration purposes to avoid verbosity. This includes the typedefs and the usecases functions. We are assuming that all of these usecases are previously provided. Then we are creating two lists, the <strong><em>operationsToDo </em></strong>which contains the main tasks of the procedure, and <strong><em>transactionRollback</em></strong>, which contains the rollbacks functions of each completed task previously executed in case some task fails.</p><p><strong>Eithers</strong> and <strong>Monads</strong>, in general, become very handy in this situation because we can <strong>combine the results</strong> of different tasks in an expressive way. Notice that the “magic” comes at the end of the file, where we chain the operations by “reducing” the list with the <strong>call</strong> function and then folding the result to rollback the procedure or not depending on the results.</p><p>We could implement this feature more expressively, using a <a href="https://index.scala-lang.org/channingwalton/transaction-monad">Transaction Monad</a> instead of a <strong>TaskEither, </strong>which is just like Either, with functions to run depending on the success of the transaction. Unfortunately, I don’t know if this feature is implemented yet in fpdart library (or don’t how to use it, hehe), but if you want to see this in an ideal way, leave me a comment and I will edit this story using or creating the Transaction Monad and implementing this feature with it.</p><h3>When to “either” use Either or throw?</h3><p>Well, if you ask a FP enthusiast they will tell you that Either/Option/Monads are the best thing ever and they could even get physical if you don’t agree. Yeah, some people can get intense 😂😂😂.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0Iy87qFTu0gDegw0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0Iy87qFTu0gDegw0%2Fgiphy.gif%3Fcid%3Decf05e47xpu3ksidbpohlrey6nsiqr6v5e4o43vsjw5w4kj0%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl0Iy87qFTu0gDegw0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="240" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a6214d8fce2fd7983a3aa0e74e75af8/href">https://medium.com/media/1a6214d8fce2fd7983a3aa0e74e75af8/href</a></iframe><p>The truth is Eithers and Monads, in general, are better suited for almost every situation. If we compare it to unchecked exceptions becomes even bigger the necessity of it, but it’s going to depend a lot on the dev community of your language. Read your language guidelines first before you start making open source code using Eithers. And if your dev community language has adopted it, don’t hesitate on using it.</p><p>If it’s not very well adopted, like in Dart, at least don’t use it in the most externals layers of your code. Instead, use it only in your Domain Layer, where your business logic is happening.</p><p>Handle failure in Domain, then throw an Exception depending on the failure ocurred and everybody wins 😁. Hope you had a good time reading my story. If you want more content like this, please leave me a follow.</p><p>Have a good one !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=293689f37393" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hablemos de abstracciones]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/hablemos-de-abstracciones-afac77285dbe?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/afac77285dbe</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 16 Aug 2021 23:09:32 GMT</pubDate>
            <atom:updated>2021-08-17T16:11:05.744Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUqsJmJ4XpCr7cRNce0jmg.jpeg" /></figure><p>Las abstracciones han estado en el radar de la humanidad desde sus inicios. Cuando eres ingeniero de software, seguro tienes un montón de amigos que tienen una idea “brillante” pero no saben como ejecutarla o al menos no tienen claro que pasos seguir para desarrollarla. Tienen un concepto, una caja negra, la cual recibe una entrada, que en este caso sería el problema, y una salida, que en este caso sería la solución deseada. Esta idea es un ejemplo común de una abstracción. No se necesita saber cómo ejecutar la idea, solo se necesita tener claro que problema resuelve y que tipo de solución devuelve. Tener bien clara una abstracción es primordial si queremos poder implementarla satisfactoriamente.</p><p>Cuando el objeto de estudio es sencillo, casi siempre las abstracciones vienen junto a las implementaciones, pero al ganar complejidad, los humanos de manera prácticamente inherente decidimos particionar nuestra problemática en problemas más pequeños y asignarles recursos para sus soluciones, ya que un solo recurso no es capaz de solucionar cada uno de estos problemas. De esta manera, se genera un grafo en el cual cada uno de sus nodos constituye una tarea asignada a ciertos recursos y las aristas constituyen una relación de comunicación entre las dos tareas (nodos) en la cual se establecen los contratos de comunicación entre estos.</p><p>Sean las tareas X y Y, dos nodos de nuestro grafo, donde existe una arista que va de X a Y. El recurso asignado a X no debe poder conocer que es lo que hace Y con el objeto entregado porque debe estar enfocado totalmente en poder ejecutar bien su tarea. En su lugar, X solo debería conocer como hacerle llegar a Y la información para que sea procesada. Esto posibilita que si en algún momento sustituimos el recurso asignado a Y, el flujo no se sienta afectado en absoluto.</p><p>Resulta evidente la importancia de las abstracciones en sistemas complejos para la humanidad en general. Es imprescindible definir buenos contratos para la comunicación de tareas, y mientras mejor se definan estos, menos susceptible será nuestro sistema a cambios. La idea de este artículo es hablar sobre algunas prácticas en cuanto a la definición de abstracciones en el campo de la programación, dándoles mi opinión personal acerca de cada una de ellas. Para ello nos apoyaremos en Dart como lenguaje por la popularidad de Flutter para el desarrollo de aplicaciones móviles cross-platform.</p><h3>Definamos una problemática de ejemplo</h3><p>Para ver como aplicar correctamente abstracciones, definamos un problema primero. Digamos que vamos a implementar el apartado “Mi Perfil” de una aplicación. Tenemos tres funcionalidades principales. Obtener la información relacionada con mi perfil, editar distintos aspectos de mi perfil y eliminar mi perfil. Veamos cada uno de los casos de uso en código:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb06aaadf90ebccb1030f9c33ce46751/href">https://medium.com/media/fb06aaadf90ebccb1030f9c33ce46751/href</a></iframe><p>En el código anterior, podemos ver tres clases las cuales extienden <strong><em>UseCase&lt;Type, Params&gt;</em></strong>, una clase para ayudarnos a la compresión del código, en la cual <strong><em>Type</em></strong> refiere el tipo de retorno en caso de éxito y <strong><em>Params</em></strong> el tipo de parámetros a recibir. El tipo <strong><em>Failure</em></strong> es una clase abstracta para manejar errores en nuestro software de manera segura. También hacemos uso del paquete dartz para programación funcional (basado en <a href="https://www.scala-lang.org/">Scala</a>) el cual es bastante genial. Si no has visto Either, Unit, Optional o las distintas funcionalidades que provee dartz puedes echarle un vistazo <a href="https://pub.dev/packages/dartz">aqu</a>í. Cada uno de estos <strong><em>UseCase</em></strong> se separan, por supuesto, en archivos diferentes ya que son funcionalidades totalmente separadas.</p><p>Por propósitos demostracionales no vamos a hacer nada en estos <strong><em>UseCase</em></strong>, solo vamos a llamar al <strong><em>repository</em></strong> y que este se encargue de procesar la data correspondiente. Por supuesto, como estaríamos dependiendo de una clase, primero deberíamos crear una abstracción que nos permita olvidarnos de cómo se procesa esta información. En Dart no existen interfaces explícitas, sino que cada clase define una interfaz implícita, la cual puede ser implementada por cualquier otra clase.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4adabdf5b525c8278e06432724394fc3/href">https://medium.com/media/4adabdf5b525c8278e06432724394fc3/href</a></iframe><p>Veamos ahora la implementación de esta interfaz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f289b58d383fa2c187bb9c40390bd19c/href">https://medium.com/media/f289b58d383fa2c187bb9c40390bd19c/href</a></iframe><h4>Analizando la solución anterior</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*8oq5kDxiXiqaPFBTVhFiaA.gif" /></figure><p>La solución anterior, a pesar de ofrecer cierta abstracción a los <strong><em>UseCase</em></strong>, no está correcta, y es alarmante ya que es una de las más vistas en tutoriales y artículos. El problema aquí es que, a pesar de brindar abstracción sobre la implementación a los <strong><em>UseCase</em></strong>, brinda demasiada información a estos que realmente no necesitan y que en realidad atenta contra la seguridad de nuestro código. Por ejemplo, desde el <strong><em>UseCase</em></strong> <strong><em>GetProfile</em></strong> no hay ninguna regla que impida acceder al repositorio y eliminar mi perfil a través del método <strong><em>deleteProfile</em></strong>. Lo mismo sucede con los otros ejemplos. Esto es una violación clara del <a href="https://es.wikipedia.org/wiki/Principio_de_segregaci%C3%B3n_de_la_interfaz">Principio de segregación de la interfaz</a> establecido en el <a href="https://es.wikipedia.org/wiki/SOLID">S.O.L.I.D</a>.</p><p>¿Qué tiene esto de malo? Bueno, principalmente provoca una brecha de seguridad considerable. Deberían existir reglas que impidan este tipo de acciones para evitar comportamientos indebidos de nuestro software. Por otro lado, a medida que va creciendo el proyecto se irán agregando funcionalidades al repositorio. Esto significa que por cada funcionalidad nueva, hay que agregar un(os) método(s) en la clase contrato del repositorio. Estas nuevas funcionalidades no alteran el comportamiento(en la vida real) de las ya establecidas previamente, así que tampoco se debería modificar su abstracción de la implementación porque en lo que a él concierne, nada ha cambiado. La solución a esto es lo que se conoce como Stable Abstractions. Veamos como crear Stable Abstractions para el ejemplo de estudio.</p><h3>Stable Abstractions</h3><p>Regresemos al código del contrato de nuestro <strong><em>ProfileRepository</em></strong>. Veamos ahora cómo solucionar este problema creando nuevos contratos y eliminando el anterior:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d00079b3813fd32af05964e570206190/href">https://medium.com/media/d00079b3813fd32af05964e570206190/href</a></iframe><p>La idea con las Stable Abstractions es evitar la volatilidad de cada una de nuestras interfaces. Si una interfaz se ve modificada, debe ser solamente porque las capas que dependen de ella así lo desean. Veamos ahora la implementación de los <strong><em>UseCase</em></strong> con este cambio.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8664609c3c4849ffa02173bbb2afa3f6/href">https://medium.com/media/8664609c3c4849ffa02173bbb2afa3f6/href</a></iframe><p>Podemos ver un código mucho menos volátil de las abstracciones. No existe forma de acceder a ninguna funcionalidad ajena al contexto de cada uno de los <strong><em>UseCase</em></strong> porque cada una de las abstracciones fue diseñada para proveer solo lo necesario y al unísono, abstraernos de los funcionamientos de la implementación. Puede que en este ejemplo no podamos apreciar el alcance que tiene crear buenas abstracciones, pero cuando nos enfrentemos a proyectos de gran envergadura, sabremos apreciar sus bondades.</p><p>Por último veamos como queda la clase <strong><em>ProfileRepositoryImpl</em></strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd31b04426e348c8688ff4009c1dd894/href">https://medium.com/media/dd31b04426e348c8688ff4009c1dd894/href</a></iframe><h3>Otra solución un poco más “funcional”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*N-EJTbqT99AHqFrL1j8nhw.gif" /></figure><p>La solución anterior a pesar de ser correcta, realmente cuando el proyecto gana en volumen, deriva en un montón de interfaces las cuales llevan tiempo, y a pesar de que podemos utilizar técnicas para reducir nuestro código, la solución a continación ayuda muchísimo en cuanto a la cantidad de código y, al menos en mi opinión, resulta en abstracciones más fuertes y aún menos volátiles que la anterior.</p><p>En la actualidad, son muchos los lenguajes que gozan de un enfoque multiparadigma. Dart es uno de ellos, en el cual las funciones son consideradas ciudadanos de primera clase. Si no conoces sobre estos temas recomiendo leer primero <a href="https://www.campusmvp.es/recursos/post/programacion-funcional-funciones-de-primera-clase-y-de-orden-superior.aspx">este artículo</a>, en el cual explican los conceptos necesarios.</p><p>Al Dart soportar funciones como ciudadanos de primera clase, esto significa que pueden ser tratadas como cualquier otro objeto del lenguaje permitiendo asignaciones a variables y pasarlas como parámetros en funciones (técnicamente llamado función de orden superior), en especial para nuestro ejemplo, al constructor de una clase. Veamos el código anterior como quedaría si en vez de usar interfaces, usáramos funciones.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/deaa895f76acaecd26e25a55b8a70419/href">https://medium.com/media/deaa895f76acaecd26e25a55b8a70419/href</a></iframe><p>Todo el contrato de nuestros <strong><em>UseCase</em></strong> ahora esta definido dentro de la propia clase. No podría cambiar nada en la implementación que repercuta en ella sin su consentimento, ya que ella es quien dictamina las reglas de su construcción y el contrato que deben cumplir sus dependencias.</p><h4>Ventajas de este enfoque</h4><p>Una de las principales ventajas con respecto al enfoque anterior es la reducción de código. Ya no tendríamos que definir un contrato por cada dependencia, ya que el contrato se encuentra implícito en el constructor de la clase. Esto puede ser ventajoso, sobre todo cuando no solo dependemos de funcionalidades alojadas en un objeto, sino que dependemos de funcionalidades alojadas en múltiples objetos.</p><p>Otra ventaja es que a pesar de que en tiempo de compilación dependamos de la interfaz, en tiempo de ejecución siempre estaríamos dependiendo de la implementación del repositorio en su totalidad, manteniendo igual acceso a cada una de los funcionalidades no deseadas, mientras que en este solamente tenemos acceso a las funciones pasadas en el constructor incluso en tiempo de ejecución.</p><p>Por último, un aspecto a analizar es qué tan susceptible a cambios es esta solución. Y aquí es donde no todo es color de rosa. Resulta extremadamente fácil cambiar la implementación específica de una función, tanto que podemos hasta cometer un error grave.</p><p>Al construir una instancia de los <strong><em>UseCase</em></strong> anteriores, solo necesitamos proveer una función la cual reciba los mismos argumentos que la deseada y retorne el mismo tipo. Esto obviamente no es algo exactamente malo, ya que otorga mayores libertades al programador, pero puede tener repercusiones severas en caso de no tener mucho cuidado. Veamos como inyectar estas dependencias:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e904cc9edc1ad5cafa45b05bd67ed1a8/href">https://medium.com/media/e904cc9edc1ad5cafa45b05bd67ed1a8/href</a></iframe><p>Nótese que no es necesario pasar una función concreta definida en el <strong><em>repository</em></strong> . Podemos usar una función anónima y desde ella acceder a los recursos que sean necesarios. De esta forma la clausura de la función estaría proveyendo toda la información necesaria para el contexto en el que se ejecutaría la función. De igual manera, si hay cambios sensibles en la salida o en los argumentos de la función, podemos mapear (siempre que sea posible) nuestros antiguos argumentos/salidas a los necesitados por la nueva implementación sin necesidad de cambiar la abstracción.</p><h3>Dejando las abstracciones y volviendo a la realidad</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*o98RouDXZ4fk-JRJ3C7-Fg.gif" /><figcaption>Bye bye</figcaption></figure><p>Hay veces que la mejor solución para un problema no es ni herencia, composición, mixins o estructuras de datos complejas. Hay veces que la mejor solución es solamente una simple función.</p><p>Quizás la definición de las abstracciones es uno de esos casos, quizás no. De cualquier forma, espero que hayan aprendido al menos un poco y la hayan pasado bien. Si les gustó, no escatimen en los aplausos 😁. Si quieren conversar sobre algún otro tema, dejénmelo en los comentarios. ¡Que tengan una buena semana!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afac77285dbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s talk about abstractions]]></title>
            <link>https://medium.com/@yansarorodriguezpaez/lets-talk-about-abstractions-af744a273680?source=rss-9570cbf63864------2</link>
            <guid isPermaLink="false">https://medium.com/p/af744a273680</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[yarn_rp]]></dc:creator>
            <pubDate>Mon, 16 Aug 2021 23:09:30 GMT</pubDate>
            <atom:updated>2021-08-17T16:14:27.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUqsJmJ4XpCr7cRNce0jmg.jpeg" /></figure><p>Abstractions has been present in humanity since the beginning of times. When you are a software engineer, surely have some friends who came with a “brilliant” idea but they don’t know how to make it work or at least is not clear. They have a concept, an object which receives an input, in this case the problem to solve, and returns an output, which in this case is the desired solution. This is a naive example of abstractions. You don’t need to know how to develop the idea, you just need to be clear about which problem solves and what would be the final result. Having a very clear abstraction is essential if we want to be able to implement it successfully.</p><p>When the problem is simple, abstractions almost always come together with implementations, but as we gain complexity, humans in an almost inherent way decide to partition our problems into smaller problems and assign them assets for their solutions, since a single assets is not capable of solving each of these problems. Behind that, a graph is generated in which each of its nodes constitutes a task assigned to certain assets and the edges are a communication relationship between the two tasks (nodes) in which the communication contracts between them are established.</p><p>Let the tasks X and Y be two nodes of our graph, where there is an edge that goes from X to Y. The asset assigned to X must not be able to know what Y is doing with the delivered input because it must be totally focused performing its task. Instead, X should only know how to pass the input properly formatted to Y. This makes possible that, if at some point we substitute the assets assigned to Y, the flow will be not affected at all.</p><p>The abstractions relevance in complex systems for humanity in general is evident. It is essential to define good contracts for the tasks communication, and the better these are defined, the less susceptible to changes our system will be . The idea of ​​this article is to talk about some practices in the programming abstractions definitions, giving you my personal opinion about each one of them. We will rely on Dart as a language due to the popularity of Flutter for the development of cross-platform mobile applications.</p><h3>Let’s define a problem first</h3><p>To see how to apply abstractions correctly, let’s define a problem first. Let’s say we are going to implement the “My Profile” section of an application. We have three main functionalities. Obtain the information related to my profile, edit different aspects of my profile and delete my profile. Let’s look at each of the use cases in code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb06aaadf90ebccb1030f9c33ce46751/href">https://medium.com/media/fb06aaadf90ebccb1030f9c33ce46751/href</a></iframe><p>In the above code, we can see three classes which extend <strong><em>UseCase &lt;Type, Params&gt;</em></strong>, a class to help the understanding code in which <strong><em>Type</em></strong> refers return type on success and <strong><em>Params</em></strong> ,type parameters to receive . The <strong><em>Failure</em></strong> type is an abstract class for handling errors in our software in a safe way. We also make use of the dartz package for functional programming (based on Scala) which is pretty cool. If you haven’t seen Either, Unit, Optional or the different functionalities that dartz provides you can take a look <a href="https://pub.dev/packages/dartz">here</a>. Each of these <strong><em>UseCases</em></strong> are of course separated into different files as they are totally separate functionalities.</p><p>For demonstration purposes we are not going to do anything in these <strong><em>UseCases</em></strong>, we are just going to call the repository and let it take care of processing the corresponding data. Of course, since we would be depending on a class, we should first create an abstraction that allows us to forget about how this information is processed. In Dart there are no explicit interfaces, but each class defines an implicit interface, which can be implemented by any other class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4adabdf5b525c8278e06432724394fc3/href">https://medium.com/media/4adabdf5b525c8278e06432724394fc3/href</a></iframe><p>Now let’s see the implementation of this interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f289b58d383fa2c187bb9c40390bd19c/href">https://medium.com/media/f289b58d383fa2c187bb9c40390bd19c/href</a></iframe><h4>Analizing this solution</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*8oq5kDxiXiqaPFBTVhFiaA.gif" /></figure><p>The previous solution, despite offering some abstraction to the <strong><em>UseCase</em></strong>, is not correct, and it is surprising since it is one of the most seen in tutorials and articles. The problem here is that, despite providing implementation abstraction to the <strong><em>UseCase</em></strong>, it provides too much information to them that they don’t really need and that actually threatens the security of our code. For example, from the <strong><em>UseCase GetProfile</em></strong> there is no rule to prevents accessing the repository and deleting my profile through the <strong><em>deleteProfile</em></strong> method. The same happens with the other examples. This is a clear violation of the <a href="https://en.wikipedia.org/wiki/Interface_segregation_principle">Interface segregation principle</a> established in the <a href="https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">S.O.L.I.D</a>.</p><p>What’s wrong with this? Well, it mainly causes a considerable security breach. There should be rules that prevent this type of actions to avoid improper behavior of our software. On the other hand, as the project grows, functionalities will be added to the repository. This means that for each new functionality, a method (s) must be added in the contract class of the repository. These new functionalities do not alter the behavior (in real life) of those already established previously, so neither should their abstraction of the implementation be modified because as far as he is concerned, nothing has changed. The solution to this is what is known as Stable Abstractions. Let’s see how to create Stable Abstractions for this example.</p><h3>Stable Abstractions</h3><p>Let’s go back to the contract of our <strong><em>ProfileRepository</em></strong>. Let’s see now how to solve this problem by creating new contracts and deleting the old one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d00079b3813fd32af05964e570206190/href">https://medium.com/media/d00079b3813fd32af05964e570206190/href</a></iframe><p>The idea with Stable Abstractions is to avoid the volatility of each of our interfaces. If an interface is modified, it must be only because that’s the desire of the layers that depend on it. Let’s now look at the <strong><em>UseCases</em></strong> implementation with this change.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8664609c3c4849ffa02173bbb2afa3f6/href">https://medium.com/media/8664609c3c4849ffa02173bbb2afa3f6/href</a></iframe><p>We can see much less volatile code for abstractions. There is no way to access any functionality outside the context of each of the <strong><em>UseCase</em></strong> because each of the abstractions were designed to provide only what is necessary and at the same time, abstract from the implementation. In this example we may not be able to appreciate the scope of creating good abstractions, but when we face huge projects, we will appreciate their benefits.</p><p>Finally, let’s see how the <strong><em>ProfileRepositoryImpl</em></strong> class looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd31b04426e348c8688ff4009c1dd894/href">https://medium.com/media/dd31b04426e348c8688ff4009c1dd894/href</a></iframe><h3>Another solution a little bit more “functional”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*N-EJTbqT99AHqFrL1j8nhw.gif" /></figure><p>The previous solution despite being correct, when the project gains in volume, it results in a lot of interfaces which take time, and although we can use techniques to reduce our the amount of code, the following solution helps a lot and, in my opinion at least, it results in stronger and even less volatile abstractions than above.</p><p>Today, many languages have a multi-paradigm approach. Dart is one of them, in which functions are considered first-class citizens. If you don’t know about these topics, I highly recommend reading <a href="https://www.developintelligence.com/blog/2016/10/javascript-functions-as-first-class-objects/">this article</a> first, in which they explain the necessary concepts.</p><p>As Dart supports functions as first-class citizens, this means that they can be treated like any other object in the language by allowing assignments to variables and passing them as parameters in functions (technically called a higher-order function), especially for our example, to the constructor of one class. Let’s see the previous code as it would look if instead of using interfaces, we used functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/deaa895f76acaecd26e25a55b8a70419/href">https://medium.com/media/deaa895f76acaecd26e25a55b8a70419/href</a></iframe><p>All our <strong><em>UseCase</em></strong> contracts are now defined within the class itself. We could not change anything in the implementation that affects it without its consent, since it’s the one who dictates the rules of its construction and the contract that its dependencies must accomplish.</p><h4>Advantages of this approach</h4><p>One of the main advantages over the previous approach is the code reduction. We would no longer have to define a contract for each dependency, since the contract is implicit in the class constructor. This is great, especially when we not only depend on functionalities stored in one object, but we also depend on functionalities stored in multiple objects.</p><p>Another advantage is that despite the fact that at compilation time we depend on the interface, at runtime we would always be depending on the implementation of the entirely repository , maintaining equal access to each of the unwanted functionalities, while in this only we have access to the functions passed in the constructor even at runtime.</p><p>Finally, one aspect to analyze is how susceptible to changes this solution is. It is extremely easy to change the specific implementation of a function, so much so that we can even make a serious mistake. When constructing an instance of the previous <strong><em>UseCases</em></strong>, we only need to provide a function which receives the same arguments as the desired one and returns the same type. This is obviously not exactly a bad thing, as it gives the programmer full freedom, but it can have severe repercussions if you are not very careful. Let’s see how to inject this functions inside <strong><em>UseCases.</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e904cc9edc1ad5cafa45b05bd67ed1a8/href">https://medium.com/media/e904cc9edc1ad5cafa45b05bd67ed1a8/href</a></iframe><p>Note that it is not necessary to inject a specific function defined in the repository. We can use an anonymous function and from it access the necessary resources. In this way, the closure of the function would be providing all the necessary information for the context in which the function would be executed. Similarly, if there are sensible changes in the output or in the arguments of the function, we can map (whenever possible) our old arguments / outputs to those needed by the new implementation without needing to change the abstraction.</p><h3>Back to reality</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*o98RouDXZ4fk-JRJ3C7-Fg.gif" /><figcaption>Bye bye</figcaption></figure><p>Sometimes the best solution to a problem is not inheritance, composition, mixins, or complex data structures. Sometimes the best solution is just a simple function.</p><p>Perhaps the definition of abstractions is one of those cases, perhaps not. Either way, I hope you have learned at least a little and had a good time. If you liked it, don’t skimp on the applause 😁 . If you want to talk about something else, leave it in the comments. Have a good week!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af744a273680" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>