<?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 Craig A Norford on Medium]]></title>
        <description><![CDATA[Stories by Craig A Norford on Medium]]></description>
        <link>https://medium.com/@craig.a.norford?source=rss-4c65c2eb6fef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VZm7qYp43vKCJYPh</url>
            <title>Stories by Craig A Norford on Medium</title>
            <link>https://medium.com/@craig.a.norford?source=rss-4c65c2eb6fef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:09:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@craig.a.norford/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[Runtime Environment Variable Injection for Frontend Applications]]></title>
            <link>https://medium.com/@craig.a.norford/runtime-environment-variable-injection-for-frontend-applications-d0f675d4ffbd?source=rss-4c65c2eb6fef------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f675d4ffbd</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Craig A Norford]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 20:29:38 GMT</pubDate>
            <atom:updated>2025-04-20T20:29:38.825Z</atom:updated>
            <content:encoded><![CDATA[<p>When containerising frontend applications, environment variables are often embedded during the build phase. This traditional approach, however, restricts flexibility, requiring separate builds for each deployment environment (development, staging, production). Deploying the same container image across different environments enhances consistency, simplifies the deployment pipeline, and reduces complexity.</p><h3>Benefits of Runtime Variable Injection</h3><p>Injecting variables at runtime instead of during the build process offers significant advantages:</p><ul><li><strong>Consistency</strong>: Deploy the exact same container image across all environments, ensuring predictable behavior and reducing discrepancies.</li><li><strong>Simpler Deployments</strong>: Eliminates the overhead and complexity of managing multiple builds for different environments.</li><li><strong>Greater Flexibility</strong>: Allows rapid configuration changes without triggering new builds.</li></ul><p>However, it’s important to recognize potential trade-offs:</p><ul><li><strong>Debugging Complexity</strong>: Runtime injection can make debugging more challenging compared to static configurations set at build time.</li><li><strong>Risk of Configuration Drift</strong>: Greater flexibility could inadvertently lead to configuration drift if runtime variables aren’t carefully managed.</li></ul><h3>Example: Runtime Variable Injection Script</h3><p>Below is a practical bash script to dynamically inject environment variables into your frontend’s JavaScript and CSS files when the container starts:</p><pre>for i in $(env | grep -E &#39;(OVERRIDE_)&#39;)<br>do<br>    key=$(echo $i | cut -d &#39;=&#39; -f 1)<br>    value=$(echo $i | cut -d &#39;=&#39; -f 2-)<br>    echo &quot;Replacing ${key} with ${value}&quot;<br>    <br>    find /usr/share/nginx/html -type f \( -name &#39;*.js&#39; -o -name &#39;*.css&#39; \) -exec sed -i &quot;s|\&quot;${key}\&quot;|\&quot;${value}\&quot;|g&quot; &#39;{}&#39; +<br>done</pre><blockquote><strong><em>Note:</em></strong><em> Ensure placeholders are unique to avoid unintended replacements during the script execution.</em></blockquote><h3>Defining Variables in the Dockerfile</h3><p>To utilize the script effectively, define placeholder variables within your Dockerfile:</p><pre>ENV APP_API_URL=OVERRIDE_API_URL<br>ENV APP_ENV=OVERRIDE_APP_ENV</pre><p>These placeholders are replaced dynamically at runtime, allowing the same container image to be used seamlessly across multiple environments.</p><h3>Operational Overview</h3><ul><li>The script scans for environment variables beginning with OVERRIDE_.</li><li>It updates placeholders within your application’s JavaScript and CSS files located in your deployment directory.</li><li>The replacements happen immediately upon container startup, using current environment values.</li></ul><h3>Practical Usage</h3><p>When starting your container, define your specific environment values like this:</p><pre>docker run -e OVERRIDE_API_URL=&quot;https://api.example.com&quot; your-image</pre><h3>Why Not Use the Window Object?</h3><p>Using the global window object to manage environment-specific configurations is common but comes with some drawbacks:</p><ul><li><strong>Security Concerns</strong>: Global exposure of variables makes sensitive information vulnerable to unintended access through browser consoles.</li><li><strong>Maintenance Challenges</strong>: Global state management becomes cumbersome, leading to scattered configurations that are difficult to track.</li><li><strong>Testing and Reliability</strong>: Injecting directly into files promotes consistency, simplifies testing, and reduces unpredictable behaviors associated with mutable global state.</li></ul><p>However, for less sensitive configurations, the simplicity of the window object can still be beneficial.</p><p>Runtime injection typically provides a cleaner, safer, and more maintainable solution, particularly for secure and complex configurations.</p><h3>Conclusion</h3><p>Implementing runtime environment variable injection significantly streamlines the deployment process of frontend applications. While it provides a robust method for dynamically managing configurations and enhancing consistency, it is essential to carefully manage runtime variables to avoid potential pitfalls such as increased debugging complexity and configuration drift.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f675d4ffbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating the Maze: Mastering Naming in Code]]></title>
            <link>https://medium.com/@craig.a.norford/navigating-the-maze-mastering-naming-in-code-226b24f1df3b?source=rss-4c65c2eb6fef------2</link>
            <guid isPermaLink="false">https://medium.com/p/226b24f1df3b</guid>
            <category><![CDATA[naming-conventions]]></category>
            <category><![CDATA[junior-developer]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Craig A Norford]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 11:01:49 GMT</pubDate>
            <atom:updated>2023-12-06T22:45:14.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiQf0j3sNTp4XYI9XULleQ.jpeg" /></figure><p>Hey there, fellow code warriors! Whats in the name? We’re entering the second part on a topic that might seem mundane at first but is actually a crucial skill in the grand coding saga — naming things in your code. Yes, naming! It’s not just about slapping labels on variables or functions; it’s an art form that can make or break your code’s readability and longevity. Let’s embark on this journey to transform from naming novices to nomenclature ninjas!</p><h3>Why Good Naming Matters</h3><p>Ever tried reading a book where every character is named Bob? Confusing, right? That’s what happens when coding lacks good naming conventions. Good naming in code leads to three key benefits:</p><ol><li><strong>Readability</strong>: Like a well-written novel, well-named code tells a clear, understandable story.</li><li><strong>Teamwork-Friendly</strong>: Good naming makes your code a team player — easy for others to read and review.</li><li><strong>Future-Proof</strong>: Think of your future self. Descriptive names make maintaining and updating code a breeze.</li></ol><h3>The Naming Conundrums</h3><p>Let’s look at some common scenarios where naming often leaves developers scratching their heads.</p><h4>Ambiguous Context</h4><pre>def processData(data):<br>   result = data[0]<br>   for d in data:<br>     if d &gt; result:<br>       result = d<br>       return result</pre><p><strong>Issue</strong>: What does `processData` do? What is `result`?</p><p><strong>The Fix</strong>:</p><pre>def findMaximumValue(numbers):<br> max_value = numbers[0]<br>   for number in numbers:<br>     if number &gt; max_value:<br>       max_value = number<br>       return max_value</pre><p>Why It’s Better? The improved version tells you exactly what it does — finds the maximum value in a list of numbers. No ambiguity here!</p><h4>Complex Functions</h4><pre>function handleData(input) {<br> // Complex logic<br> return output;<br>}</pre><p>The issue is, What specific action does `handleData` perform?</p><pre>function processAndValidateUserData(userData) {<br> // Detailed processing and validation logic<br> return validatedUserData;<br>}</pre><p>Why It’s Better? The new name gives away the plot — it processes AND validates user data. Specificity is king!</p><h4>Similar Yet Distinct</h4><p><strong>The Problem</strong>:</p><pre>public void update() {<br> // Updates some data<br>}<br><br>public void updateAll() {<br> // Updates all related data<br>}</pre><p>From these names do you understand how`update` differs from `updateAll`?</p><p><strong>The Fix</strong>:</p><pre>public void updateCurrentRecord() {<br> // Updates the current record<br>}<br>public void updateAllRecords() {<br> // Updates all records in the dataset<br>}</pre><p>Now you know exactly what each function updates. No mix-ups!</p><h4>Convention Chaos</h4><p><strong>The Problem</strong>:</p><pre>def CALCULATEInterest(rate, principal):<br> return rate * principal</pre><p>This is inconsistent with Python’s naming convention (PEP 8).</p><p><strong>The Fix</strong>:</p><pre>def calculate_interest(rate, principal):<br> return rate * principal</pre><p>Adhering to Python’s PEP 8 naming conventions makes your code stylistically consistent and easier to understand for Pythonistas.</p><h3>Wrapping Up: The Name of the Game</h3><p>Remember, naming in coding isn’t just a chore; it’s your chance to add clarity and character to your code. Practice thoughtful naming, and soon you’ll be the Shakespeare of the coding world. Keep your names descriptive, context-appropriate, and consistent with conventions. Your future self, and your team, will thank you.</p><p>Now go forth, junior developers, and name with confidence and creativity. May your code be as readable as your favorite book!</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=226b24f1df3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code Chronicles: The Art of Naming in Programming]]></title>
            <link>https://medium.com/@craig.a.norford/clean-code-chronicles-the-art-of-naming-in-programming-3f6cf7592a5e?source=rss-4c65c2eb6fef------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f6cf7592a5e</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[naming-conventions]]></category>
            <dc:creator><![CDATA[Craig A Norford]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 11:02:35 GMT</pubDate>
            <atom:updated>2023-11-27T11:02:35.571Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome, fellow travellers of the Clean Code Chronicles! In this episode, we dive into the delightful realm of coding, where the elegance of good naming transforms your code into a masterpiece. Join us on this journey, as we unravel the secrets behind the witty art of naming in programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*whhbRY726M1CO7XdCYrV5A.png" /></figure><h3>Prologue</h3><blockquote>Indeed, the ratio of time spent reading vs. writing is well over 10:1.We are <em>constantly </em>reading old code as part of the effort to write new code.</blockquote><blockquote>Because this ratio is so high, we want the reading of code to be easy, even if it makes the writing harder. Of course there’s no way to write code without reading it, so <em>making it easy to read actually makes it easier to write</em>.</blockquote><p><em>Clean Code — Robert C. Martin</em></p><p>Difficult-to-read code incurs financial costs for businesses due to increased maintenance expenses, greater likelihood of bugs and errors leading to costly fixes, reduced developer productivity, extended onboarding and training times, and the accumulation of technical debt. It also necessitates more time-consuming code reviews and debugging processes, diminishes code reusability, hinders effective knowledge transfer, and may adversely impact the end-user experience, potentially affecting customer satisfaction and revenue. Investing in writing clear and readable code is essential to mitigate these financial implications and enhance overall development efficiency. The sooner we understand this as developers, the sooner we can add value to our teams. Naming is just one part of keeping your code clean but a great place to start.</p><h3>Chapter 1: Code Readability — Where the Tale Begins</h3><p>In our opening chapter, we draw parallels between coding and storytelling. A well-structured code reads like a captivating novel, where variables and functions are characters in your narrative.</p><p>Our protagonist, func, begins as a riddle:</p><pre>def func(a, b):<br>    x = a + b<br>    return x</pre><p>But a twist in the plot reveals a fairy tale transformation:</p><pre>def add_numbers(num1, num2):<br>    result = num1 + num2<br>    return result</pre><p>Now, your code has a fairy tale charm, and readability reigns supreme in the kingdom of coding.</p><h3>Chapter 2: Maintainability — The Elixir of Code Immortality</h3><p>In Chapter 2, we explore the concept of code aging gracefully. Just as a ship should withstand the test of time, your code needs to be maintainable.</p><p>In our second example, we discover a code snippet that appears ancient:</p><pre>let a = 10;<br>let b = 5;<br>function f(x, y) {<br>  return x * y;<br>}</pre><p>But behold, a transformation unfolds:</p><pre>const firstNumber = 10;<br>const secondNumber = 5;<br>function multiplyNumbers(num1, num2) {<br>  return num1 * num2;<br>}</pre><p>Now, your code is a phoenix, ready to rise from the ashes whenever changes are needed. It’s a testament to the elixir of maintainability.</p><h3>Chapter 3: Collaboration — The Ensemble Cast of the Programming Theater</h3><p>In the third chapter, we step into the programming theater, where collaboration is the heart of the show. In this grand production, clarity is key, and good naming ensures that everyone knows their role.</p><p>Imagine sharing this script:</p><pre>def g(x):<br>    y = x + 1<br>    return ypy</pre><p>The audience (your team) is left scratching their heads. But present it like this:</p><pre>def increment_by_one(number):<br>    result = number + 1<br>    return result</pre><p>Now, your code is a blockbuster hit, with a well-defined ensemble cast that fosters harmony in collaboration.</p><h3>Conclusion</h3><p>In the Clean Code Chronicles, we’ve unveiled the magic of good naming in programming. It’s not just a chore; it’s a playful dance of words that transforms your code into poetry, a timeless masterpiece, and a blockbuster hit. Embrace quality code naming, and you’ll find your coding adventures enriched, your collaborations smoother, and your code as pristine apps maintainable.</p><p>Stay tuned for our next episode in the Clean Code Chronicles, where we unravel more secrets to writing code that stands the test of time. Until then, happy coding, and may your code be as clean as a freshly turned page!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f6cf7592a5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Code Chronicles: The Truth About Commenting]]></title>
            <link>https://medium.com/@craig.a.norford/clean-code-chronicles-the-truth-about-commenting-f0ad262de550?source=rss-4c65c2eb6fef------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0ad262de550</guid>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Craig A Norford]]></dc:creator>
            <pubDate>Tue, 21 Nov 2023 20:06:05 GMT</pubDate>
            <atom:updated>2023-11-21T22:09:29.505Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, Junior Devs!</p><p>Welcome to the vibrant, ever-evolving world of coding! 🚀 Today, we’re diving into a topic that’s as contentious as tabs vs. spaces (okay, maybe not *that* contentious). It’s about commenting your code. Yes, those little snippets of text you’ve been told are your best friends. But are they always? Let’s chat about how commenting code can sometimes break the “single source of truth” rule and what that means for you.</p><h3>The Single Source of Truth: Myth or Reality?</h3><p>The single source of truth (SSoT) is like the holy grail of coding. It’s the idea that your code — and only your code — should tell the full story of what it does. No legends, no folklore, just pure, unadulterated code. But then come comments, the well-meaning narrators that sometimes end up telling their own version of the story. The inspiration behind this blog was a new junior developer who joined our team, who is fantastic, but we had a really great exchange in our first pairing session where they had commented on nearly every line of their code. This example is not the code but the spirit is the same:</p><pre>// Define a function to add two numbers<br>function addNumbers(a, b) {<br>    // Calculate the sum of a and b<br>    const sum = a + b;<br>    // Return the calculated sum<br>    return sum;<br>}<br><br>// Call the addNumbers function with 5 and 3<br>const  result = addNumbers(5, 3);<br>// Output the result to the console<br>console.log(&quot;The sum is:&quot;, result);</pre><p>when they asked why the comments needed to be removed I found it difficult to articulate why to my satisfaction. Months later when listening to <a href="https://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code</a> by Rober C. Martin and heard this:</p><blockquote>Truth can only be found in one place: the code. Only the code can truly tell you what it does. It is the only source of truly accurate information. Therefore, though comments are sometimes necessary, we will expend significant energy to minimize them.</blockquote><p>For me, this resonated more than anything else. The code itself should be the single source to explain its functionality. Here are a few tales of comment woe to illustrate some common issues with commenting.</p><h3>The Tale of the Outdated Comment</h3><p>Picture this: you’ve written a nifty function that calculates squares. You’ve proudly commented, `# Calculate the square of the number`. But wait! A wild requirement change appears, and your square function is now a cube function. But oops, the comment didn’t get the memo. Now it’s a misleading relic of a bygone era.</p><pre>python<br># Calculate the square of the number<br>def compute_value(x):<br> return x * x * x # It&#39;s a cube now, folks!</pre><h3>Comments: The Crutch of Confusion</h3><p>Good code is like a good book; it shouldn’t need a narrator explaining every plot twist. Over-commenting can be a sign that your code is gasping for clarity. For instance, instead of writing, `// Check if user is eligible for discount`, why not let your code speak for itself with a well-named function?</p><pre>javascript<br>function isUserEligibleForDiscount(user) {<br> return user.age &gt; 65 || user.isVeteran;<br>}</pre><h3>The Echo Chamber of Redundancy</h3><p>Ever heard someone repeat what you just said? That’s what redundant comments feel like. They echo what the code already states, adding clutter without value.</p><pre>java<br>// Set the age of the person to 30<br>person.setAge(30);</pre><p>We get it, the age is set to 30. No need to say it twice!</p><h3>The Ghost Stories of Automated Refactoring</h3><p>Automated tools are like ghost hunters; they don’t care about the stories (comments), only the spirits (code). When refactoring, your comments might end up like ghost stories — intriguing but not really reflecting current realities.</p><pre>c#<br>public int CalculateArea(int length, int width) {<br> return length * width; // This function calculates the area of a rectangle<br>}</pre><h3>The Modern Tale of Self-Documenting Code</h3><p>Instead of relying on comments, strive to write code that’s as self-explanatory as possible. Choose meaningful variable names, structure your code logically, and when all else fails, remember that external documentation is your ally.</p><pre>python<br>def is_user_eligible_for_discount(user):<br> return user.age &gt; 65 or user.isVeteran</pre><h3>A Happy Ending</h3><p>Below is an acceptable example of commenting. Even if you don&#39;t understand the code hopefully you can see the difference in comparison to our previous not-so-happy examples.</p><pre>function adjustTemperature(reading) {<br>    // Corrects the sensor reading for temperature coefficient<br>    // Note: The sensor&#39;s output decreases by 0.05% per degree above 25°C<br>    const BASE_TEMPERATURE = 25;<br>    const TEMPERATURE_COEFFICIENT = 0.0005;<br><br>    if (reading.temperature &gt; BASE_TEMPERATURE) {<br>        let correction = (reading.temperature - BASE_TEMPERATURE) * TEMPERATURE_COEFFICIENT * reading.value;<br>        return reading.value - correction;<br>    }<br>    return reading.value;<br>}</pre><p>What do these comments have that the others didn&#39;t?</p><ul><li><strong>Technical Details: </strong>The comment explains a technical detail (temperature coefficient) that is crucial to understanding why the correction is applied. This specific information is not evident from the code alone.</li><li><strong>Clarifies Complex Logic: </strong>The comment clarifies the reasoning behind the correction formula. While the formula itself is clear in the code, the rationale for its existence is not.</li><li><strong>Preserves the Single Source of Truth:</strong> The code is still the authoritative source for what is being executed. The comment adds value by providing necessary background information, enhancing comprehension without duplicating or contradicting the code’s functionality.</li></ul><h3>Wrapping Up: The Moral of the Story</h3><p>Comments, like fairy dust, should be used sparingly. They’re there to illuminate, not to overshadow. Your mission, should you choose to accept it, is to write code that speaks for itself, where comments are the delightful sprinkles on top, not the main ingredient. Keep your code the single source of truth, and you’ll be the hero in your own coding story.</p><p>Happy coding, and may your comments be few and your code be clean! 🌟👩‍💻👨‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0ad262de550" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Chaos to Collaboration: Improving Your Bootcamp Project Workflow]]></title>
            <link>https://medium.com/@craig.a.norford/from-chaos-to-collaboration-improving-your-bootcamp-project-workflow-10943f297180?source=rss-4c65c2eb6fef------2</link>
            <guid isPermaLink="false">https://medium.com/p/10943f297180</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Craig A Norford]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 11:34:43 GMT</pubDate>
            <atom:updated>2023-04-10T11:34:43.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Team coding together" src="https://cdn-images-1.medium.com/max/1024/1*3w9Fe-A5ttZOlaic_37Tqw.jpeg" /></figure><p>As a software engineer who entered the tech industry through a bootcamp, I’ve had the opportunity to teach part-time at the same bootcamp where I learned the ropes. While guiding students through their final projects, I’ve noticed that many teams struggle not because of their coding skills, but because of inefficient workflows. That is why I recommend incorporating some DevOps and Agile practices into your project. By doing so, you can streamline your development process and work more collaboratively with your team</p><h3>What this Covers</h3><ul><li>Common difficulties with building bootcamp projects</li><li>Improve your project planning and progress tracking</li><li>Automate Deployments to <a href="http://heroku.com/">Heroku</a></li><li>Protect your main branch</li><li>Rails testing!</li><li>Tests and <a href="https://github.com/features/actions">Github Actions</a></li></ul><h4><strong>The Stack</strong></h4><p><a href="https://rubyonrails.org/">Ruby on Rails</a></p><p><a href="https://github.com/">Github</a></p><p><a href="https://www.heroku.com/">Heroku</a></p><h3>Common Difficulties with Bootcamp Projects</h3><p>Bootcamp project teams typically face a number of challenges that can make completing the project more difficult. Some of the most common challenges include:</p><p><strong>Communication:</strong> One of the biggest challenges for any team is communication. When working on a project, it’s important for team members to communicate effectively and regularly in order to ensure everyone is on the same page and the project is progressing smoothly.</p><p><strong>Time management:</strong> Bootcamps are typically intensive programs with strict deadlines, so time management is crucial. Team members must be able to manage their time effectively in order to meet project deadlines.</p><p><strong>Technical difficulties:</strong> Depending on the project, team members may encounter technical difficulties that can slow down progress. This can be particularly challenging for those who are new to coding and may not have the experience to troubleshoot effectively.</p><p><strong>Conflict resolution:</strong> With any team, conflicts can arise. It’s important for team members to be able to resolve conflicts in a constructive manner in order to maintain productivity and avoid negative feelings.</p><p><strong>Motivation:</strong> Bootcamps can be intense and require a lot of hard work, which can be challenging for team members who are struggling with motivation. Team leaders must find ways to keep team members engaged and motivated throughout the project.</p><p><strong>Quality control:</strong> Finally, ensuring that the project meets quality standards can be a challenge. Team members must be diligent in checking their work and testing the project thoroughly in order to ensure it meets the necessary requirements.</p><p>Those of you who are reading this who have already done a bootcamp, or even just building a personal project with a team of other learners, you will probably have experienced some of these challenges. The tools and techniques described below are not a cure-all but will certainly help if executed and used correctly. Great workflows create more time for the important conversations and allow you to stay focused on driving the progress of your project.</p><h3>Improve your project planning and progress rituals</h3><h4>Definition of Done</h4><p>By far the most important piece of advice in this blog is having a clear definition of done for each piece of work, it should look something like this:</p><p><em>“New feature added and </em><strong><em>working in production environment</em></strong><em>”</em></p><p>The most important part of this (in the context of this blog) is “working in production environment”. In my experience of amateur projects, work is considered ‘done’ when a PR has been merged, after which a learner will move on to the next piece of work. This often means that work is never deployed and tested, despite being merged. When the deployment eventually happens there are then multiple PRs worth of code which makes debugging more difficult when problems occur.</p><p>Simply agreeing with your team that every ticket must be tested and working in production before being considered ‘done’ will go a long way towards a better work-flow, smaller, more regular deployments and easier debugging.</p><h3>A Better Kanban</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NXkvciW_hbfLYtPvIBld2g.png" /><figcaption>Basic Kanban</figcaption></figure><p>The basic Kanban that you may be familiar with (as above) is a great way to track work that’s being done in a project, but just this basic version doesn’t quite capture the workflow in fine enough detail.</p><p>To improve the board to better reflect our work flow we will add three columns.</p><p><strong>Backlog: </strong>A backlog column in Kanban is a prioritised list of tasks waiting to be worked on. It sits at the beginning of the board and represents work that hasn’t started. Unlike “To Do” you are not committed to delivering the work in backlog but it is the place to prioritise and decide one what work you are going to commit to with the time you have.</p><p><strong>Under PR: </strong>The “Under PR” column in Kanban represents tasks awaiting review before merging into the main codebase.</p><p><strong>QA in prod:</strong> A “QA in prod” column in Kanban represents tasks being tested in the production environment. It sits towards the end of the board and indicates that the item has been deployed and is being checked for any potential issues before being moved to the “Done” column. Its purpose is to ensure items are thoroughly tested before release to users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8UnSownpsxM7ZoFvugDRg.png" /><figcaption>Improved kanban</figcaption></figure><p><strong>Example Board:</strong> <a href="https://trello.com/b/QUprS2eo/improved-kanban">https://trello.com/b/QUprS2eo/improved-kanban</a></p><p>Tracking the flow of work with more detail gives the whole team better transparency on the project, encourages everyone to meet that definition of done.</p><p><a href="https://kanbanize.com/kanban-resources/getting-started/what-is-kanban-board">Here</a> is a great article by Kanbanize to <a href="https://kanbanize.com/kanban-resources/getting-started/what-is-kanban-board">learn more</a> about Kanban.</p><h3>Automated Deployments With Heroku</h3><p>Now that as a team you’ve agreed on a workflow, what can you do to enable the team to follow that workflow even when under pressure? Firstly we have to understand that even though there are benefits, if a process is difficult to follow it’s unlikely the team will reliably follow that process. We can start with automating deployments.</p><h4>Why you should automate your deployments</h4><p>Speed and efficiency, consistency, simplicity and flexibility. With Heroku’s automated deployment process, developers can quickly and easily deploy their application without worrying about the technicalities of the deployment process. Additionally, the deployment process is consistent, reducing the risk of errors. Heroku’s automated deployment process saves time and improves the efficiency of the development process, making it an ideal option for developers of all skill levels.</p><h4>How to automate your deployments</h4><ul><li>Connect your code repository to your Heroku application by navigating to your app dashboard on the Heroku website and selecting the “Deploy” tab.</li><li>Choose the deployment method that best suits your needs. Heroku offers several options, including GitHub integration, Dropbox integration, and Heroku Git.</li><li>Configure your deployment settings, such as the branch to deploy and any necessary environment variables.</li><li>Enable automatic deploys if desired. This feature will automatically deploy your app every time you push changes to your connected repository.</li><li>Set up automatic scaling for your application, if needed, using Heroku’s built-in features or add-ons.</li></ul><p>One of the key benefits of automating your deployments with Heroku is that it can help you gain valuable experience in problem-solving with your production environment. By deploying on every pull request, you and your team can identify and fix issues early on, rather than waiting until the last minute to deploy a large batch of changes. This approach allows you to test and refine your deployment process continuously, giving you more opportunities to learn from your mistakes and improve your workflow.</p><h3>Protect your main branch</h3><p>Now that you are automating deployment on each merge to main, protect the main branch from being directly pushed to without going though the pull request process. This will mean every piece of code will be seen by at least one other team member, improving the team’s knowledge of the codebase and enforcing the PR process.</p><h4>What is branch protection?</h4><p>Branch protection is a feature in Git-based version control systems, such as GitHub, that allows repository administrators to enforce certain rules and safeguards for specific branches. The purpose of branch protection is to prevent unauthorised changes, reduce errors, and ensure code quality by enforcing best practices for collaborative development.</p><p>Branch protection can include a variety of rules and safeguards, such as:</p><ul><li>Requiring pull request reviews before merging changes into the branch</li><li>Requiring status checks to pass (such as automated tests) before merging changes</li><li>Restricting who can push changes to the branch (such as only allowing certain users or teams)</li><li>Restricting who can merge changes to the branch (such as only allowing administrators)</li><li>Restricting who can delete the branch (such as only allowing administrators)</li><li>Requiring signed commits or specific commit message formats</li><li>Enforcing certain code quality standards (such as preventing commits that fail code linting checks)</li></ul><p>Protecting the main branch in GitHub improves workflow by enforcing rules and safeguards. It ensures code quality by requiring pull request reviews and status checks, reducing errors and saving time. It promotes team collaboration by encouraging feedback and discussion during the review process, enhancing code quality and building a more cohesive team. It also promotes transparency and accountability, helping the team to see changes being made and identify issues. Overall, protecting the main branch leads to a stable, reliable, high-quality codebase and a streamlined workflow.</p><h4>How to protect your main branch</h4><p>To protect the main branch in GitHub, you can follow the steps below:</p><ol><li>Go to your GitHub repository and click on the “Settings” tab.</li><li>In the left-hand sidebar, select “Branches.”</li><li>Under “Branch protection rules,” click “Add rule.”</li><li>In the “Branch name pattern” field, enter “main” (without the quotes).</li><li>Under “Require pull request reviews before merging,” select the checkbox.</li><li>Under “Require status checks to pass before merging,” select the checkbox.</li><li>Under “Include administrators,” select the checkbox.</li><li>Click “Create” to save the branch protection rule.</li></ol><h3>Rails Testing</h3><p>We have automated deployments so as a developer in a project team I can deploy a feature to production and manually test it as soon as it’s merged. But as our app grows bigger it becomes harder and harder to manually test the entire app and make sure we are not breaking features as we’re building new ones. This is where automated tests come into play; we can write tests and run them at any time to check that the app is working as intended.</p><p>My recommendation for putting this into practice given that you don’t have much time to build your projects is to take a “just enough” approach — add the minimum amount of testing required to check that you’re not losing core functionality. For example, test that a key element (that won’t be removed) on each page is visible, so that if you break a page you will know sooner rather than later. This approach doesn’t cover everything but will help you avoid major catastrophes.</p><p><strong>Learn More:</strong> <a href="https://guides.rubyonrails.org/testing.html">https://guides.rubyonrails.org/testing.html</a></p><p>In Rails, there are three main types of tests: unit tests, request tests, and system tests. Here’s how they differ:</p><h4>Unit Tests</h4><p>Unit tests are used to test individual pieces of code in isolation, such as methods or classes. They are usually fast and don’t require a full Rails application to run. Unit tests are typically written using Minitest or RSpec, and are located in the test/models directory. They can be used to test the behavior of models, controllers, and other parts of the application<strong>.</strong></p><p><strong>Example:</strong></p><pre># test/models/user_test.rb<br>require &#39;test_helper&#39;<br><br>class UserTest &lt; ActiveSupport::TestCase<br>  test &quot;full_name returns first and last name&quot; do<br>    user = User.new(first_name: &quot;John&quot;, last_name: &quot;Doe&quot;)<br>    assert_equal &quot;John Doe&quot;, user.full_name<br>  end<br><br>  test &quot;full_name returns only first name if last name is blank&quot; do<br>    user = User.new(first_name: &quot;John&quot;, last_name: &quot;&quot;)<br>    assert_equal &quot;John&quot;, user.full_name<br>  end<br><br>  test &quot;full_name returns only last name if first name is blank&quot; do<br>    user = User.new(first_name: &quot;&quot;, last_name: &quot;Doe&quot;)<br>    assert_equal &quot;Doe&quot;, user.full_name<br>  end<br>end</pre><h4>Request Tests</h4><p>Request tests, also known as integration tests, test the behavior of the application’s controllers and views as a whole, by sending requests to the application and verifying the responses. They test how the application responds to HTTP requests, and can help ensure that the application’s URLs, routes, and views are all functioning as expected. Request tests are typically written using Minitest or RSpec, and are located in the test/controllers directory.</p><p><strong>Example:</strong></p><pre># test/controllers/users_controller_test.rb<br>require &#39;test_helper&#39;<br><br>class UsersControllerTest &lt; ActionDispatch::IntegrationTest<br>  test &quot;index responds successfully&quot; do<br>    get users_path<br>    assert_response :success<br>  end<br><br>  test &quot;index displays a list of users&quot; do<br>    user1 = users(:one)<br>    user2 = users(:two)<br>    get users_path<br>    assert_select &quot;table tr&quot; do<br>      assert_select &quot;td&quot;, user1.email<br>      assert_select &quot;td&quot;, user2.email<br>    end<br>  end<br>end</pre><p>Run the tests with this command:</p><pre>$ rails test</pre><h4>System Tests</h4><p>System tests, also known as end-to-end tests or acceptance tests, test the behaviour of the application as a user would experience it, by simulating user actions such as clicking links and filling out forms. They test how the application works from end-to-end, including its JavaScript behaviour and interactions with external services. System tests are typically written using a tool like Capybara, and are located in the test/system directory.</p><p>In summary, unit tests are focused on testing individual pieces of code, request tests are focused on testing how the application handles HTTP requests, and system tests are focused on testing the application as a whole from a user’s perspective.</p><p><strong>Example:</strong></p><pre># test/system/sign_up_test.rb<br>require &quot;application_system_test_case&quot;<br><br>class SignUpTest &lt; ApplicationSystemTestCase<br>  test &quot;user signs up successfully&quot; do<br>    visit new_user_registration_path<br>    fill_in &quot;Email&quot;, with: &quot;test@example.com&quot;<br>    fill_in &quot;Password&quot;, with: &quot;password&quot;<br>    fill_in &quot;Password confirmation&quot;, with: &quot;password&quot;<br>    click_on &quot;Sign up&quot;<br>    assert_selector &quot;div&quot;, text: &quot;Welcome! You have signed up successfully.&quot;<br>  end<br><br>  test &quot;user receives error message with invalid email&quot; do<br>    visit new_user_registration_path<br>    fill_in &quot;Email&quot;, with: &quot;invalid-email&quot;<br>    fill_in &quot;Password&quot;, with: &quot;password&quot;<br>    fill_in &quot;Password confirmation&quot;, with: &quot;password&quot;<br>    click_on &quot;Sign up&quot;<br>    assert_selector &quot;div&quot;, text: &quot;Email is invalid&quot;<br>  end<br>end</pre><h3>Tests and Github Actions</h3><p>Even though we have testing that can be run easily with a single command, we need to make sure that this testing is happening automatically and is acting as another line of protection for our main branch. We’re going to automate the tests running on each pull request and merge to main, if the test don’t pass you can’t merge. This means rather than finding out you have a bug in production you will likely find out when the test fails and resolve it locally. This keeps your production environment more stable and makes debugging easier.</p><p>To run tests in Rails with GitHub Actions, you can follow these general steps:</p><ol><li>Create a new workflow file in your GitHub repository under .github/workflows/, for example rails-test.yml.</li><li>Define the trigger for the workflow, such as push or pull_request, and specify the branches to watch.</li></ol><pre>name: Rails Test<br>on:<br>  push:<br>    branches: [main]<br>  pull_request:<br>    branches: [main]</pre><p>3. Define the job for the workflow, which will run your tests. Specify the operating system and version you want to use, and any required setup steps such as installing dependencies.</p><pre>jobs:<br>  test:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v2<br>      - name: Set up Ruby<br>        uses: ruby/setup-ruby@v1<br>        with:<br>          ruby-version: 3.0<br>      - name: Install dependencies<br>        run: bundle install --jobs 4 --retry 3<br>      - name: Run tests<br>        run: bundle exec rails test</pre><p>In this example, we’re using the ruby/setup-ruby action to set up Ruby 3.0, and then installing our dependencies with bundle install. Finally, we run our tests with bundle exec rails test.</p><p>4. Save the workflow file and commit it to your repository. GitHub Actions will automatically detect the new file and start running the tests whenever a push or pull request is made to the main branch.</p><p><strong><em>Note:</em></strong><em> You may need to modify these steps based on your specific project and testing needs. You can also customise the workflow further with additional steps, such as running linters or deploying to a staging environment.</em></p><h3>Conclusion</h3><p>Although these tools and techniques take a small amount of time to set up, in the competitive microcosm of a bootcamp you may feel like you’re lagging behind other teams when precious developer time is spent implementing them. However, this will reap huge dividends as your project proceeds as you’ll be spending less time debugging and you’ll have more bandwidth for the important things like figuring out how to improve your platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10943f297180" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>