<?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 Derek Novak on Medium]]></title>
        <description><![CDATA[Stories by Derek Novak on Medium]]></description>
        <link>https://medium.com/@derek.novak1?source=rss-9294ddbf1197------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CZ6yCMHm2hHAdUQYk-2KxA@2x.jpeg</url>
            <title>Stories by Derek Novak on Medium</title>
            <link>https://medium.com/@derek.novak1?source=rss-9294ddbf1197------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 15:23:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@derek.novak1/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[I Failed an Interview Assessment So You Don’t Have To]]></title>
            <link>https://medium.com/@derek.novak1/i-failed-an-interview-assessment-so-you-dont-have-to-50bfbfef0dd8?source=rss-9294ddbf1197------2</link>
            <guid isPermaLink="false">https://medium.com/p/50bfbfef0dd8</guid>
            <category><![CDATA[launch-school]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Derek Novak]]></dc:creator>
            <pubDate>Sat, 19 Oct 2024 22:19:28 GMT</pubDate>
            <atom:updated>2024-10-21T13:29:12.265Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>From a “Not Yet” to an A+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i33Az9TnEkBiHe5W207Aqg@2x.jpeg" /><figcaption>Photo by Francisco De Legarreta C. on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It finally happened. After 12 consecutive passes, I received my first “Not Yet” on a Launch School assessment, that being the LS216 interview assessment. And you know what?</p><p>It sucks.</p><p>Before the interview, I had solved over 100 coding challenges, attended 3 SPOT sessions, studied with multiple students one-on-one, and had a solid plan of attack. I knew how to seek out edge cases and solved the majority of problems well within the required timeframe. By all accounts, I was ready. So, what happened?</p><p>In this article, I will go over the mistakes I made that ultimately led to a “Not Yet” and how I rectified them in my retake. While this happened for the LS216 interview, what I will discuss is relevant to any kind of technical assessment.</p><p>Here we go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cHJ_cJM9hw2s8sFMlgyDg@2x.jpeg" /><figcaption>Photo by <a href="https://abgeknipst.de/">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Follow Your Plan</h3><blockquote>“OK — I can see what’s going on here, so I don’t need to break down the test cases.”</blockquote><p>Before going into the interview, you have undoubtably solved countless coding challenges and have since developed a thorough system of approaching a problem. This may include how you read through the problem, the order you develop your PEDAC, or even the way you organize your notes. Regardless of how you structure this process: stick to it, especially when the problem takes you in a seemingly different direction.</p><p>By maintaining this methodology, you are working within your normal problem-solving flow, something that has been tried-and-true every other time you’ve implemented it. Any deviations, while small, can quickly throw off your game-plan and begin the early stages of spiraling away from what you’ve practiced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBGJby6qYLBxXSd1QTNeHg@2x.jpeg" /><figcaption>Photo by Nathan Dumlao on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Remain Patient</h3><blockquote>“I don’t quite know what I want to do yet, but let’s keep moving on and see if it comes to me while I work through the Algorithm.”</blockquote><p>With the pressure of time, you may feel compelled to rush through your PEDAC. After all, you only have X amount of time to solve the problem and you want to reserve as much time as possible to debug or address any issues that arise… right?</p><p>Wrong.</p><p>In every interview assessment I’ve taken, time has never worked against me. In fact, I had a legitimate panic attack in my LS216 retake that halted my performance for nearly 15 minutes, yet I was still able to solve the problem within the timeframe because I did not rush forward.</p><p>What <em>does</em> work against you is rushing through your PED, not having a clear idea of what you want to do, then hack-and-slash your Algorithm or Code hoping an epiphany will come along the way. This was what ultimately led to my failed first attempt.</p><p>But what if you <em>do</em> go over time? Is that an automatic failure?</p><p>Wrong again.</p><p>Assuming you went through every step of your PEDAC fully, communicated well, and showcased a thoughtful approach, time will not be your undoing. Many people have gone over time and still passed for this very reason. With that said, if you are taking an hour to solve a 30 minute problem, there is more than likely something important within your process that needs adjustment. But using 5, even 10 minutes to really think through a specific step? That will not break you, and in many cases, will greatly speed up later steps in your process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qb1gIFBsSctogzaXcscdQg@2x.jpeg" /><figcaption>Photo by <a href="https://khalfalli.com/">Yassine Khalfalli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Revisit the Question Thoroughly</h3><p><em>“Let’s quickly read through the question again and see if I’m missing anything.”</em></p><p>When studying for any exam, would you simply read through the lesson material once and jump straight into the assessment? Seems insane, right? So, why would you do this <em>during</em> the test?</p><p>The first time you read your given problem, it’s exactly that: <strong>the first time</strong>. Maybe you had an inkling of what to expect, but you have never seen it before. Yes, you probably understand the general essence of the question, but there are more than likely some hidden gems within it that may aid in your success in solving the problem. What should you do, then?</p><p>Revisit the prompt.</p><p>I found the best time to do this to be after analyzing the test cases provided or that I had made. At this point, I have had enough time to sit with the problem, play around with it a bit, and ruminate on potential solutions. Now, I can reread the question and pick apart every aspect of it.</p><p>What I‘ve learned is that most questions hide huge hints within the description to help you solve the problem. Think of it like <strong>buzzwords </strong>to discover.</p><blockquote>“Create a function that finds the string in a list of elements that contains a double-letter substring.”</blockquote><p>Just from this simple problem alone, we can parse a ton of information.</p><ul><li><strong>string — </strong>the returned value should be a string</li><li><strong>list</strong> — the main data structure is an array</li><li><strong>elements</strong> — we are likely dealing with multiple data types in the array</li><li><strong>substring</strong> — using a substring-generating helper function makes for a great approach</li><li><strong>double</strong> — our substring function can make groups of 2 letters</li><li><strong>finds</strong> — using a find method will make it easy to iterate through the array and return a specific value based upon a condition.</li></ul><p>While you may have been able to gauge some of these buzzwords upon your first viewing, a second look will absolutely expose them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxYZV9G-dSKY_3EC15-BMA@2x.jpeg" /><figcaption>Photo by <a href="https://www.instagram.com/maxwbender/">Max Bender</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>You’re Not Being Tricked</h3><p>If you find yourself lost in a convoluted Algorithm with crazy nesting that hinge on numerous random variables to keep the code somewhat working, you’ve likely drastically deviated from the problem’s intended solution. These interviews are<em> no</em>t designed to be tricky, but instead assess your fundamental ability to solve a technical coding problem. So what, then, should you do if you’ve found yourself here?</p><p>Burn it.</p><p>I’m not being facetious. At this point, you’re throwing bandages on a bad algorithm that will only become worse. Instead, now that you have deeply engaged with the problem, think about what other approaches might exist from a clean slate.</p><p>I’ve known others who, after reaching this point 30 minutes into their PEDA, decided to start from scratch and solved the problem 5 minutes later. The leap of faith can feel scary, but it is much better than continuing to beat a dead Algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otlA68j8UhlSgOUCsEEbNA@2x.jpeg" /><figcaption>Photo by <a href="http://jeshoots.com/">JESHOOTS.COM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Mistakes Happen</h3><p>The beauty of the Launch School curriculum is your ability to grow from mistakes. A “Not Yet” is not the end of the world, nor does it determine your success as a Software Engineer. This simply means that some aspect of your understanding or methodology needs to be tweaked, and there are countless resources to nudge you in the right direction.</p><p>For my LS216 “Not Yet”, I was unable to solve all test cases due to an incredibly convoluted Algorithm and a misunderstanding of the problem. Had I simply reread the problem description, I would have easily recognized my oversight and quickly formed a solution. When studying for the retake, I knew I had the technical ability to solve coding problems, so I focused instead on strengthening my PED.</p><p>These are the lessons that I learned throughout this experience, and led to me flipping a “Not Yet” into an A+. I share them with you now so that you can avoid making the same silly mistakes as me.</p><p>Keep up the great work, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50bfbfef0dd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polymorphism and its Many Forms]]></title>
            <link>https://medium.com/@derek.novak1/polymorphism-and-its-many-forms-87bd8fd3d0ae?source=rss-9294ddbf1197------2</link>
            <guid isPermaLink="false">https://medium.com/p/87bd8fd3d0ae</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Derek Novak]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 23:22:23 GMT</pubDate>
            <atom:updated>2024-03-10T05:07:25.565Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“Polymorphism is the ability for different types of data to respond to a common interface.” — Launch School</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4c5VBiRPo3yAe0C7" /><figcaption>Photo by <a href="https://unsplash.com/@nixcreative?utm_source=medium&amp;utm_medium=referral">Tyler Nix</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>An important concept that is learned within Object Oriented Programming is <strong>polymorphism</strong>. Polymorphism, at its core, allows for less repetitive code within a program and provides software developers a means to group classes together that exhibit similar behaviors.</p><p>The idea of it is fairly simple — multiple objects have the ability to respond to the same method call — but it can start to become confusing once you investigate the various ways it’s included in a program. In this article, I will outline three different forms of polymorphism that are used specifically within the Ruby programming language and how to implement them into your codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9WufoGNT5nS9AzQ5" /><figcaption>Photo by <a href="https://unsplash.com/@benjaminmanley?utm_source=medium&amp;utm_medium=referral">Benjamin Manley</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Polymorphism via Inheritance</h3><p>Inheritance, as the name suggests, occurs when one object inherits from another. In regards to Ruby, we are referring to a class inheriting behaviors (methods) from an additional source, that being either modules or another class. While similar in their execution, polymorphism via class inheritance versus interface inheritance are best utilized in different scenarios.</p><h4>Class Inheritance</h4><p>Polymorphism via <strong>class inheritance</strong> occurs when all subclasses of a parent-class share a common behavior; rather than defining the behavior in every subclass, it can be defined in the parent-class, allowing each subclass to inherit it.</p><pre>class Human<br>  def sleep<br>    puts &quot;I&#39;m sleeping!&quot;<br>  end<br>end<br><br>class Adult &lt; Human; end<br>class Child &lt; Human; end<br>class Baby &lt; Human; end<br><br>[Adult.new, Child.new, Baby.new].each(&amp;:sleep)<br><br># I&#39;m sleeping!<br># I&#39;m sleeping!<br># I&#39;m sleeping!</pre><p>In this example, the Adult, Child, and Baby classes all share a sleep instance method. Rather than define the method in each class, we can define it in their shared parent-class Human, allowing each class to inherit it.</p><p>What if we included a more specific implementation for the Adult class?</p><pre>class Adult &lt; Human<br>  def sleep<br>    puts “I’m snoring!”<br>  end<br>end</pre><p>Although Adult has a unique output, it is still considered polymorphism via class inheritance due to its inheritance of the default definition from the Human class, as well as the fact that all other subclasses share the sleep behavior.</p><p>This is great and all, but what occurs when not all of the subclasses share this behavior?</p><h4>Interface Inheritance</h4><p>Polymorphism via <strong>interface inheritance</strong> occurs when multiple, <strong><em>but not all</em></strong>, subclasses of a parent-class share a common behavior. Not all of the classes can exhibit the behavior, therefore it should not be defined in the parent-class. Instead, these behaviors can be extracted to a module and included into the necessary classes as a <strong>mixin</strong>.</p><pre>module Runable<br>  def run<br>    puts &quot;I&#39;m running!&quot;<br>  end<br>end<br><br>class Human; end<br><br>class Adult &lt; Human<br>  include Runable<br>end<br><br>class Child &lt; Human<br>  include Runable<br>end<br><br>class Baby &lt; Human; end<br><br>[Adult.new, Child.new, Baby.new].each(&amp;:run)<br><br># I&#39;m running!<br># I&#39;m running!<br># undefined method `run&#39; for #&lt;Baby:0x000000010f832fb0&gt; (NoMethodError)</pre><p>In this example, we’ve introduced a new run instance method. While both our Adult and Child classes have the ability to run, it’s fair to assume that a Baby does not. With this in mind, the method should not be defined in our Human parent-class, as all 3 classes would then inherit it. We could define the method into each appropriate class, but that would become repetitive, particularly if we added a bunch of new subclasses such as Teenager or Elder.</p><p>Instead, the run instance method can be extracted to a module and included as a mixin. This allows the behavior to be included in the requisite classes without becoming overly repetitive. While run only includes a single line of code, other instance methods may contain much more complexity which could quickly crowd a program.</p><p>What if just a single subclass contains a behavior? Should we extract this to a module and call it interface inheritance?</p><pre>class Adult<br>  def pay_taxes<br>    puts “That time of the year again?”<br>  end<br>end</pre><p>The answer is no. Because <em>only</em> the Adult class can pay_taxes, it makes more sense just to define it in its class. If, however, we implemented another class into the program that can pay_taxes as well, <em>then </em>we can extract the method to a module and include the mixin.</p><p>While Polymorphism via Inheritance deals exclusively with <strong>related</strong> classes, there will be times where objects of <strong>unrelated</strong> classes also need to be grouped together. For this, we shift to…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y5-nELrJ5EK4MlR1" /><figcaption>Photo by <a href="https://unsplash.com/@jasonthedesigner?utm_source=medium&amp;utm_medium=referral">Jason Richard</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Duck Typing</h3><p>Duck typing, coined from the phrase “if it walks and quacks like a duck, then it must be a duck” occurs when multiple <em>unrelated</em> objects share a common behavior and can therefore be grouped together. In other words, objects instantiated from classes that have an instance method with the same name can be assembled to perform a specific task, executing their unique implementation of the method.</p><p>Imagine we are designing a program to help maintain a fast-food restaurant. In preparation for the day, the various machines throughout the restaurant first need to be refilled. Rather than invoking a refill method on these objects individually, they can grouped together as a sort of “morning routine”.</p><pre>class CashRegister<br>  def refill<br>    @money = 300<br>  end<br>end<br><br>class SodaMachine<br>  def refill<br>    @pepsi = 100<br>    @sprite = 100<br>  end<br>end<br><br># Morning routine<br>[CashRegister.new, SodaMachine.new].each(&amp;:refill)</pre><p>As you can see, there is <em>intention</em> behind the Duck Typing. While different classes can certainly contain instance methods of the same name, it’s not considered Duck Typing unless they are purposely called simultaneously.</p><p>Let’s now imagine that a waiter for this restaurant is tasked to refill one of the customer’s drinks throughout their shift.</p><pre>class Drink<br>  def refill<br>    @fill = 100<br>  end<br>end</pre><p>While this instance method is named the same, is unrelated to both CashRegister and SodaMachine, and is even included within the same program, it would not be considered Duck Typing. Unless we find a reason to pair this behavior with any of the others, there is no need to classify them as the same ‘duck’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x-PE_oziCSuMK2lB" /><figcaption>Photo by <a href="https://unsplash.com/@vladsargu?utm_source=medium&amp;utm_medium=referral">Vlad Sargu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Which Polymorphism is Being Used?</h3><p>While understanding each form of Polymorphism does not pose too much challenge, trying to create your own ideal examples or determine which form is being utilized may be muddy. The good news is that it’s as easy as following a few simple rules.</p><ol><li>Class Inheritance</li></ol><ul><li>All classes are related by a common parent-class</li><li>All subclasses share a common method</li></ul><p>2. Interface Inheritance</p><ul><li>All classes are related by a common parent-class</li><li>Multiple, <strong>but not all</strong>, subclasses share a common method</li></ul><p>3. Duck Typing</p><ul><li>The classes do not share a common parent-class</li><li>The classes share a common method</li><li>There is intention to group objects of the classes together.</li></ul><p>Your programs will most likely incorporate many variations each form of polymorphism — that’s great! It’s a sign that you’re being intentional with the code you write and have created an efficient codebase.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87bd8fd3d0ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret to a Strong PEDAC Algorithm]]></title>
            <link>https://medium.com/@derek.novak1/the-secret-to-a-strong-pedac-algorithm-7c0988f5c9be?source=rss-9294ddbf1197------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c0988f5c9be</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Derek Novak]]></dc:creator>
            <pubDate>Tue, 06 Feb 2024 00:59:40 GMT</pubDate>
            <atom:updated>2024-02-06T13:54:09.683Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“A goal without a plan is just a wish.” -Antoine de Saint-Exupéry</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EBjODteJE5H8rPNh" /><figcaption>Photo by <a href="https://unsplash.com/@stevep4?utm_source=medium&amp;utm_medium=referral">Stephen Monroe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Forming a strong PEDAC is an essential skill for all Programmers, as it provides a tool for breaking down, understanding, and systematically solving basic code problems. PEDAC is an acronym for the following:</p><ul><li>(Understand the) <strong>P</strong>roblem</li><li><strong>E</strong>xamples/Test Cases</li><li><strong>D</strong>ata Structure</li><li><strong>A</strong>lgorithm</li><li><strong>C</strong>ode</li></ul><p>In most cases, the first 3 steps are fairly straight-forward. It’s that fourth step — Algorithm — that can be tricky to construct, with it being the precursor to your coded solution. That said, a strong Algorithm is <em>essential</em> to having a seamless coding experience. This article is devoted exclusively to the Algorithm.</p><p>Let’s get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sPIUldK_E9p0cfoJ" /><figcaption>Photo by <a href="https://unsplash.com/@chasefade?utm_source=medium&amp;utm_medium=referral">Chase Fade</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Algorithm RAP</h3><p>Master your PEDAC skills in a SNAP by learning the Algorithm RAP — <strong>Requirements</strong>,<strong> Approach</strong>,<strong> Procedure </strong>— a 3-part implementation of steps in creating the Algorithm outline.</p><ol><li><strong>Requirement</strong> — The important, generalized steps required to navigate from the input to the desired output.</li><li><strong>Approach</strong> — The process that will be utilized to accomplish each Requirement.</li><li><strong>Procedure</strong> — Specific details to implement the Approach.</li></ol><p>Steps should be formed in sequence and are ordered from most to least important. A Procedure cannot be implemented until an Approach is decided, which cannot be determined unless the Requirement is understood.</p><pre>ALGORITHM<br><br>- Requirement 1<br>  - Approach<br>    - Procedure<br>- Requirement 2<br>  - Approach<br>    - Procedure<br>- Requirement 3<br>  - Approach<br>    - Procedure</pre><p>Let’s explore each one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*en8TGVVmM-OLTO5A" /><figcaption>Photo by <a href="https://unsplash.com/@benobro?utm_source=medium&amp;utm_medium=referral">ben o&#39;bro</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Requirement</h3><p>When breaking a problem into its required steps, keeping the Requirement as general as possible is vital, as it allows for multiple Approaches to exist in forming a solution. Each step should serve a single purpose, as you can always refactor the code later.</p><h4>Buzzwords</h4><p>When deciding on descriptions for the Requirements, utilize a list of common verbs — <em>Buzzwords </em>— to help formulate each step.</p><ul><li><strong>CREATE</strong> — Create an array of substrings</li><li><strong>SELECT</strong> — Select only the elements that are letters</li><li><strong>REMOVE </strong>— Remove all vowels from the string</li><li><strong>TRANSFORM</strong> — Transform the string to all uppercase</li><li><strong>SORT</strong> — Sort the array from largest to smallest</li><li><strong>FIND</strong> — Find the element that contains a special character</li><li><strong>RETURN</strong> — Return largest integer in the array</li><li><strong>OUTPUT</strong> — Output each element to the console</li><li><strong>COUNT</strong> — Count the number of lowercase letters</li></ul><p>Notice that each Buzzword is general in its operation, not alluding to any specific method/function or mechanism.</p><p>There are also words to avoid, as to prevent a premature Approach from evolving.</p><ul><li><strong>LOOP</strong> — locks you into a looping mechanism</li><li><strong>ITERATE</strong> — locks you into an iterative method</li><li><strong>INITIALIZE</strong> — locks you into using a separate variable</li><li><strong>PUSH</strong> — locks you into initializing a variable</li></ul><p>These words hint at using language specific methods/functions, and should be avoided until the deciding on an Approach.</p><p>While the Buzzwords list is not exhaustive, it encompasses a variety of words that can be used throughout the Requirement phase.</p><h4>Single Purpose</h4><p>Each Requirement should serve a single purpose, even when implementation of multiple steps is fairly simple. This prevents locking yourself into a solution that may not work out in the end.</p><p>Take this simple example, which returns the size of the joined elements.</p><pre>Input:   [&#39;abc&#39;, &#39;def&#39;, &#39;ghi&#39;] <br>Output:  9 </pre><p>How might the Requirements be indicated?</p><pre>BAD<br><br>- Join the elements together as a string and return its size<br>size</pre><pre>GOOD<br><br>- TRANSFORM array into a string with elements joined<br>- RETURN the size of the string</pre><p>While we are taking extra steps here that may seem unnecessary, this allows the Algorithm to remain flexible. For example, what if a new condition was discovered that required removing the vowels before counting? Let’s see how this changes the Algorithm.</p><pre>BAD<br><br>- Join the elements together as a string and return its size<br>  with vowels removed</pre><pre>GOOD<br><br>- TRANSFORM array into a string with elements joined<br>- SELECT only the characters that are not vowels<br>- RETURN the size of the string</pre><p>Trying to implement changes to the “BAD” Algorithm made the explanation more confusing, while the “GOOD” Algorithm was easy to adjust and retained clarity.</p><p>The Requirements are easily the most important aspect of creating a strong Algorithm, as its framework allows for flexibility while remaining solid in construction. If the Algorithm were a Roadmap, the Requirements are the large cities that you pass through on your trip: you can take detours, but arriving at these locations are essential to a smooth trip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kPSPwD6T4aNZNHca" /><figcaption>Photo by <a href="https://unsplash.com/@ed259?utm_source=medium&amp;utm_medium=referral">Ed 259</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Approach</h3><p>Once every Requirement has been established, you can begin to decide which kind of Approach you will use to construct a solution. While this step is a bit more in-depth, specific implementation details must remain undecided. In most cases, the Approach decides which data structure will be used and whether a looping or iterative method will be utilized.</p><p>Let’s take one of our previous Requirements:</p><pre>- SELECT only the characters that are not vowels</pre><p>Because the input is a string, there are a few things we know need to happen here.</p><ul><li>The string needs to be converted into an array</li><li>The array needs to remove all vowels</li><li>The array needs to be rejoined</li></ul><p>…and there is your Approach! While more specific, it does not include any implementation details. Let’s add it to the Algorithm.</p><pre>- SELECT only the characters that are not vowels<br>  - Convert the string to an array<br>  - Iterate through characters, returning only elements that are not vowels<br>  - Rejoin the array</pre><p>What if this Approach does not seem to work, or that you don’t know how to “convert the string to an array”? Change it! Because the Requirement has been established, we know what <em>has</em> to occur, so simply adjust the Approach.</p><pre>- SELECT only the characters that are not vowels<br>  - Initialize a new string<br>  - Iterate through each character, pushing only characters that are<br>    not vowels to the new string</pre><p>Flexibility is the key that allows our Approach to come together. Using the previous Roadmap metaphor, the Approach are the roads taken throughout the trip. You know which cities you are aiming to reach, but the roads you take are up to you. If there are closures or accidents that block your path, simply choose a different road.</p><p>Once each Approach has been determined, it’s finally time to add in the final details: the Procedure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_oI5QE1Alg7Xl2ag" /><figcaption>Photo by <a href="https://unsplash.com/@jerrykavan?utm_source=medium&amp;utm_medium=referral">Jaromír Kavan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Procedure</h3><p>Unlike the Requirement and Approach, the Procedure is much more detailed and language specific. Here, you can make decisions based upon your current Algorithm that will solidify a plan for coding the solution.</p><p>The Procedure can be applied in a few different ways:</p><ul><li>Naming variables</li><li>Specifics on implementation details, such as counters or parameters</li><li>Potential methods/functions that could be used</li></ul><p>The intent of the procedure is to clear up any gaps in your Approach before coding begins.</p><p>Let’s use our SELECT example one last time:</p><pre>- Initialize a new string</pre><p>Here, we can name the variable ‘consonants’, as it will reference all the characters except the vowels from the string.</p><pre>- Iterate through each character, pushing only characters that are<br>  not vowels to the new string</pre><p>How do we determine what is not a vowel? Maybe we can use an array of all the vowels, and only push values that are not included? Regular Expression is also an option. Choose whichever method you’re most comfortable!</p><pre>- SELECT only the characters that are not vowels<br>  - Initialize a new string<br>    - ‘consonants’<br>  - Iterate through each character, pushing only characters that are<br>    not vowels to the new string<br>    - If not included in [a, e, i, o, u], push to ’consonants’</pre><p>To conclude our Roadmap metaphor, the Procedures include everything else. What kind of car do you drive? How fast is the speed-limit? How do you even drive a car? You obviously can still properly operate a vehicle with this knowledge, but without the Requirement or Approach, you’re simply driving around aimlessly.</p><p>…and that’s a RAP!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0B6nLNXl9rYchtR-" /><figcaption>Photo by <a href="https://unsplash.com/@dinoreichmuth?utm_source=medium&amp;utm_medium=referral">Dino Reichmuth</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Walk-Through Problem</h3><p>Let’s solve a real, complex problem using the Algorithm RAP.</p><pre>Given a string, write a method/function which returns the number of <br>characters present in the largest palindrome substring. Palindromes are<br>case-insensitive and are at least 2 characters long. If no palindromes<br>are present, return -1.<br><br><br>&quot;supertacocat&quot;  =&gt; 7<br>&quot;MomAndDad&quot;     =&gt; 3<br>&quot;Palindrome&quot;    =&gt; -1</pre><p>Here is the PED:</p><pre>Input: A string<br>Output: An integer, representing the size of the largest palindrome<br>        substring<br><br>Rules:<br>- Palindromes<br>  - Same forwards/backwards<br>  - Case-insensitive<br>  - At least 2 characters in length<br>- If there are no palindromes, return -1<br><br>Example<br>- supertacocat<br>  - coc<br>  - acoca<br>  - tacocat =&gt; longest, 7 characters long<br><br>Data Structure<br>- An array for all of the substrings</pre><p>Using the Algorithm RAP, we first need to determine the Requirements of the problem. Here is what we know:</p><ul><li>We need to find all palindrome substrings</li><li>Of these substrings, we need to determine the longest</li><li>The expected return is an integer, so we need to return the substring’s size</li><li>If there are no palindrome substrings, we need to return -1</li></ul><p>Great! Now we can decide on which Buzzwords are most appropriate.</p><pre>- CREATE an array of all possible substrings<br>- SELECT only the substrings that are palindromes<br>- TRANSFORM each substring to its size value<br>- RETURN -1 if substrings is empty<br>- RETURN the largest number in substrings</pre><p>These are my Requirements, but yours may look a bit different. As long as you are using the single-purpose Buzzwords, you’re on the right track.</p><p>For each Requirement, we can now decide on a practical Approach.</p><pre>- CREATE an array of all possible substrings</pre><p>This is the most challenging step, so let’s break it down:</p><ul><li>We need to iterate throughout each character</li><li>For each character, we need to capture all substrings from the current character to the end of the string</li><li>To house all of the substrings, we need to initialize an array</li></ul><p>Let’s add this Approach to our Requirement.</p><pre>- CREATE an array of all possible substrings<br>  - Initialize an array for substrings<br>  - Iterate through each character<br>  - For each character, push all substrings to the array</pre><p>Now that we have a solid plan, we can begin to implement our Procedure and fill in the remaining gaps of the Algorithm, such as:</p><ul><li>What should we name this new array?</li><li>How do we push every substring for each character to the array?</li><li>How do we account for the change in length of the string after each character iteration?</li></ul><p>This is where language specific knowledge is necessary, as it will dictate which tools you have at your disposal. The good news is that, because our Requirement and Approach is solid, multiple Procedure options become available.</p><p>Here is my solution:</p><ul><li>Name the array ‘substrings’</li><li>Use a looping mechanism, and increment the range of the string by 1 each loop.</li><li>Because the string size will decrease with each character, we need the maximum range of characters to decrement by 1 after each character</li></ul><pre>- CREATE an array of all possible substrings<br>  - Initialize an array for substrings<br>    - ‘substrings’<br>  - Iterate through each character<br>    - use ’times’ method, using each iteration as the starting index<br>  - For each character, push all substrings to the array<br>    - Use ‘upto’ method, using each iteration as the range of characters<br>    - Decrement the maximum range by 1 each iteration</pre><p>Awesome! This is a solid plan for the first Requirement, which is the most challenging part of the problem.</p><p>Try forming the Approach and Procedure for the remaining Requirements.</p><p>Below is my Algorithm:</p><pre>- CREATE an array of all possible substrings<br>  - Initialize an array for substrings<br>    - &#39;substrings&#39;<br>  - Iterate through each character<br>    - use &#39;times&#39; method, using iteration as the starting index<br>  - For each character, push all substrings to the array<br>    - Use &#39;upto&#39; method, using iteration as the range of characters<br>    - Decrement the maximum range by 1 each iteration<br>- SELECT only the substrings that are palindromes<br>  - Must follow these conditions<br>    - Same forward/backward, case-insensitive<br>    - More than 1 character in length<br>- TRANSFORM each substring to its size value<br>  - Iterate through each substring, transforming each to its size value<br>- RETURN -1 if substrings is empty<br>  - Check if ’substrings’ is empty<br>- RETURN the largest number in substrings<br>  - use ’max’ method</pre><p>And, for my fellow Rubyists, the coded solution:</p><pre>def longest_palindrome(str)<br>  # CREATE  <br>  substrings = []<br>  max_range = str.size<br><br>  str.size.times do |start_idx|<br>    1.upto(max_range) do |range|<br>      substrings &lt;&lt; str[start_idx, range]<br>    end<br><br>    max_range -= 1<br>  end<br>  <br>  # SELECT<br>  substrings.select! do |substr|<br>    (substr.downcase == substr.downcase.reverse) &amp;&amp; (substr.size &gt; 1)<br>  end<br>  <br>  # TRANSFORM<br>  substrings.map!(&amp;:size)<br><br>  # RETURN<br>  substrings.empty? ? -1 : substrings.max<br>end</pre><p>Notice how, even with the code, the 4 Requirements are sectioned. If any adjustments are needed, by either a bug or added functionality, implementation will be easy.</p><h3>Summary</h3><p>The Algorithm RAP, similar to PEDAC, breaks down each element of the Algorithm to allow for a clearer and more systematic way to solve the given problem. As we have learned:</p><ul><li>Each Requirement should serve a single purpose, moving step-by-step from input to output</li><li>Buzzwords are common verbs that aid in developing the problem’s Requirements</li><li>The Approach creates a plan for solving the Requirement without involving language-specific details</li><li>The Procedure fills any gaps left over in the Algorithm.</li></ul><p>Like anything, practice makes perfect — don’t expect to develop a perfect Algorithm overnight. That being said, breaking the Algorithm down to these steps is a powerful tool that will take your PEDAC to the next level.</p><p>Now, go out and impress your colleagues with your new RAP skills!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c0988f5c9be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Speaking like a Ruby Programmer]]></title>
            <link>https://medium.com/@derek.novak1/the-art-of-speaking-like-a-ruby-programmer-cfc321bf3157?source=rss-9294ddbf1197------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfc321bf3157</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Derek Novak]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 23:37:03 GMT</pubDate>
            <atom:updated>2024-01-16T19:12:23.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hPljyHHKis-wYx2t" /><figcaption>Photo by <a href="https://unsplash.com/@mimithian?utm_source=medium&amp;utm_medium=referral">Mimi Thian</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>After hours of personal study and hundreds of practice code-snippets, you feel confident in solving nearly any example thrown your way. You meet up with a group of people, ready to showcase your newly acquired skillset, are presented with the first problem and…….</p><p>Blank.</p><p>You know the solution. You know what will be returned, what will print, even a great way to refactor the code. But explaining it out loud? That would just be a mess.</p><p>We’ve all been there.</p><p>While it would be wonderful to simply code all day as a software developer, the reality is that both technical writing and speaking are mandatory to be successful. In this article, I will discuss my approach in learning to speak like a Ruby Programmer, outlining some basic terminology and rules, as well as best practices for providing succinct explanations of code-snippets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1qEQKXgilbPPqjh0" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>General Terminology</h3><p>The first place to start becoming comfortable in reading code is to develop a firm grasp on basic terminology. A strong foundation on vocabulary will not only showcase an understanding of core Ruby principles, but will also aid in the later steps. While this medium article will outline a few frequently used terms, most vocabulary will be learned through Ruby documentation and self-study.</p><h4>Variable initialization vs reassignment</h4><p>The first instance in which a variable is assigned a value, that variable gets ‘initialized’. Any following assignment will be considered a ‘reassignment’.</p><pre>a = &#39;Hello World!&#39;<br>b = a<br>a = &#39;Goodbye!&#39;</pre><blockquote>On line one, local variable a is <strong>initialized</strong> and references the string object &#39;Hello World!&#39;. On line 2, local variable b is <strong>initialized</strong> and references the same object as a. On line 3, a is <strong>reassigned</strong> to the string object &#39;Goodbye!&#39;.</blockquote><h4>Method invocation</h4><p>A method is called on an object when it appears after the object, usually (but not always) prepended by a dot.</p><pre>&#39;hello world!&#39;.upcase</pre><blockquote>The upcase method <strong>is called</strong> on the string object &#39;hello world!&#39;.</blockquote><p>An object gets passed into a method invocation when the object appears after the method, usually (but not always) delimited by parentheses.</p><pre>puts(&#39;hello world!&#39;)</pre><blockquote>The puts method <strong>is invoked</strong> and gets passed the string object &#39;hello world!&#39; as an argument.</blockquote><h4>Arguments vs parameters</h4><p>Arguments are objects that get passed into a method, only appearing at the method invocation. Parameters are placeholder variables that allow the arguments to be used within the method.</p><pre>def say(string)<br>  puts string<br>end<br><br>say(&#39;hello&#39;)</pre><blockquote>The say method is invoked and gets passed the string object &#39;hello&#39; as an <strong>argument</strong>, which is then bound to the method’s <strong>parameter</strong> string.</blockquote><h4>Return vs output</h4><p>A method will always return a value, but may not always output one. An outputted value gets printed to the console.</p><pre>puts [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;].pop</pre><blockquote>The pop method is called on the array object [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;], which removes and <strong>returns</strong> the last element &#39;c&#39;. &#39;c’ is then passed as an argument to the puts method, <strong>outputting</strong> it to the console.</blockquote><h4>True vs truthy</h4><p>Say it with me: “Everything in Ruby evaluates as true, except for false and nil.” You’ve probably heard this 100 times — it’s a core principle! With that in mind, an important distinction to understand is that everything <strong><em>evaluates </em></strong>as true, and not that everything <strong><em>is</em></strong> true.</p><pre>if 5 &gt; 1<br>  puts &#39;5 is greater than 1&#39;<br>end</pre><blockquote>Because 5 &gt; 1 <strong>evaluates as true</strong>, the string object 5 is greater than 1 is output.</blockquote><p>While it seems like we’re splitting hairs, making this distinction will avoid confusion. Only the boolean object true is true.</p><p>While this is not an exhaustive list, it provides a few important distinctions that must be understood in order to move forward. There is plenty of other terminology to learn, with the best source of appropriate language being within the Ruby Documentation, linked below.</p><p><a href="https://ruby-doc.org/">Ruby-Doc.org</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O5Y-bh_UtKPW2ITf" /><figcaption>Photo by <a href="https://unsplash.com/@tingeyinjurylawfirm?utm_source=medium&amp;utm_medium=referral">Tingey Injury Law Firm</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Basic Rules</h3><p>With a firm grasp on terminology, it’s helpful to understand a few basic rules when describing code. Each point is geared to improve your presentation.</p><h4>Say it once</h4><p>Once you establish what an object is or what a method does, there is no need to explain it again.</p><pre>a = 1<br>a = 2</pre><blockquote>On line 1, local variable <em>a</em> is initialized and references an integer object with the value <em>1</em>. On line 2, a is reassigned to 2.</blockquote><p>The first sentence shows a clear understanding of:</p><ol><li>The type of variable that a represents.</li><li>The type of object that 1 represents.</li></ol><p>Because the audience is already aware that you understand these elements of the code, there is no need to repeat them when referencing the data. Repeating yourself will both slow you down and remove clarity in your explanation.</p><h4>Everything in the code requires markdown</h4><p>If it exists in the code snippet, markdown should be used. Along with this, the object should appear in the exact same syntax (i.e. a string should appear as a string).</p><pre>str = &#39;hello world!&#39;</pre><blockquote>On line 1, local variable <em>str</em> is initialized and references a string object with the value <em>&#39;hello world!&#39;</em>.</blockquote><h4>When in doubt, more is better</h4><p>Although we’re trying to make you into a succinct developer, sometimes it’s unclear whether your description provides too much information. When there is a doubt, it’s best to have more information than not enough, as you could potentially omit an important detail. Just be wary of providing too much information, as extra details that are incorrect could do more harm than good.</p><p>Now that you are well-equipped with the basic terminology and rules, it’s time to put them into practice with some real code-snippets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RoW7OeKUYutTvkx9" /><figcaption>Photo by <a href="https://unsplash.com/@jack_anstey?utm_source=medium&amp;utm_medium=referral">Jack Anstey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Reading Flow</h3><p>Learning to read Ruby code with a proper sense of flow will not only help you sound proficient, but will also provide a tremendous aid in debugging. When presented with a long list of code, it may seem daunting to know where to start or the order in which to read everything. The good news is that it’s fairly straight-forward.</p><h4>You are the interpreter</h4><p>Just like your computer is the interpreter for your code, so to are you when reading through it. After all, you are deciphering a series of instructions, focusing on what gets returned and what is output. In a similar fashion to your computer, you follow this written path until the isolated program concludes.</p><p>Ruby will always start at the top of the program, moving line-by-line throughout it. We will approach it in the same manner.</p><p>Let’s use an example.</p><pre>number = 5<br><br>if number &gt; 0<br>  puts &#39;This is a positive integer.&#39;<br>end</pre><p>First, how would your computer process this code?</p><ol><li>number references 5.</li><li>if condition checks truthiness of number &gt; 0.</li><li>Because 5 &gt; 0 evaluates as true, puts is invoked.</li><li>&#39;This is a positive integer.&#39; gets passed as an argument to puts.</li><li>This is a positive integer. is output to the console.</li></ol><p>Now, simply turn these steps into your own words, using the language included in the previous sections.</p><blockquote>On line 1, local variable number is initialized and references the integer object 5. On line 3, an if statement is employed, which checks the truthiness of number &gt; 0. Because this evaluates as true, the puts method is invoked and gets passed &#39;This is a positive integer.&#39; as an argument, outputting it to the console.</blockquote><p>This is a perfectly acceptable and very precise explanation of the above code.</p><p>Let’s do one more, with some added complexity.</p><pre>def add_5(number)<br>  number + 5<br>end<br><br>a = 5<br>p add_5(a)</pre><p>Again, computer first:</p><ol><li>The add_5 method is defined.</li><li>a references 5.</li><li>add_5 method is invoked.</li><li>a gets passed as an argument to the add_5 method invocation.</li><li>The value of a gets bound to the method’s parameter number.</li><li>The + method is called on number.</li><li>5 is passed as an argument to the + method.</li><li>The + method executes and returns the integer 10.</li><li>Because this is the last line of the add_5 method, 10 is returned from the method and gets passed as an argument to the p method.</li><li>The p method is invoked, outputting 10 to the console.</li></ol><p>Now, follow these same steps for reading the code.</p><blockquote>On line 5, local variable a is initialized and references the integer object 5. On line 6, the add_5 method is invoked and gets passed a as an argument, binding its value to the method’s parameter number. Within the method, the + method is called on number and gets passed the integer 5 as an argument, returning the integer 10. Because this is the last line of the method, 10 is returned from add_5 and gets passed as an argument to the p method invocation, outputting it to the console.</blockquote><p>You may notice that I skipped over discussing the method definition until an object got passed into it. This is a personal choice, as I find it easier to talk through the method using a tangible value; however, you can discuss it beforehand if that’s an easier approach for you.</p><p>One other curious line…</p><blockquote>“Within the method, the + method is called on number and gets passed the integer 5 as an argument, returning the integer 10&quot;.</blockquote><p>Why not just say:</p><blockquote>“This method evaluates the sum of number and 5, returning the integer 10.”</blockquote><p>Although the first explanation is more technically correct, the latter is much clearer and uses less words — why not write that instead? This is an excellent point, and leads me to the final section of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IVWR7beLnYo4HEOU" /><figcaption>Photo by <a href="https://unsplash.com/@lmtrochezz?utm_source=medium&amp;utm_medium=referral">Lina Trochez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Approach</h3><p>Not all code will utilize the same level of explanation. Optimizing your explanation will not only save you time, but will also help in forming a succinct response.</p><p>When first approaching some code to decipher, first determine a few things:</p><ol><li>What is being asked of me?</li><li>How many lines of code will I be describing?</li><li>What is the intent behind the question?</li></ol><p>Let’s break each of these down.</p><h4>What is being asked of me?</h4><p>For any kind of assessment you are given — written or interview — there will be questions that evaluate your understanding of core Ruby principles. In these scenarios, it may not be the best utilization of time to explain every bit of code in your response, so learning what you can omit is a powerful skill.</p><p>Let’s use an example.</p><p>Why does the below code output Hello rather than Goodbye?</p><pre>def greet(greeting)<br>  return ‘Hello’<br>  greeting<br>end<br><br>str = ‘Goodbye’<br>puts greet(str)</pre><blockquote>The following code outputs Hello due to the explicit return command on line 2. When used within a method, the method immediately terminates at the location of the command, returning its argument value. In this case, &#39;Hello’ is returned from greet and output by invocation of the puts method.</blockquote><p>This response is short, sweet, and gets right to the point. The question only asks about the output, to which neither the assignment of str on line 6 nor the calling of greeting on line 3 influence. While it’s certainly better to provide more information than not enough, succinct responses are the most appropriate.</p><h4>How many lines of code will I be describing?</h4><p>The length of the program in question will dictate how in-depth your response should be. For just a few lines of code, it may be worth while to provide a detailed response; however, longer programs can certainly include more summarized sections.</p><p>Let’s take a look at a longer problem.</p><p>What will the below code output and why?</p><pre>def countdown(starting_num)<br>  loop do<br>    puts starting_num<br>    starting_num -= 1<br>    break if starting_num == 0<br>  end<br>  <br>  puts ‘Blast off!’<br>end<br><br>countdown(3)</pre><blockquote>On line 11, the countdown method is invoked and gets passed the integer 3 as an argument, binding it to the method’s parameter starting_num. Within the method, the loop method is called and gets passed a do…end block as an argument, creating a loop from lines 3–5. Upon each iteration of the loop, the current value of starting_num will output, decrement by 1, then terminate the loop if its value is 0. Because its original value is 3, the loop will execute 3 times, outputting 3, 2, and 1, followed by Blast off! from the puts method invocation on line 8.</blockquote><p>Rather than detailing every line within the loop — including the puts method invocation, reassignment of starting_num, and the break if command — a simple summary of these lines was sufficient in showing a clear understanding of its execution.</p><h4>What is the intent behind the question?</h4><p>Responding to a problem goes further than reading exactly what is written in the prompt. While the problem could be a simple ‘a does b’, there’s a good chance that the question is present to check that a fundamental concept is understood. Ask yourself these questions:</p><ol><li>Is there a different result that may have been expected?</li><li>What core concept does this problem demonstrate?</li></ol><p>This is not to say that you should go down a rabbit hole of explanation, rather that there is most likely a purpose to what is being asked.</p><p>Here’s an example.</p><p>What does the below code output and why?</p><pre>str = ’cat’<br><br>def say<br>  str = ’meow’<br>end<br><br>puts str</pre><blockquote>The following code outputs cat. This is due to variable scoping rules in regards to methods, which states that methods have their own, self-contained scope that cannot access local variables initialized outside of it, nor the other way around. Because both str local variables are located within different scopes of the say method, they are considered different variables. The str on line 7 is outside of the method’s scope, and therefore references the value assigned on line 1.</blockquote><p>The question is somewhat vague in what it is asking of us, but there is a clear underlying principle demonstrated in the example: variable scope. Although the question does not explicitly ask for a concept definition, this is a perfect opportunity to showcase that knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OFz1cDnCpHOERabM" /><figcaption>Photo by <a href="https://unsplash.com/@clark_fransa?utm_source=medium&amp;utm_medium=referral">Arnold Francisca</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Final thoughts</h3><p>While the article is intended to help you learn to speak like a Ruby Programmer, you will not become fluent over night. The best way to improve is to take this information and put it into practice. You will certainly make mistakes, but each attempt is like a chisel to the marble stone: you’ll eventually have a beautifully sculpted response.</p><p>Here is what I did in my early studies with the Ruby language:</p><ol><li>Wrote out individual explanations of methods, logical statements, assignments, etc.</li><li>Wrote out individual definitions of fundamental Ruby concepts.</li><li>Went through a series of easy code-snippets, practicing both writing and speaking through the code.</li><li>Practiced the previous point, but in front of others.</li></ol><p>As you work through each point, you will not only gain more confidence with discussing that level of code, but will truly begin to understand the ins and outs of its functionality. Then, when it’s time to showcase all that you have learned throughout your Ruby journey, you’ll feel and sound confident.</p><h4>Additional resources</h4><p>Speaking in Ruby, by <a href="https://medium.com/u/14d9658b6e5">Rebecca Biancofiore</a></p><ul><li>This was the first resource I discovered when learning to speak through Ruby code. Rebecca’s ‘right to left’ approach was a game changer for me.</li></ul><p><a href="https://medium.com/@rebeccabiancofiorecw/speaking-in-ruby-caabc4f1adf6">Speaking in Ruby</a></p><p>Launch School</p><ul><li>I would not be in the position I am today without the incredible education and support provided through Launch School. If you’re an aspiring Software Engineer and don’t know where to begin, I cannot recommend this program enough.</li></ul><p><a href="https://launchschool.com/">Launch School - An Online School For Software Engineers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfc321bf3157" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>