<?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 Donald Siziba on Medium]]></title>
        <description><![CDATA[Stories by Donald Siziba on Medium]]></description>
        <link>https://medium.com/@donaldsiziba?source=rss-15a421216220------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Dj1piviNkvrXch_fE80OXA.jpeg</url>
            <title>Stories by Donald Siziba on Medium</title>
            <link>https://medium.com/@donaldsiziba?source=rss-15a421216220------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:14:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@donaldsiziba/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[Just Turn the Key]]></title>
            <link>https://medium.com/@donaldsiziba/just-turn-the-key-d448890cd896?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/d448890cd896</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 20:04:24 GMT</pubDate>
            <atom:updated>2026-04-04T18:38:44.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*KnBa5GgbJ0Wjpgf1GiTELg.png" /><figcaption>Image courtesy of AZ Quotes</figcaption></figure><p>In a <a href="https://medium.com/@donaldsiziba/saved-by-the-ford-model-t-e121aeae1ccd?source=friends_link&amp;sk=9f4c9251b5caf8c6dee32bc064547a99">previous article</a>, I used the Ford Model T to make the case for automation. The punchline was this:</p><blockquote>“Although computing is still an industry at the Model-T stage, we can’t afford to go through two pages of instructions again and again for some common operation.”<em> — The Pragmatic Programmer [1]</em></blockquote><p>That was almost four years ago. I have been making good on that argument ever since.</p><p>One of the most repetitive — and most error-prone — rituals in software delivery is the release. You have to be on the right branch. The version has to be bumped. A pull request has to be raised. The artifact has to be built and published. A tag has to be created. And then, somehow, the development branch has to be brought back in sync with what just went to production.</p><p>Miss any one of those steps and the consequences can quietly compound for weeks before anyone notices.</p><p>I have watched talented developers nervously step through the release checklist at the end of a sprint, with the hope everything goes according to plan. It is the kind of work that demands full concentration but rarely gets it — because the pressure to ship has already set in.</p><p>There had to be a better way.</p><p>I am pleased to introduce <strong>GitFlowmatic</strong> — two utility tools that, that complement each other and together, take the toil out of a software release:</p><p><a href="https://awesomaticza.github.io/gitflow/"><strong>gitflow</strong></a><strong> </strong>handles the developer side — releases, hot fixes, branching, version bumping, and raising the pull request — all from your local machine with a single <em>make</em> command.</p><p><a href="https://awesomaticza.github.io/github-workflows/"><strong>github-workflows</strong></a><strong> </strong>handles the server side — the moment that pull request lands on the <em>master</em> branch, GitHub Actions takes over: publishes the artifact, tags the release, and creates a pull request to back-merge the changes into the <em>develop</em> branch.</p><p>No need to remember the checklist. No need to be on the right branch by memory. The process is automatic and foolproof — just like turning the key in a modern car.</p><p>Both tools are available, documented, and ready to wire into any Maven project. If you want to understand the full picture — how they fit together, what happens at each stage, and how to get started — the documentation is the right place to begin.</p><p>No two-page instructions. Just turn the key.</p><p><strong>References</strong></p><p>[1] Excerpt From: Hunt, Andrew;Thomas, David. “The Pragmatic Programmer: From Journeyman to Master”, Addison Wesley Longman Inc., 2000</p><p>GitFlowmatic is a free, open-source product built by <strong>Awesomatic</strong>. Both tools — gitflow and github-workflows are part of the GitFlowmatic toolkit.</p><p>To explore the full product, see what else we have in the works, or get in-touch visit our website — <a href="https://awesomatic.co.za/">awesomatic.co.za</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d448890cd896" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Growing Pains]]></title>
            <link>https://medium.com/@donaldsiziba/growing-pains-4793935ebae5?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/4793935ebae5</guid>
            <category><![CDATA[techtransformation]]></category>
            <category><![CDATA[it-leadership]]></category>
            <category><![CDATA[digital-transformation]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 08 Aug 2025 03:51:54 GMT</pubDate>
            <atom:updated>2025-08-09T09:40:42.349Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*K7PRimjHD4MRxqmcFB1GKA.jpeg" /><figcaption>Image courtesy of Wikipedia — Growing Pains (Alessia Cara song)</figcaption></figure><p><em>“We could have created this magic five years ago,”</em> one of the departmental managers remarked in awe.<br> I smiled. <em>“No,”</em> I replied, <em>“I had to go through some growing pains.”</em></p><p>That moment stuck with me — not because of what we <a href="https://medium.com/@donaldsiziba/i-love-it-when-a-plan-comes-together-c19873656756">built</a>, but because of what it took to get there. The journey wasn’t just technical. It was layered, political, emotional. It was about conviction, patience, and learning to speak multiple dialects: code, strategy, and influence.</p><p>Back when Docker was still a buzzword and most teams dismissed it as “not production ready,” I saw something different. For me, it wasn’t just a container tool — it was a gateway. It allowed me to experiment with fully-fledged CI/CD pipelines in ways that felt almost too elegant to be real.</p><p>I became a bit of a Docker evangelist. For nearly a year, I pitched its potential across architecture forums, often to skeptical audiences. But that year taught me more than just how to defend a technical idea.</p><blockquote>“I learned to speak in ROI and risk, not YAML and logs.”</blockquote><p>I learned to navigate standards and guidelines without losing momentum. And most importantly, I learned to rally cross-functional teams — developers, testers, infrastructure leads — behind a common cause.</p><p>Eventually, we went live with Docker in production — possibly a first in the country. The initiative earned us the Group’s IT Innovation award. But more than the accolade, it proved that conviction backed by collaboration can shift paradigms.</p><p>That experience gave me a taste of what it meant to lead change. So when I transitioned into a Technical Architecture role, I didn’t shy away from the work others avoided. Especially the migrations.</p><p>One of the most impactful migrations involved moving payment platforms from other departments into ours. It wasn’t glamorous work, and it certainly wasn’t popular among the Software Architects tied to business portfolios.</p><p>But it was transformative.</p><p>We enhanced one such platform to support straight-through processing for outward money transfers — cutting transfer times from over an hour to mere seconds. Inward transfers were a bit more complicated, but we streamlined them from over a week to just three days.</p><blockquote>“The result? Improved cash flow for countless small and medium businesses.”</blockquote><p>That kind of impact doesn’t show up in a sprint review, but it echoes in boardrooms and balance sheets.</p><p>That project didn’t just improve systems — it built trust. So when a Software Architect left one of the business portfolios, I was recommended to fill the role. It was a microcosm of everything I’d been preparing for: working directly within a business unit, translating technical possibilities into strategic outcomes.</p><p>Looking back, I understand why we couldn’t have built that “magic” five years earlier. I wasn’t ready. I needed the friction, the resistance, the slow wins.</p><p>I needed to learn how to listen, how to persuade, how to build bridges between silos.</p><blockquote>“Growing pains aren’t just uncomfortable — they’re essential.”<em> <br> </em>They shape the kind of leader who doesn’t just build systems, but builds belief.</blockquote><p><strong>The Backstory</strong></p><p>Titles are funny things. They often arrive late — trailing behind the work, the grit, the quiet reinvention.</p><p>Five years prior to this conversation, I interviewed for a Senior Developer role. The level of mastery I demonstrated in the technical assessment stirred debate. This particular manager saw something more — argued I could step straight into architecture. The rest of the panel hesitated. “Not battle-hardened enough,” they said. So they compromised and offered me a Technology Specialist role — which still took me by surprise when I got the offer letter.</p><p>Six months later, I was promoted to Software Architect.</p><p>Maybe I wasn’t battle-hardened then, but the battlefield showed up anyway, and the journey to get to that point had been nothing but colourful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4793935ebae5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“What traits make you stand out as a Software Engineer?”]]></title>
            <link>https://medium.com/@donaldsiziba/what-traits-make-you-stand-out-as-a-software-engineer-857970912fa6?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/857970912fa6</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 22 Mar 2024 06:02:22 GMT</pubDate>
            <atom:updated>2026-03-05T09:12:30.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6Nuqo7H6CnzJN4OMdrm6w.jpeg" /><figcaption>Image courtesy of Getty Images</figcaption></figure><p>I was on a call recently with someone who wants me to mentor him when he posed this pertinent question. I took a moment to gather my thoughts as I had never thought of this before, let alone attribute myself the tag of a “Rock Star” or “10x” Software Engineer. Looking back on my journey, I realised that it’s all about mastering the basics well, staying open to learning and continuous experimentation. Armed with this I feel one will be able to provide top-notch and world-class solutions in any environment.</p><p>One instance that stands out is once when I did a routine technical assessment and interview for a Senior Developer role. I was surprised when I eventually received the offer. In the offer letter, I was offered a Technology Specialist role along with a hefty pay increase. I immediately called the HR representative to rectify the “mistake”. She stated that the interview panel was blown away by my solution and approach to the technical assessment so they unanimously decided to offer me another role they were looking to fill. Did I not grab this opportunity with both hands and run with it. Fast forward 6 months into this role, I was promoted to the role of a <a href="https://medium.com/@donaldsiziba/i-worked-myself-out-of-a-tech-job-not-once-but-twice-63eeb830ce5e?source=friends_link&amp;sk=10d3ccafa01535a6ac291f31022c9bf6">Software Architect</a>.</p><p>As I reflected on our conversation after the call, I couldn’t help but think of the trail of events that led to my promotion a mere 6 months into this role, and this is one of those that stand out.</p><p>I occasionally had chats with the CIO and in one of our chats I picked up a critical issue of manual deployments and security exposure due to artifact distribution via shared folders. I pointed out that this could be a deployment model that the Flintstones would be proud of and we both chuckled at this thought. I went on the explain my extensive experience with automated builds and deployments and I offered to demonstrate some of the deployment pipelines that I had built in my spare time. He suggested that he would instruct the Lead Architect to invite me to the Architecture Forum to showcase the deployment pipelines.</p><p>The Architecture Forum was impressed with the showcase and they immediately approved that I could liaise with the core team to implement automated deployments in their environments. Something else caught the attention of the Lead Architect, which was the rapid speed at which I managed to provision the test environments. I used <a href="https://www.docker.com/">Docker</a> to provision the test environments which contributed to the fast start-up times for the test environments. Just some background, this is about a decade ago, Docker was relatively unknown at this time. Some of those who knew Docker were in a big debate whether Docker was suitable for production deployments, and the remainder wouldn’t even touch Docker with a 10-foot pole.</p><p>We then went on to brainstorm how we could use Docker in our software delivery value stream. Myself and the Lead Architect had started working in this department at the same time. One of our mutual frustrations was the slow onboarding of the developers into the development teams. Case in point we had been there for over a month and we both didn’t have a fully running environment for one of the core applications on our laptops.</p><p>We came up with an idea to streamline developer onboarding. The idea was to use a concept that we eventually termed DevBox. This DevBox would comprise a Linux ISO image installation preconfigured with all the development tools along with the network and the security configuration of the organisation. Once a new joiner was issued with a laptop they would install the ISO image via a network drive and within an hour they would have a fully-fledged development environment. We further proposed we would use Docker to spool up the core application on the developer’s laptop using automated deployment scripts. With this setup, the developers would have a full development environment, including the core application, up and running by lunchtime on their first day. This way we would cut out the months of frustration of trying to set up development environments to within a few hours. We put together a business case and we were given the go-ahead to implement DevBox.</p><p>DevBox became quite a hit and it was eventually rolled out to the whole organisation to standardise the Linux environments preferred by the majority of developers. As for Docker, we eventually deployed it to our production environment after a rigorous journey where we took it to the various Architectural Forums within the organisation to garner support and approval. We were probably one of the first organisations in the country to go live with Docker in production. After this, we took on the role to assist other departments within the organisation with their Docker rollouts. Later that year we won the organisation’s <em>IT Innovation Award</em>. Not a bad achievement within the first 2 years I reckon, the only challenge was how to maintain this or even <a href="https://medium.com/@donaldsiziba/i-love-it-when-a-plan-comes-together-c19873656756?source=friends_link&amp;sk=3a819189931d488973e8123720a941cd">surpass it</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=857970912fa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I love it when a plan comes together]]></title>
            <link>https://medium.com/@donaldsiziba/i-love-it-when-a-plan-comes-together-c19873656756?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/c19873656756</guid>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 05:56:20 GMT</pubDate>
            <atom:updated>2024-09-10T17:45:11.770Z</atom:updated>
            <content:encoded><![CDATA[<h3>I love it when a plan comes together.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UAKSqGH8YUCw9eSrg2ky-g.jpeg" /><figcaption>Image courtesy of imgflip.com</figcaption></figure><p>The odds were stacked against the team. The business owner was already in discussions with a third-party service provider to take over the reporting solution if the team didn’t meet the mandate of reducing the project delivery timelines this time around. If you recall in my <a href="https://medium.com/@donaldsiziba/i-worked-myself-out-of-a-tech-job-not-once-but-twice-63eeb830ce5e">previous post</a>, our business wanted to roll out the solution to 5 countries within 2 years. The problem was a single implementation was taking over a year to roll out. Needless to say, at this rate we would roll out the solution in 5 countries in 5 years, which was clearly untenable. There were already 2 implementations running in production and the business owner didn’t understand why rollouts took so long and cost so much. The next few months were critical.</p><blockquote><strong><em>There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. — C.A.R. Hoare</em></strong></blockquote><h3>The Principle of Conceptual Integrity</h3><p>The fact that there were two separate codebases for the same reporting solution was one of the red flags I spotted during my initial investigation. I examined both codebases and I discovered that they shared more than 80% of the same code. The remaining portion of the code that was different was related to the central regulatory authorities’ web service contracts, which we integrated with for compliance reporting.</p><p>For the uninitiated, a <em>web service </em>is a function that can be accessed by other programs over the internet. A <em>web service contract </em>defines the format of the data involved in the information exchange.</p><p>The problem with this approach is that it locks all parties into a specific web service contract and prohibits code reusability across the different reporting implementations. This translated to all the parties starting from scratch whenever there was a need to onboard a new country onto the reporting solution, hence the long delivery times and the never reducing project costs. If we had to make the rollout of the reporting solution viable the concrete dependency on the <em>web service contracts </em>from the central regulatory authorities had to be broken. I applied the architectural principle of <em>Conceptual Integrity </em>to come up with what would be a sustainable rollout of the reporting solution.</p><h4>Conceptual Integrity</h4><p><em>The application should avoid concrete dependencies on other systems and applications where possible, and provide features that allow it and any data that it holds to be upgraded, migrated, and re-factored. </em>[1]</p><p><em>- Application Architecture Guide — Chapter 6: Quality Attributes — J.D. Meier, Alex Homer, David Hill, Jason Taylor, Prashant Bansode, Lonnie Wall, Rob Boucher Jr, Akshay Bogawat.</em></p><p>After a few design sessions, we managed to come up with a standard contract that would be used within our organization for future projects. In addition to this, we managed to design a nifty adaptor component that would transform the message formats appropriately as they transition across the integration boundary. In Domain Driven Design terminology this integration boundary is known as the <a href="https://learn.microsoft.com/en-us/azure/architecture/patterns/anti-corruption-layer">Anti-corruption Layer</a> [2].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxhzexEoL5s-JvzlukXQXg.png" /><figcaption>To the left of the dotted line are implementations that were locked into the respective central authority web service contracts. To the right is the proposed blueprint of the solution centered around the adaptor component to break the concrete dependency on the central authorities’ web service contracts.</figcaption></figure><p>We somehow knew we had done a great job in meeting the initial business mandate, but we couldn’t prove it then as this was the initial implementation.</p><p>This is probably the simplest and most elegant solution that I have ever come up with — I doubt I will ever top it.</p><p><strong>The Litmus Test</strong><br>It was one Thursday afternoon when I was summoned to an urgent and impromptu meeting. When I walked into the meeting room, the project manager was already on a conference call with some executives from the country where we were implementing the reporting solution. The mood in the room was tense and I knew straight away something was wrong.</p><p>“As you all know, it has been a few days since we went live but the central regulatory authority still has not granted anyone permission to integrate into their web services due to a situation that is out of their control,” the project manager began. “This has put us in a difficult situation as one of the vendors who were reporting to the authority before on a previous version of the application can not have 2 different applications running in their production environment.” This was new information to me as this had never been raised when we logged the project’s risks. “We will have to pay severe penalties if we don’t submit any reports after the grace period which has been afforded to us until next week Wednesday.” Looking toward me she continued, “The reporting entities are already submitting reports to the aggregator component, right?”. I nodded gently to affirm her statement. “Since we have the data in the aggregator component, is it not possible to filter the data from this vendor and submit it to the previous web service endpoint?” she quizzed. I promised to get back to her by the close of business after consulting with the team.</p><p>I consulted the team and everyone was extremely confident we could pull off the rescue mission. A chance to test out our design couldn’t have presented itself at a more opportune time. I confirmed with the project manager that we would solve this issue and that there was no need for us to work over the weekend.</p><p>As things turned out we were right. We were able to develop, test and deploy the solution to production by Tuesday afternoon. This alone was good enough to prove we had done enough to streamline the delivery timelines and reduce rollout costs for future projects. In light of this, <a href="https://medium.com/@donaldsiziba/i-worked-myself-out-of-a-tech-job-not-once-but-twice-63eeb830ce5e?source=friends_link&amp;sk=10d3ccafa01535a6ac291f31022c9bf6">my job here was done</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ElLrF2Fqw2Jm58vW5rXZqw.jpeg" /><figcaption>Image courtesy of Wikipedia</figcaption></figure><p><strong>References</strong></p><p>[1] Excerpt from: J.D. Meier; Alex Homer; David Hill; Jason Taylor; Prashant Bansode; Lonnie Wall; Rob Boucher Jr; Akshay Bogawat. “Application Architecture Guide.”</p><p>[2] Anti-corruption Layer Patter — <a href="https://learn.microsoft.com/en-us/azure/architecture/patterns/anti-corruption-layer">https://learn.microsoft.com/en-us/azure/architecture/patterns/anti-corruption-layer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c19873656756" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Saved by the Ford Model T]]></title>
            <link>https://medium.com/@donaldsiziba/saved-by-the-ford-model-t-e121aeae1ccd?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/e121aeae1ccd</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-leadership]]></category>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[it-automation]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 01 Apr 2022 08:01:44 GMT</pubDate>
            <atom:updated>2026-04-09T09:35:01.904Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFY_69OAHr9DCufBbPWwpA.jpeg" /><figcaption>Image courtesy of Adobe Stock.</figcaption></figure><p>No sooner had I assumed the <a href="https://medium.com/@donaldsiziba/i-worked-myself-out-of-a-tech-job-not-once-but-twice-63eeb830ce5e">Software Architect role</a> in the business portfolio, did the department kick off a series of monthly meetings where a given team would present the highlights of the previous month and mention what we could look forward to in the upcoming month. And as “luck” would have it our team was nominated to go first. As the de-facto technical lead of the team, I wasn’t spared either, I was asked to present “something”. I was also informed that the C-level executives were going to grace this presentation as it was the inaugural one, this just added to the pressure. Whatever topic I would choose to present, I had to make sure not to bore the C-level executives with any technical jargon.</p><p>Having helped out this team before during my tenure as the Technical Architect, I knew what I was getting myself into. After much deliberation, I decided I was going to present on DevOps with an emphasis on Automation. But how does one present on DevOps and Automation without sounding too technical?</p><p>Luckily at the time on my daily commute to and from work I was reading an ebook titled <em>The Pragmatic Programmer: From Journeyman to Master. </em>One of the articles, headlined <em>Ubiquitous Automation</em>, that had caught my attention gave an idea of how I could structure my presentation. This is where the Ford Model T comes in.</p><p>I kicked off the presentation by asking the audience if they knew the name of the car pictured above. To everyone’s amusement, no one was able to give the correct answer. And then I went on to list some amazing facts about the Model T.</p><ol><li>With over 16.5 million units sold, the Model T is the eighth best selling car of all time — [1] — infoplease.com — <a href="https://www.infoplease.com/world/travel-transportation/top-ten-best-selling-cars-all-time">Top Ten Best Selling Cars of All Time</a></li><li>In 1999 the Global Automotive Electronic Foundation name the Model T <em>The Most Influential Car of the 21st Century </em>mainly because it was the first car to be mass produced by means of an assembly line. — [2]— Wikipedia — <a href="https://en.wikipedia.org/wiki/Car_of_the_Century#:~:text=The%20Car%20of%20the%20Century,1999%20in%20Las%20Vegas%2C%20Nevada.">Car of the Century</a></li></ol><p>Despite these amazing facts here is one hard truth about the Model T… and the IT Industry.</p><p><em>“At the dawn of the age of automobiles, the instructions for starting a Model-T Ford were more than two pages long. With modern cars, you just turn the key — the starting procedure is automatic and foolproof. A person following a list of instructions might flood the engine, but the automatic starter won’t.</em></p><p><em>Although computing is still an industry at the Model-T stage, we can’t afford to go through two pages of instructions again and again for some common operation. Whether it is the build and release procedure, code review paperwork, or any other recurring task on the project, it has to be automatic. We may have to build the starter and fuel injector from scratch, but once it’s done, we can just turn the key from then on.</em></p><p><em>In addition, we want to ensure consistency and repeatability on the project. Manual procedures leave consistency up to chance; repeatability isn’t guaranteed, especially if aspects of the procedure are open to interpretation by different people.” </em>[3]</p><p>-<em>The Pragmatic Programmer: From Journeyman to Master — Ubiquitous Automation — Andy Hunt and Dave Thomas</em></p><p>Unfortunately, this is a sad reality in the IT industry, though there has been some vast improvements lately.</p><p>Whenever I start a new job or join a new team I am reminded of the movie <a href="https://en.wikipedia.org/wiki/Edge_of_Tomorrow">Edge of Tomorrow</a> [4]. I always feel as if I am caught in a time loop whereby I join a team, optimize and automate their software delivery value stream only to do it all over again when I move on to join the next team.</p><p>That is how the Model T saved my first assignment as the technical lead of my new team. With this presentation, I had somehow laid down a marker of what I intended to do in my new role. After months of hard work, we managed to fully automate build, test, and deployment workflows from the developers’ local environments right up through to production, much to the delight of the team who until then were used to manual deployments.</p><p><strong>References</strong></p><p>[1] <a href="https://www.infoplease.com/world/travel-transportation/top-ten-best-selling-cars-all-time">Top Ten Best Selling Cars of All Time</a> — infoplease.com</p><p>[2] <a href="https://en.wikipedia.org/wiki/Car_of_the_Century#:~:text=The%20Car%20of%20the%20Century,1999%20in%20Las%20Vegas%2C%20Nevada.">Car of the Century</a> — Wikipedia</p><p>[3] Excerpt From: Hunt, Andrew;Thomas, David. “The Pragmatic Programmer: From Journeyman to Master”, Addison Wesley Longman Inc., 2000</p><p>[4] <a href="https://en.wikipedia.org/wiki/Edge_of_Tomorrow">Edge of Tomorrow</a> — Wikipedia</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e121aeae1ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I worked myself out of a tech job not once… but twice]]></title>
            <link>https://medium.com/@donaldsiziba/i-worked-myself-out-of-a-tech-job-not-once-but-twice-63eeb830ce5e?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/63eeb830ce5e</guid>
            <category><![CDATA[software-leadership]]></category>
            <category><![CDATA[collaboration]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 18 Mar 2022 05:15:31 GMT</pubDate>
            <atom:updated>2024-07-24T07:21:55.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GowcTCJS3kQQObYsrAxN5A.jpeg" /><figcaption>Image courtesy of Adobe Stock.</figcaption></figure><p>The first time it happened I was just a senior Java developer graciously going about his job when I was informed my services were no longer required, and that I had a few months to look for my next job. I was given the offer to stay on if nothing materialized within those few months, but thankfully I managed to find another job within a month.</p><p>The second time, I was an accomplished Software Architect and I knew better when to walk before being asked to do so.</p><p>Here are some of the things I believe helped me “walk on water” and “shoot the lights out” in these 2 roles.</p><p><strong>Understand the Big Picture</strong></p><p>One major pitfall that software developers suffer from is focusing on coding mostly, in the process they miss out on understanding the big picture of why they are coding in the first place. One thing that I always set out to do is to probe the stakeholders for the big picture.</p><p>In the Java developer role, the team was experiencing an influx of Business-to-Business integration projects and their turnaround times were no longer acceptable. I was hired to come in and streamline the delivery of these integration projects.</p><p>In the Software Architect role, I had just been tasked to lead a business portfolio, after being a Technical Architect for over 3 years. The business division needed to roll out its reporting solution to 5 subsidiaries, read countries, within 2 years. The problem was that the team at the time was taking over a year to roll out the solution to a single subsidiary.</p><p><strong>Communicate the Vision</strong></p><p>One of the key things an Architect has to get right is to understand what needs to be built, create a vision for building it and make the appropriate design decisions. Equally crucial is communicating the vision so that everybody involved in the delivery of the project understands what needs to be done so they can contribute in a positive way to its success.</p><p>On both occasions, I spelt out the vision of what we needed to achieve and I purposefully scheduled recurring sessions where I shared progress with the team. With the recurring sessions, my aim was to ensure visibility and make the point that everyone was equally responsible for the successful delivery of the project.</p><p><strong>Delegate</strong></p><p>Software developers who eventually move on to lead development teams usually struggle with letting go of their software development duties and as a result, they end up spreading themselves too thin as they strive to balance between their main duty of leading the team and dabbling in software development tasks.</p><p>While I struggled with this for some time, I quickly realized that I would be more effective if I could not only delegate some of the difficult programming tasks but also deliberately impart my architectural knowledge to the team. You will be surprised how many developers struggle to move onto architecture and they will gladly take on the offer if someone avails it to them.</p><p>By allowing your team to take on more responsibility, you eventually free yourself to move on and do something else which could actually contribute to your growth as well. So in the end everyone gets to benefit.</p><p><strong>Reusability</strong></p><p>One of the architectural principles that I heavily relied on in both engagements was <em>Reusability</em>. In both cases, I was able to identify the blocks of functionality that could be abstracted and reused, sometimes without even the need to code except maybe to perform a few minor configuration tweaks, for the subsequent delivery of future projects. This, and automation, are the main attributes that made me dispensable.</p><p>Needless to say in both projects I was able to reduce the project implementation times significantly. For the Business-to-Business project, I was able to reduce delivery time from a month to a few days and the reporting solution from just over a year to one month. Yes, one month you read that right. How we pulled this off is worthy of <a href="https://medium.com/@donaldsiziba/i-love-it-when-a-plan-comes-together-c19873656756">a post</a> on its own. Stay tuned…</p><p><strong>Automate</strong></p><p>I have always been fascinated with build, test, and deployment automation since I wrote my first custom Maven plugins years ago to achieve automated deployments, and need I say I have never looked back since then.</p><p>When I joined the reporting team, the developers were manually writing release notes on some collaboration platform. The operations team would in turn read through these instructions and deploy the changes to the environments. In short, deployments used to take a lot of the team’s development time. When I left we had the same build, test and deployment scripts running from the developers’ local environments through to test environments and into production. We actually implemented One-Click and Zero-Downtime deployments in the test and production environments.</p><p>Aim to automate as much as possible so as to free the team from doing repetitive and boring tasks. This will leave the team free to concentrate on delivering real business value.</p><p><strong>Passion</strong></p><p>I am a naturally introverted person but over the years, I became so passionate about Software Craftsmanship to an extent that I felt the need to impart some of my knowledge to the teams that I worked with. In the process I had to overcome some things that totally terrify me, like public speaking.</p><p>In the reporting development team, I managed to host technical design sessions once a week for a few months.</p><p>During this time I also eventually hosted a general tech discussion forum every Friday. These sessions attracted the attention of other development teams on the floor and we found ourselves looking for bigger meeting rooms to accommodate extra numbers.</p><p>I was amazed I pulled it off, but I think this all boiled down to my passion to share my knowledge.</p><p><strong>Documentation is a Superpower </strong><br>This point will probably make me very unpopular among developer circles, but I will make it anyway.</p><p>Development teams tend to leave project documentation till the last phase of the project. But in most cases than not, when this last phase comes, still little or no documentation is ever done.</p><p>I have mastered the discipline of documenting early and often and I have seen the benefits. Documenting early forces you to think about the project delivery by challenging some of the assumptions you have about the requirements, in the process I find I usually consult extensively and refine my design a couple of times before it eventually sticks.</p><p>Take time to document the project incrementally, in this way the knowledge does not only stay with you, but any team member or stakeholder can reference it whenever.</p><p><strong>Conclusion</strong></p><p>Would I work myself out of a job again if I had the chance? Absolutely YES!</p><p>Working yourself out of a job not only gives you satisfaction, but also the confidence to move on and break new ground.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63eeb830ce5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Requirements as First Class Citizens]]></title>
            <link>https://medium.com/@donaldsiziba/requirements-as-first-class-citizens-cc67f15f4c7d?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc67f15f4c7d</guid>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[softare-development]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Fri, 21 Jun 2019 17:39:21 GMT</pubDate>
            <atom:updated>2025-06-25T20:18:30.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35MuqNMEh96rFMwmqIVDMg.png" /><figcaption>Image courtesy of edition.cnn.com</figcaption></figure><blockquote>The hardest part of building software is not coding — it’s requirements.</blockquote><p>Technology within the IT space is evolving rapidly and it is usually overwhelming for one to keep up with the trends. From front-end technologies to DevOps practices add Containerisation, Microservices to the list and off-course top it up with Cloud Computing. Then there’s also Artificial Intelligence, Machine Learning, and Quantum Computing. The last three are slated to change Computer Programming and Computing as we know it forever. But that’s a story for another blog.</p><p>Despite all these shiny technology trends, the one that has really caught my attention over the years, and is probably the least known, is Behaviour Driven Development (BDD).</p><p><strong>What is Behaviour Driven Development?<br></strong>Agile development has significantly reduced project delivery times from what they were over a decade ago. With so little time to complete a delivery phase, it becomes an absolute need to eliminate as much unnecessary work as possible. Common areas that slow down project delivery include detailed requirements specifications, wasteful rework caused by ambiguities and functional gaps, and long manual regression testing cycles. BDD attempts to streamline project delivery so tangible value can be realized across the software delivery value chain.</p><p>BDD is a software development process that encourages collaboration among analysts, developers, testers, and business stakeholders with an emphasis on discovering and delivering features that provide visible business value. BDD provides a common language based on simple, structured sentences that facilitate communication between team members and business stakeholders.</p><p><strong>Feature Specifications<br></strong>BDD specifications are built through the close collaboration of the project team and business stakeholders using concrete examples to create a common understanding of the requirements. BDD feature specifications consist of a narrative and one or more scenarios. The feature specification format looks like this:</p><pre>Narrative:<br>In order to [achieve a desired outcome]<br>As a [role]<br>I want [feature]<br><br>Scenario: [description]<br>Given [initial context]<br>When [event or action occurs]<br>Then [description of expected outcomes]</pre><p>Here’s an example of a feature specification:[1]</p><pre>Feature: Transferring money between accounts<br> In order to manage my money more efficiently<br> As a bank client<br> I want to transfer funds between my accounts whenever I need to<br><br> Scenario: Transferring money to a savings account<br> Given my current account has a balance of 1000.00<br> And my savings account has a balance of 2000.00<br> When I transfer 500.00 from my current account to my savings account<br> Then I should have 500.00 in my current account<br> And I should have 2500.00 in my savings account<br><br> Scenario: Transferring with insufficient funds<br> Given my current account has a balance of 1000.00<br> And my savings account has a balance of 2000.00<br> When I transfer 1500.00 from my current account to my savings account<br> Then I should receive an &#39;Insufficient Funds&#39; error<br> And I should have 1000.00 in my Current account<br> And I should have 2000.00 in my Savings account</pre><p>The feature specifications are expressed in plain English which means requirements can be written in a clear, precise, and unambiguous way.</p><p><strong>Executable Specifications<br></strong>Feature specifications that are written in the format specified above can be used as executable specifications that can be used to determine whether a particular feature is production ready or not. These executable specifications can be run as part of an automated build process.</p><p>In my next post, I will go through an example that will showcase how to use BDD to capture specifications and how to use these specifications to drive project delivery.</p><p>[1] John Ferguson Smart — <em>BDD in Action, Manning Publications Co, 2015</em></p><p><em>Originally published at </em><a href="https://awesomaticblog.wordpress.com/2019/06/21/requirements-as-first-class-citizens/"><em>http://awesomaticblog.wordpress.com</em></a><em> on June 21, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc67f15f4c7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Good Are Your Tests?]]></title>
            <link>https://medium.com/@donaldsiziba/how-good-are-your-tests-b0c1ac11b424?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0c1ac11b424</guid>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 11:45:15 GMT</pubDate>
            <atom:updated>2024-04-03T18:55:33.012Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otoBa-XNCudoq-1fnnAN6Q.jpeg" /><figcaption>Image courtesy of iStock</figcaption></figure><p>By now you know what TDD is. It’s now second nature as you practice it consistently in your day-to-day development tasks. But do you ever wonder how good your tests really are?</p><h4>Code Coverage</h4><p><a href="https://en.wikipedia.org/wiki/Code_coverage">Code Coverage</a>, sometimes referred to as Test Coverage, is the most common way to indicate the quality of the test suite in most software development teams. Code Coverage measures the lines of code that are executed during testing and provides reports on how well the code is covered. <a href="https://www.sonarqube.org/">Sonarqube</a> is the most popular tool that is used to measure code coverage in most Java projects.</p><p><a href="https://github.com/donaldsiziba/password-validator">GitHub - donaldsiziba/password-validator</a></p><p>Let’s revisit the <a href="https://medium.com/@donaldsiziba/a-comprehensive-tdd-kata-og-8ebfafcddc71?source=friends_link&amp;sk=377e51a24e58bb377d302586d8349632">Password Validator</a> and generate a code coverage report. Instead of using Sonarqube, I will use my IDE to generate the code coverage report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xak8VoDEK72GX2bk.png" /><figcaption>Disclaimer: Full coverage should never be an obsession when writing tests Aim to write tests that cover the important use cases.</figcaption></figure><p>The Code Coverage report shows full coverage of all classes and lines under test. However, full coverage proves nothing about the quality of the underlying tests. To showcase this point, declare dummy assertions for the Spock test and comment out the assertions in the JUnit test.</p><p><strong>Please NOTE</strong>: Modify both the <em>Spock</em> and <em>JUnit</em> test classes.</p><p><strong>Spock</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>        PasswordValidationResponse result = passwordValidator.apply(new PasswordValidationRequest(password, previousPasswords))<br><br>        then: &quot;the result should be #valid&quot;<br>            assert true    //dummy assert<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>           <br>            assert true    //dummy assert<br><br>        where:<br>            password           | previousPasswords       || valid | messages<br>            &#39;userp@ssw0rd&#39;     | [] as Set               || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     | [] as Set               || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     | [] as Set               || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     | [] as Set               || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      | [] as Set               || false | [&#39;The password should be at least 12 characters long&#39;]<br>            &#39;User   P@ss w0rd&#39; | [] as Set               || false | [&#39;The password should not have any whitespaces&#39;]<br>            &#39;UserP@ssw0rD&#39;     | [] as Set               || true  | []<br>            &#39;userpasword&#39;      | [] as Set               || false | [&#39;The password should have at least one uppercase character&#39;,&#39;The password should have at least one digit&#39;,&#39;The password should have at least one special character&#39;,&#39;The password should be at least 12 characters long&#39;]<br>            &#39;UserP@ssw0rD&#39;     | [&#39;UserP@ssw0rD&#39;] as Set || false | [&#39;The password should not match any of the previous passwords&#39;]<br>    }<br>}</pre><p><strong>JUnit</strong></p><pre>@RunWith(Parameterized.class)<br>public class PasswordValidatorTestCase {<br>    @Parameterized.Parameters(name= &quot;{index}: validate({0})&quot;)<br>    public static Collection&lt;Object[]&gt; data() {<br>        return Arrays.asList(new Object[][] {<br>                {&quot;userp@ssw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one uppercase character&quot;}},<br>                {&quot;USERP@SSW0RD&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one lowercase character&quot;}},<br>                {&quot;UserP@ssword&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one digit&quot;}},<br>                {&quot;UserPassw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one special character&quot;}},<br>                {&quot;UserP@sw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should be at least 12 characters long&quot;}},<br>                {&quot;User   P@ss w0rd&quot;, new String[] {}, false, new String[] {&quot;The password should not have any whitespaces&quot;}},<br>                {&quot;UserP@ssw0rD&quot;, new String[] {}, true, new String[] {}},<br>                {&quot;userpasword&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one uppercase character&quot;, &quot;The password should have at least one digit&quot;,<br>                        &quot;The password should have at least one special character&quot;, &quot;The password should be at least 12 characters long&quot;}},<br>                {&quot;UserP@ssw0rD&quot;, new String[] {&quot;UserP@ssw0rD&quot;}, false, new String[] {&quot;The password should not match any of the previous passwords&quot;}}<br>        });<br>    }<br><br>    private String password;<br>    private String[] previousPasswords;<br>    private boolean valid;<br>    private String[] messages;<br><br>    PasswordValidator passwordValidator;<br><br>    public PasswordValidatorTestCase(String password, String[] previousPasswords, boolean valid, String[] messages) {<br>        this.password = password;<br>        this.previousPasswords = previousPasswords;<br>        this.valid = valid;<br>        this.messages = messages;<br>    }<br><br>    @Before<br>    public void setUp() {<br>        passwordValidator = new PasswordValidator();<br>    }<br><br>    @Test<br>    public void validatePassword() {<br>        PasswordValidationResponse result = passwordValidator.apply(new PasswordValidationRequest(password, new HashSet&lt;&gt;(Arrays.asList(previousPasswords))));<br><br>        // comment out assertions<br>        //assertEquals(result.isValid(), valid);    <br>        //assertArrayEquals(result.getMessages().toArray(), messages);  <br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rb__fTEMjqfK7bna.png" /></figure><p>After removing the assertions the line coverage goes down to 93%, which is still quite good but useless from a quality assurance perspective. This shows it is very possible to “fake” automated tests in order to “boost” code coverage. This is where <a href="https://en.wikipedia.org/wiki/Mutation_testing">Mutation Testing</a> comes in handy.</p><h4>Mutation Testing</h4><p><a href="https://en.wikipedia.org/wiki/Mutation_testing">Mutation Testing</a> provides a better way to measure the quality of your tests. The idea behind Mutation Testing is to automatically change or mutate code, run the test cases and then check the outcome. The changes that are made to a class are called <em>Mutants</em> as they present a mutated version of the class. A mutant is killed if a test fails, proving that this mutation is catered for by the test suite. If a mutant does not trigger a failing test case, the mutant survives and this indicates that some aspects of the code are not fully tested.</p><p>Java projects mainly use <a href="http://pitest.org/">PIT</a> for Mutation Testing. PIT uses byte manipulation to mutate code. No mutated code is stored hence it does not interfere with the codebase. PIT uses configurable mutators. Some examples of these Mutators include <a href="http://pitest.org/quickstart/mutators/#CONDITIONALS_BOUNDARY">Conditionals Boundary</a> and <a href="http://pitest.org/quickstart/mutators/#NEGATE_CONDITIONALS">Negate Conditionals</a>.</p><p>More Mutators can be found in the <a href="http://pitest.org/quickstart/mutators/">documentation</a>.</p><p><strong>Configuration<br></strong>There are a number of ways to configure PIT, below is one example of how to configure PIT using its Maven Plugin.</p><pre>&lt;plugin&gt;<br>  &lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>  &lt;artifactId&gt;pitest-maven&lt;/artifactId&gt;<br>  &lt;version&gt;1.11.6&lt;/version&gt;<br>  &lt;configuration&gt;<br>      &lt;timestampedReports&gt;false&lt;/timestampedReports&gt;<br>  &lt;/configuration&gt;<br>  &lt;executions&gt;<br>      &lt;execution&gt;<br>          &lt;id&gt;mutation-coverage&lt;/id&gt;<br>          &lt;goals&gt;<br>              &lt;goal&gt;mutationCoverage&lt;/goal&gt;<br>          &lt;/goals&gt;<br>      &lt;/execution&gt;<br>  &lt;/executions&gt;<br>&lt;/plugin&gt;</pre><p>After adding the XML snippet above to the Maven POM file execute the following command and then proceed to open the <em>index.html</em> file under the <em>target/pit-reports</em> folder.</p><pre>mvn clean verify</pre><p>An HTML report is generated for the Mutation Testing execution showing a summary and a high-level package breakdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bjz0yBVTmWk1XFcg-UDqcQ.png" /></figure><p>The high code coverage from the tests without assertions gives a false impression as all 14 mutants survived.</p><p>You can also drill down into class-level detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcbrclXMUf35BviZA6Y74Q.png" /><figcaption>Light pink shows a lack of line coverage, and dark pink shows a lack of mutation coverage.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogJ6Bk-NAYJMuPYh-4OsRw.png" /><figcaption>Light green shows line coverage, and dark green show mutation coverage.</figcaption></figure><p>Roll back the tests to include the original assertions and run the build to generate a new Mutation Test report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-GwRoH06PA9v9xdRj8oMQ.png" /></figure><p>This time all 14 mutants are killed. The high number of mutants killed would most likely indicate that your code is covered by a solid and extensive test suite.</p><p><strong>Things to consider<br></strong>When you have a large test suite it is NOT recommended to run m<em>utation tests</em> as part of your normal build as <em>mutation tests</em> tend to be slow. This is partly due to the fact that for each mutation a separate test run, that is all test cases, is executed. In such a case you can maybe schedule mutation testing to run outside your normal build process at least once a day.</p><h4>Conclusion</h4><p>This post just gives a glimpse of what Mutation Testing is and how it can complement the code coverage toolset that you already have to improve quality assurance.</p><p><em>Originally published at </em><a href="https://awesomaticblog.wordpress.com/2019/03/10/how-good-are-your-tests/"><em>http://awesomaticblog.wordpress.com</em></a><em> on March 10, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0c1ac11b424" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive TDD Kata 2 — OG]]></title>
            <link>https://medium.com/@donaldsiziba/a-comprehensive-tdd-kata-2-og-bbd6f7e81bd?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbd6f7e81bd</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[extreme-programming]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Thu, 21 Feb 2019 20:01:14 GMT</pubDate>
            <atom:updated>2024-04-03T18:52:53.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Comprehensive TDD Kata 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBDDHyp_wJ29zuIHT2DcRw.jpeg" /><figcaption>Image courtesy of iStock.</figcaption></figure><p>This is a continuation of the <a href="https://medium.com/@donaldsiziba/a-comprehensive-tdd-kata-og-8ebfafcddc71?source=friends_link&amp;sk=377e51a24e58bb377d302586d8349632">previous post’s</a> word-for-word and blow-by-blow account of a TDD Kata.</p><p>Your business owner comes back to you with another request. This time they want you to add functionality that checks if a user does not use a password similar to any of their previous passwords.</p><p>This implementation assumes the client application will provide the previous passwords for a given user.</p><p><strong>Solution</strong></p><p><em>Remember: start with a failing test case before writing any implementation code.</em></p><p>Update the Data Transfer Object (DTO) class and the test cases to cater for the previous passwords.</p><pre>public class PasswordValidationRequest {<br>    private final String password;<br>    private final Set&lt;String&gt; previousPasswords;<br><br>    public PasswordValidationRequest(final String password, Set&lt;String&gt; previousPasswords) {<br>        this.password = password;<br>        this.previousPasswords = previousPasswords;<br>    }<br><br>    public String getPassword() {<br>        return password;<br>    }<br><br>    public Set&lt;String&gt; getPreviousPasswords() {<br>        return Collections.unmodifiableSet(previousPasswords);<br>    }<br>}</pre><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>        PasswordValidationResponse result = passwordValidator.apply(new PasswordValidationRequest(password, previousPasswords))<br><br>        then: &quot;the result should be #valid&quot;<br>            result.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            result.messages == messages<br><br>        where:<br>            password           | previousPasswords       || valid | messages<br>            &#39;userp@ssw0rd&#39;     | [] as Set               || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     | [] as Set               || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     | [] as Set               || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     | [] as Set               || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      | [] as Set               || false | [&#39;The password should be at least 12 characters long&#39;]<br>            &#39;User   P@ss w0rd&#39; | [] as Set               || false | [&#39;The password should not have any whitespaces&#39;]<br>            &#39;UserP@ssw0rD&#39;     | [] as Set               || true  | []<br>            &#39;userpasword&#39;      | [] as Set               || false | [&#39;The password should have at least one uppercase character&#39;,&#39;The password should have at least one digit&#39;,&#39;The password should have at least one special character&#39;,&#39;The password should be at least 12 characters long&#39;]<br>            &#39;UserP@ssw0rD&#39;     | [&#39;UserP@ssw0rD&#39;] as Set || false | [&#39;The password should not match any of the previous passwords&#39;]<br>    }<br>}</pre><p>I have included the JUnit test case to make things easy for those who want to code along.</p><pre>@RunWith(Parameterized.class)<br>public class PasswordValidatorTestCase {<br>    @Parameterized.Parameters(name= &quot;{index}: validate({0})&quot;)<br>    public static Collection&lt;Object[]&gt; data() {<br>        return Arrays.asList(new Object[][] {<br>                {&quot;userp@ssw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one uppercase character&quot;}},<br>                {&quot;USERP@SSW0RD&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one lowercase character&quot;}},<br>                {&quot;UserP@ssword&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one digit&quot;}},<br>                {&quot;UserPassw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one special character&quot;}},<br>                {&quot;UserP@sw0rd&quot;, new String[] {}, false, new String[] {&quot;The password should be at least 12 characters long&quot;}},<br>                {&quot;User   P@ss w0rd&quot;, new String[] {}, false, new String[] {&quot;The password should not have any whitespaces&quot;}},<br>                {&quot;UserP@ssw0rD&quot;, new String[] {}, true, new String[] {}},<br>                {&quot;userpasword&quot;, new String[] {}, false, new String[] {&quot;The password should have at least one uppercase character&quot;, &quot;The password should have at least one digit&quot;,<br>                        &quot;The password should have at least one special character&quot;, &quot;The password should be at least 12 characters long&quot;}},<br>                {&quot;UserP@ssw0rD&quot;, new String[] {&quot;UserP@ssw0rD&quot;}, false, new String[] {&quot;The password should not match any of the previous passwords&quot;}}<br>        });<br>    }<br><br>    private String password;<br>    private String[] previousPasswords;<br>    private boolean valid;<br>    private String[] messages;<br><br>    PasswordValidator passwordValidator;<br><br>    public PasswordValidatorTestCase(String password, String[] previousPasswords, boolean valid, String[] messages) {<br>        this.password = password;<br>        this.previousPasswords = previousPasswords;<br>        this.valid = valid;<br>        this.messages = messages;<br>    }<br><br>    @Before<br>    public void setUp() {<br>        passwordValidator = new PasswordValidator();<br>    }<br><br>    @Test<br>    public void validatePassword() {<br>        PasswordValidationResponse result = passwordValidator.apply(new PasswordValidationRequest(password, new HashSet&lt;&gt;(Arrays.asList(previousPasswords))));<br><br>        assertEquals(result.isValid(), valid);<br>        assertArrayEquals(result.getMessages().toArray(), messages);<br>    }<br>}</pre><p>Execute the tests, and as expected the new test case fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-iVX_t201AhosIZypSTLew.png" /><figcaption>Previous passwords failing test case</figcaption></figure><p>The following is a diagram of the current implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*rQji5DxLuauIyDmKGni4lA.png" /><figcaption>Password Validator component diagram</figcaption></figure><p>This updated diagram includes the rule to cater for the previous passwords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*ABHRpJTD3-1tiZSj1EGkVQ.png" /><figcaption>Password Validator component with password history rule</figcaption></figure><p>Below is the implementation of the new rule class.</p><pre>public class PasswordHistoryValidationRule implements ValidationRule {<br>    private final String message;<br><br>    public PasswordHistoryValidationRule(String message) {<br>        this.message = message;<br>    }<br><br><br>    @Override<br>    public String getMessage() {<br>        return this.message;<br>    }<br><br>    @Override<br>    public boolean test(PasswordValidationRequest request) {<br>        return request.getPreviousPasswords().contains(request.getPassword());<br>    }<br>}</pre><p>Now, add this rule to the component class.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;),<br>        new RegexValidationRule(&quot;.*[^a-zA-Z0-9].*&quot;, &quot;The password should have at least one special character&quot;),<br>        new RegexValidationRule(&quot;.{12,}&quot;, &quot;The password should be at least 12 characters long&quot;),<br>        new RegexValidationRule(&quot;\\S+$&quot;, &quot;The password should not have any whitespaces&quot;),<br>        new PasswordHistoryValidationRule(&quot;The password should not match any of the previous passwords&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><p>Execute the test case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xyaqea4k93gMT1zGvkneHw.png" /><figcaption>All test cases fail</figcaption></figure><p>All the test cases fail. I have gone from one test case failing to all the test cases failing! The new rule seems to have thrown a spanner into the works.</p><p>After some digging, I eventually figured that this goes back to the Password Validator component where I <em>negate()</em> the predicate. It makes sense to <em>negate</em> the regex rules but for the password history rule, it doesn’t.</p><p>To fix this, remove the negate in the Password Validator component.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;),<br>        new RegexValidationRule(&quot;.*[^a-zA-Z0-9].*&quot;, &quot;The password should have at least one special character&quot;),<br>        new RegexValidationRule(&quot;.{12,}&quot;, &quot;The password should be at least 12 characters long&quot;),<br>        new RegexValidationRule(&quot;\\S+$&quot;, &quot;The password should not have any whitespaces&quot;),<br>        new PasswordHistoryValidationRule(&quot;The password should not match any of the previous passwords&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><p>And then include the <em>Logical not </em>operator in the <em>RegexValidationRule </em>class.</p><pre>public class RegexValidationRule implements ValidationRule {<br>    private final String regex;<br>    private final String message;<br><br>    public RegexValidationRule(final String regex, final String message) {<br>        this.regex = regex;<br>        this.message = message;<br>    }<br><br>    @Override<br>    public String getMessage() {<br>        return message;<br>    }<br><br>    @Override<br>    public boolean test(PasswordValidationRequest request) {<br>        return !request.getPassword().matches(regex);<br>    }<br>}</pre><p>Run the tests again. This time all the tests pass, including the password history test case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LP0w9vQOprZLJ7pNQdj2BQ.png" /><figcaption>All test cases pass</figcaption></figure><p>That’s a wrap for this TDD Kata. Thank you for following along.</p><p><a href="https://github.com/donaldsiziba/password-validator">GitHub - donaldsiziba/password-validator</a></p><p><em>Originally published at </em><a href="https://awesomaticblog.wordpress.com/2019/02/21/password-validator-kata-2/"><em>http://awesomaticblog.wordpress.com</em></a><em> on February 21, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbd6f7e81bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive TDD Kata — OG]]></title>
            <link>https://medium.com/@donaldsiziba/a-comprehensive-tdd-kata-og-8ebfafcddc71?source=rss-15a421216220------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ebfafcddc71</guid>
            <category><![CDATA[extreme-programming]]></category>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Donald Siziba]]></dc:creator>
            <pubDate>Sat, 26 Jan 2019 13:14:12 GMT</pubDate>
            <atom:updated>2025-08-29T05:10:04.837Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Comprehensive TDD Kata</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBDDHyp_wJ29zuIHT2DcRw.jpeg" /><figcaption>Image courtesy of iStock.</figcaption></figure><p>One of the most effective ways to master TDD is through the use of <a href="https://medium.com/javarevisited/tdd-katas-5e897300a887#:~:text=TDD(Test%20Driven%20Development)%20Katas,that%27s%20why%20we%20practice%20Katas.">Katas</a>[1]. The following is a comprehensive TDD Kata that will give you an idea of what TDD is all about. Feel free to check out the <a href="https://github.com/donaldsiziba/password-validator-starter">starter project</a> and code along so you can master the TDD workflow and thought pattern.</p><p><a href="https://github.com/donaldsiziba/password-validator-starter">GitHub - donaldsiziba/password-validator-starter</a></p><p>I hope you will realise most if not all of the attributes, that I mentioned in my <a href="https://medium.com/@donaldsiziba/does-anyone-ever-use-test-driven-development-og-e34824d8f2b5?source=friends_link&amp;sk=e3489eead8b4a24d62b2f4c62e7bf160">previous article</a>, that makes TDD worth a try.</p><p>I apologise for the lengthy article but please bare with me as I try to bring across TDD concepts.</p><p><strong>Introduction</strong></p><p>As a measure to beef up application security, your business owner has asked you to implement a password compliance component that satisfies the criteria detailed below.</p><p><strong>Acceptance Criteria</strong></p><ol><li>The password should have at least one uppercase character</li><li>The password should have at least one lowercase character</li><li>The password should have at least one digit</li><li>The password should have at least one special character</li><li>The password should be at least 12 characters long</li><li>The password should not have any whitespaces</li></ol><p>If a user enters a non-compliant password, the component should return a message notifying the user of what is wrong with the given password. The returned message should be similar to the corresponding description in the acceptance criteria.</p><p><strong>HINT:</strong></p><ul><li>This is the complete list of ASCII Special Characters — !”#$%&amp;’()*+,-.\:;&lt;=&gt;?@[/]^_`{|}~</li></ul><p>This can be represented by the following regular expression <em>[^a-zA-Z0–9]</em></p><h4>Solution</h4><p>The basic premise of TDD is that you write a test before writing the code that actually provides the implementation, and then you refactor that implementation as needed.</p><h4>The TDD 3-phase Cycle</h4><p>When TDD practitioners need to implement a feature, they first write a failing test that describes, or specifies, that feature. Next, they write just enough code to make the test pass. Finally, they refactor the code to help ensure that it will be easy to maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zokl62wPOGfLQk7oLjLm5w.png" /><figcaption>TDD 3-phase cycle. [2]</figcaption></figure><p>Let’s see how TDD techniques can be applied to fulfill the abovementioned requirements. The solution below is coded in Java. The Unit tests are implemented in JUnit and Spock.</p><p>I use <a href="http://spockframework.org/">Spock</a> to illustrate my test cases. Spock is a comprehensive testing framework for Groovy and Java applications. I prefer Spock because of its expressive syntax. For those more familiar with JUnit, please refer to the <a href="https://github.com/donaldsiziba/password-validator">source code</a> for the Java test cases.</p><h4>Password Validator Component</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*pnJgeiMlTm4C4Jlbwhqveg.png" /><figcaption>Password Validator component</figcaption></figure><p>The Password Validator component is available in the <a href="https://github.com/donaldsiziba/password-validator-starter">starter project</a> with the <em>happy day scenario</em> as the default implementation.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>@Override   <br>public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>      return new PasswordValidationResponse(true, new ArrayList&lt;&gt;());<br>   }<br>}</pre><p><em>NOTE</em>: I have simplified the implementation by including the Data Transfer Objects (DTOs) in this project. Best practice would dictate that the DTOs are auto-generated in a separate project and included as a dependency in the client project.</p><h4>The First Test Criteria</h4><p><strong>The password should have at least one uppercase character</strong></p><p>Change the <em>PasswordValidatorTest </em>in the <a href="https://github.com/donaldsiziba/password-validator-starter">starter project</a> and write the first test case as shown in the code snippet below.</p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    def &quot;password should have at least one uppercase character&quot;() {<br>        given: &quot;the following password&quot;<br>            String password = &quot;userp@ssw0rd&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the password should be invalid&quot;<br>            response.valid == false<br><br>        and: &quot;the user should be notified that the password has no uppercase character&quot;<br>            response.messages == [&quot;The password should have at least one uppercase character&quot;]<br>    }<br>}</pre><p>Executing the test cases at this stage, as expected, will result in a failing test case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIwsZzbtEbzKb9xpIxoHEA.png" /><figcaption>No uppercase failing test case</figcaption></figure><p><strong>No Uppercase Implementation</strong></p><p>Next, write the least amount of code to make the test case pass.</p><p>The solution involves pattern-matching string expressions so it makes sense to use <a href="https://en.wikipedia.org/wiki/Regular_expression">Regular Expressions</a>.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt;  {<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = new ArrayList&lt;&gt;();<br>        boolean isUppercaseCharacterPresent = request.getPassword().matches(&quot;.*[A-Z].*&quot;);<br>        if(!isUppercaseCharacterPresent) {<br>            messages.add(&quot;The password should have at least one uppercase character&quot;);<br>        }<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><p>With the implementation above, executing the test case results in a passing test case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-71lSAlNpvTn7iTFdEjceA.png" /><figcaption>No uppercase passing test case</figcaption></figure><p><strong>Refactor No Uppercase Implementation</strong></p><p>The <em>isUppercaseCharacterPresent</em> variable can be extracted into a method.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt;  {<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = new ArrayList&lt;&gt;();<br>        if(!isUppercaseCharacterPresent(request)) {<br>            messages.add(&quot;The password should have at least one uppercase character&quot;);<br>        }<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br><br>    private boolean isUppercaseCharacterPresent(PasswordValidationRequest request) {<br>        return request.getPassword().matches(&quot;.*[A-Z].*&quot;);<br>    }<br>}</pre><p><strong>NOTE: </strong>Run the test to make sure it still passes.</p><h4>The Second Test Criteria</h4><p><strong>The password should have at least one lowercase character</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    def &quot;password should have at least one lowercase character&quot;() {<br>        given: &quot;the following password&quot;<br>            String password = &quot;USERP@SSW0RD&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the password should be invalid&quot;<br>            response.valid == false<br><br>        and: &quot;the user should be notified that the password has no lowercase character&quot;<br>            response.messages == [&quot;The password should have at least one lowercase character&quot;]<br>    }<br><br>    def &quot;password should have at least one uppercase character&quot;() {<br>        given: &quot;the following password&quot;<br>            String password = &quot;userp@ssw0rd&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the password should be invalid&quot;<br>            response.valid == false<br><br>        and: &quot;the user should be notified that the password has no uppercase character&quot;<br>            response.messages == [&quot;The password should have at least one uppercase character&quot;]<br>    }<br>}</pre><p>Do you notice the code duplication from the 2 test cases? This will be addressed later using the <strong>Parameterized Test Pattern</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzZxkjKj2ZFaR0So9Z3big.png" /><figcaption>No lowercase failing test case</figcaption></figure><p><strong>No Lower Case Implementation</strong></p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt;  {<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = new ArrayList&lt;&gt;();<br>        if(!isUppercaseCharacterPresent(request)) {<br>            messages.add(&quot;The password should have at least one uppercase character&quot;);<br>        }<br>        if(!isLowerCaseCharacterPresent(request)) {<br>            messages.add(&quot;The password should have at least one lowercase character&quot;);<br>        }<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br><br>    private boolean isUppercaseCharacterPresent(PasswordValidationResquest request) {<br>        return request.getPassword().matches(&quot;.*[A-Z].*&quot;);<br>    }<br><br>    private boolean isLowerCaseCharacterPresent(PasswordValidationRequest request) {<br>        return request.getPassword().matches(&quot;.*[a-z].*&quot;);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLGGafxQx6ojaTMSVtu2Vg.png" /><figcaption>No lowercase passing test case</figcaption></figure><h4>Back to the Drawing Board</h4><p>Take note of the code duplication in the <em>isUpperCasePresent</em> and <em>isLowerCasePresent</em> methods. This is not what you want in your code. It breaks one of the <a href="https://dzone.com/articles/4-rules-simple-design">Four Rules of Simple Design</a><br><em>Simple Code</em> is defined by the following traits:</p><ol><li>Passes all the tests</li><li>Clear, Expressive &amp; Consistent</li><li>Contains No Duplication aka DRY (Don’t Repeat Yourself)</li><li>A minimal number of classes, methods, and other moving Parts</li></ol><p>Looking at these 2 methods they take in a parameter, perform an action on it, and return <em>true</em> or <em>false</em> depending on the values in the given parameter.</p><p>Java 8 comes with several new functional interfaces in the package <em>java.util.function</em>. One of the interfaces is a <em>Predicate</em>. This interface returns a boolean value based on an input of type <strong>T</strong>.</p><pre>package java.util.function;<br><br>@FunctionalInterface<br>public interface Predicate {<br> boolean test(T t);<br>}</pre><p>A <em>Predicate</em> can, therefore, be used as the assignment target for a <a href="https://howtodoinjava.com/java-8/complete-lambda-expressions-tutorial-in-java/">lambda expression</a>.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private Predicate&lt;PasswordValidationRequest&gt; isUppercaseCharacterPresent = request -&gt; request.getPassword().matches(&quot;.*[A-Z].*&quot;);<br>    private Predicate&lt;PasswordValidationRequest&gt; isLowerCaseCharacterPresent = request -&gt; request.getPassword().matches(&quot;.*[a-z].*&quot;);<br><br>    public PassowrdValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = new ArrayList&lt;&gt;();<br>        if(!isUppercaseCharacterPresent.test(request)) {<br>            messages.add(&quot;The password should have at least one uppercase character&quot;);<br>        }<br>        if(!isLowerCaseCharacterPresent.test(request)) {<br>            messages.add(&quot;The password should have at least one lowercase character&quot;);<br>        }<br>        return new PasswordValidationRespons(messages.isEmpty(), messages);<br>    }<br>}</pre><p><strong>NOTE:</strong> Run the tests and make sure they still pass.</p><p>Let’s update the PasswordValidator component diagram to represent the current implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*jArcI1OfA8HV-F45LvtwWQ.png" /><figcaption>Password Validator component update</figcaption></figure><h4>Separate what varies from what stays the same</h4><p>The 2 <em>Predicates </em>can be <em>pushed out</em> and the variables in question will be abstracted into a collection on the <em>PasswordValidator</em> component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*iuf-1gJUa-9d27JX_mK59w.png" /><figcaption>Separate what varies from what stays the same</figcaption></figure><p>This design needs to be refined before the code gets to a workable state.</p><p>To cater for the <em>Regular Expressions</em> and <em>Notification Messages</em>, there is a need for a class that derives from a <em>Predicate</em> that will take into consideration both of these concerns. This is all addressed in the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*_cloeyKp0cOSJQLtfgZ8zw.png" /><figcaption>Password Validator component refined design</figcaption></figure><p>Let’s go ahead and update the code.</p><h4>Validation Rule Interface</h4><pre>public interface ValidationRule extends Predicate&lt;PasswordValidationRequest&gt; {<br>    String getMessage();<br>}</pre><h4>Regex Validation Rule Class</h4><pre>public class RegexValidationRule implements ValidationRule {<br>    private final String regex;<br>    private final String message;</pre><h4>Regex Validation Rule Class</h4><pre>public class RegexValidationRule implements ValidationRule {<br>    private final String regex;<br>    private final String message;<br><br>    public RegexValidationRule(final String regex, final String message) {<br>        this.regex = regex;<br>        this.message = message;<br>    }<br><br>    @Override<br>    public String getMessage() {<br>        return message;<br>    }<br><br>    @Override<br>    public boolean test(PasswordValidationRequest request) {<br>        return request.getPassword().matches(regex);<br>    }<br>}</pre><h4>Password Validator Component</h4><p><em>NOTE</em>: For simplicity, the rules are hard-coded into the password validation component. In an actual implementation, it is best practice to provide the rules as configuration. I will leave that as an exercise for the reader.</p><pre>public class PasswordValidator implements Function&lt;PasswordValidatonRequest, PasswordValidationResponse&gt; {<br>  private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;)<br>    );<br><br>  @Override<br>  public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>    List&lt;String&gt; messages = new ArrayList&lt;&gt;();<br>    for(ValidationRule rule : rules) {<br>      if(!rule.test(request)) {<br>        messages.add(rule.getMessage());<br>      }<br>    }<br>    return new PasswordValidationResponse(messages.isEmpty(), messages);<br>  }   <br>}</pre><p><strong>NOTE:</strong> Run the tests and make sure they still pass.</p><h4>Refactor the Password Validator Implementation</h4><p>Use the following Java 8 idioms to refactor the password validator component:</p><ol><li><a href="https://docs.oracle.com/javase/tutorial/collections/streams/index.html">Streams</a></li></ol><p><a href="https://docs.oracle.com/javase/tutorial/collections/streams/index.html">2. Aggregation Operations</a></p><ul><li><a href="https://docs.oracle.com/javase/tutorial/collections/streams/">Filter</a></li><li><a href="https://docs.oracle.com/javase/tutorial/collections/streams/">Map</a></li><li><a href="https://docs.oracle.com/javase/tutorial/collections/streams/reduction.html#collect">Collect</a></li></ul><p><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html">3. Method Reference</a></p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><p><strong>NOTE:</strong> Run the tests and make sure they still pass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7YgO6nAV_6sUGQhEZBw69w.png" /><figcaption>No lowercase passing test case</figcaption></figure><h4>Parameterized Test Pattern</h4><p>A <a href="https://en.wikipedia.org/wiki/Unit_testing#Parameterized_unit_testing">Parameterized Test</a> offers a way to reuse the same test logic for multiple test scenarios. This is a perfect pattern to use whenever there is <em>Test Code Duplication</em> as a result of several tests implementing the same test code but with slightly different data.</p><p><strong>Tabular Data Input with Spock</strong></p><p>Spock enables you to directly embed a table as-is inside your Groovy code. The following code snippet shows how this is done in the current context.</p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The paassword should have at least one lowercase character&#39;]<br>    }<br>}</pre><p>The key point of this unit test is the <strong>where:</strong> label (in addition to the usual <strong>given-then-when</strong> labels) that holds a definition of all inputs/outputs used in the other blocks. In the where: block of this Spock test, I copied verbatim the password validation scenarios into the table. The <strong>||</strong> notation is used to split the inputs from the outputs. The <strong>@Unroll</strong> annotation “unrolls” the test scenarios and presents them to the test runner as individual tests.</p><p><strong>NOTE:</strong> Run the tests and make sure they still pass.</p><p>After this slight but necessary detour, I can now proceed and define the remainder of the test scenarios and their corresponding implementations. It should be downhill from here.</p><h4>The Third Test Criteria</h4><p><strong>The password should have at least one digit</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ZoCifWti5s17MtGXjdJnw.png" /><figcaption>No digit failing test case</figcaption></figure><p><strong>No Digit Implementation</strong></p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OpGm03e37iepN1hYaeyyw.png" /><figcaption>No digit passing test case</figcaption></figure><h4>The Fourth Test Criteria</h4><p><strong>The password should have at least one special character</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     || false | [&#39;The password should have at least one special character&#39;]<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eA1_F_n3ef1TZmcA-_v1SA.png" /><figcaption>No special character failing test case</figcaption></figure><p><strong>No Special Character Implementation</strong></p><pre>public class PasswordValidator implements Fuction&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;),<br>        new RegexValidationRule(&quot;.*[^a-zA-Z0-9].*&quot;, &quot;The password should have at least one special character&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BmuRPCHFtKTdgRCTRnYJw.png" /><figcaption>No special character passing test case</figcaption></figure><h4>The Fifth Test Criteria</h4><p><strong>The password should at least be 12 characters long</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      || false | [&#39;The password should be at least 12 characters long&#39;]<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xKl_4z_Do8Evc2BPWvp2Q.png" /><figcaption>Password length failing test case</figcaption></figure><p><strong>Password Length Implementation</strong></p><pre>public class PasswordValidator implements Fuction&lt;PasswordValidationRequest, PasswordValidationResponse&gt;{<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;),<br>        new RegexValidationRule(&quot;.*[^a-zA-Z0-9].*&quot;, &quot;The password should have at least one special character&quot;),<br>        new RegexValidationRule(&quot;.{12,}&quot;, &quot;The password should be at least 12 characters long&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0l4Ous0fDoTHQgq7lX-7w.png" /><figcaption>Password length passing test case</figcaption></figure><h4>The Sixth Test Criteria</h4><p><strong>The password should NOT have any whitespace</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      || false | [&#39;The password should be at least 12 characters long&#39;]<br>            &#39;User   P@ss w0rd&#39; || false | [&#39;The password should not have any whitespaces&#39;]<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwj9zf3vS4NJhyfH-gb2Hw.png" /><figcaption>Password with whitespace failing test case</figcaption></figure><p><strong>Password with Whitespace Implementation</strong></p><pre>public class PasswordValidator implements Function&lt;PasswordValidationRequest, PasswordValidationResponse&gt; {<br>    private List&lt;ValidationRule&gt; rules = List.of(<br>        new RegexValidationRule(&quot;.*[A-Z].*&quot;, &quot;The password should have at least one uppercase character&quot;),<br>        new RegexValidationRule(&quot;.*[a-z].*&quot;, &quot;The password should have at least one lowercase character&quot;),<br>        new RegexValidationRule(&quot;.*[0-9].*&quot;, &quot;The password should have at least one digit&quot;),<br>        new RegexValidationRule(&quot;.*[^a-zA-Z0-9].*&quot;, &quot;The password should have at least one special character&quot;),<br>        new RegexValidationRule(&quot;.{12,}&quot;, &quot;The password should be at least 12 characters long&quot;),<br>        new RegexValidationRule(&quot;\\S+$&quot;, &quot;The password should not have any whitespaces&quot;)<br>    );<br><br>    @Override<br>    public PasswordValidationResponse apply(PasswordValidationRequest request) {<br>        List&lt;String&gt; messages = rules.stream().filter(rule -&gt; rule.negate().test(request))<br>                                              .map(ValidationRule::getMessage)<br>                                              .collect(toCollection(ArrayList::new));<br>        return new PasswordValidationResponse(messages.isEmpty(), messages);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*smQtnkfhUaVjYsgMHdUldA.png" /><figcaption>Password with whitespace passing test case</figcaption></figure><h4>The Seventh Test Criteria</h4><p><strong>Happy Day Scenario</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      || false | [&#39;The password should be at least 12 characters long&#39;]<br>            &#39;User   P@ss w0rd&#39; || false | [&#39;The password should not have any whitespaces&#39;]<br>            &#39;UserP@ssw0rD&#39;     || true  | []<br>    }<br>}</pre><p>Because the password meets all the previous criteria, the test cases pass without the need to implement any code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0EjZpmJrhjklbeDJgfsA1g.png" /><figcaption>Happy day scenario</figcaption></figure><h4>The Eighth Scenario</h4><p><strong>Password violates multiple of the Password Compliance Rules</strong></p><pre>class PasswordValidatorTest extends Specification {<br>    PasswordValidator passwordValidator<br><br>    def setup() {<br>        passwordValidator = new PasswordValidator()<br>    }<br><br>    @Unroll<br>    def &quot;validate the following password - #password&quot;() {<br>        given: &quot;the following password: #password&quot;<br><br>        when: &quot;the password is validated&quot;<br>            PasswordValidationResponse response = passwordValidator.apply(new PasswordValidationRequest(password))<br><br>        then: &quot;the result should be #valid&quot;<br>            response.valid == valid<br><br>        and: &quot;the following message should be returned to the user: #messages&quot;<br>            response.messages == messages<br><br>        where:<br>            password           || valid | messages<br>            &#39;userp@ssw0rd&#39;     || false | [&#39;The password should have at least one uppercase character&#39;]<br>            &#39;USERP@SSW0RD&#39;     || false | [&#39;The password should have at least one lowercase character&#39;]<br>            &#39;UserP@ssword&#39;     || false | [&#39;The password should have at least one digit&#39;]<br>            &#39;UserPassw0rd&#39;     || false | [&#39;The password should have at least one special character&#39;]<br>            &#39;UserP@sw0rd&#39;      || false | [&#39;The password should be at least 12 characters long&#39;]<br>            &#39;User   P@ss w0rd&#39; || false | [&#39;The password should not have any whitespaces&#39;]<br>            &#39;UserP@ssw0rD&#39;     || true  | []<br>            &#39;userpasword&#39;      || false | [&#39;The password should have at least one uppercase character&#39;,&#39;The password should have at least one digit&#39;,&#39;The password should have at least one special character&#39;,&#39;The password should be at least 12 characters long&#39;]<br>    }</pre><p>There is no need to implement any code as the implementation already caters for these scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWfF55bTBtsl2poopeyz5w.png" /><figcaption>Password with multiple violation test case</figcaption></figure><p>Thank you for taking the time to follow along. This has been an in-depth look at TDD in practice. I hope this gives insight into how TDD can be applied in day-to-day development.</p><p><a href="https://github.com/donaldsiziba/password-validator">GitHub - donaldsiziba/password-validator</a></p><p><strong>References</strong></p><p>[1] <a href="https://medium.com/javarevisited/tdd-katas-5e897300a887#:~:text=TDD(Test%20Driven%20Development)%20Katas,that%27s%20why%20we%20practice%20Katas.">TDD Katas</a> — JAVING</p><p>[2] BDD in Action, Manning Publication Co, 2015 — John Ferguson Smart</p><p><em>Originally published at </em><a href="https://awesomaticblog.wordpress.com/2019/01/26/password-validator-kata/"><em>http://awesomaticblog.wordpress.com</em></a><em> on January 26, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ebfafcddc71" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>