Published in Better Programming·Mar 16Member-onlyStory Slicing — a Practical GuideSome stories may be challenging to split but with careful analysis and effort, they can often be broken down into smaller, more consumable pieces. Let me tell you how. — Why split? Make sure you read Part I first: The benefits of breaking down user stories How breaking down problems into smaller, more consumable pieces can improve predictability, feedback cycles, and…medium.com When to split? Should a story always be split? My rule of thumb is to split always; not because it’s big but because it can be independently delivered and still bring value to the users and provide learnings to the team. The benefits of splitting greatly…Software Engineering7 min readSoftware Engineering7 min read
Published in Better Programming·Feb 8Member-onlyMisconceptions About Domain-Centric ArchitecturesDiscussing the benefits of segregating business and technical code and tackling common misconceptions. — ‘Domain’ is short for ‘business domain.’ Here, business is used in a broad sense to refer to the real-world problem the app is set out to solve (e.g., a to-do list, an online shop, or a game).Clean Architecture8 min readClean Architecture8 min read
Published in CodeX·Nov 22, 2022Deploying a Kotlin app to Railway (a Slack bot)We will deploy a “Hello world” Slack bot to Railway, sourced from GitHub (written in Kotlin). — Now that Heroku has no free plan anymore, it’s time to find a new home for our experimental JVM apps. Railway does the job. 1. Codebase Create a new Kotlin project. If you haven’t yet made git init, you should do it now. Make sure you have a .gitignore file at the…Railway3 min readRailway3 min read
Published in CodeX·Nov 7, 2022The Testing Library meets SeleniumThe Testing Library enables testing as a user. It’s available for multiple JavaScript frameworks (e.g. React, Vue, Cypress). I realized it was possible and valuable to bring it to Kotlin’s Selenium. — The more your tests resemble the way your software is used, the more confidence they can give you. (Kent C. Dodds) What I developed a set of custom Selenium locators (e.g. ByRole, ByText) that wrap the corresponding Testing Library queries (specifically, the DOM Testing Library):Automated Testing6 min readAutomated Testing6 min read
Oct 14, 2022Selenium waitsWaiting for things to happen can be a source of slow and flaky tests. Let’s learn how to properly wait with Selenium (Kotlin). — Implicit wait In Selenium, you can query a page with: // wait until it's found, else throw a timeout exception driver.findElement(By.id("4-door")) // wait until at least one element is found, else return empty list when the the time out is reached driver.findElements(By.tagName("mat-option"))Selenium4 min readSelenium4 min read
Published in CodeX·Oct 4, 2022Member-onlyA testing strategy for a domain-centric architecture (e.g. hexagonal)I’ll propose a testing strategy for the hexagonal architecture. — Hexagonal architecture The hexagonal architecture and the clean architecture are domain-centric architectural patterns. They’re powerful and adaptable to your needs; even simple apps like command-line tools benefit from centralizing the domain (to separate the I/O from the actual algorithm). Here’s what you need to know: The main principle is that the app…Hexagonal Architecture11 min readHexagonal Architecture11 min read
Published in CodeX·Sep 6, 2022Member-onlyA vertical testing strategyOne of the goals of automated testing is to support you while refactoring, which is a continuous task. Tests should not be in the way. Let’s see how. — 📝 I’ll use the Arrange; Act; Assert terms (the same as Given; When; Then), which is the way tests should be split. A flawed strategy I often see codebases that rely on low-level unit tests to test everything; there are just a few high-level tests for happy cases. I think this derives from…Automated Testing12 min readAutomated Testing12 min read
Published in CodeX·Aug 31, 2022Member-onlyDecoupling tests from implementation detailsOne of the goals of automated testing is to support refactoring but many times, they get in the way. Tests should aim to define what is intended (behavior); not how it’s implemented (details). — Refactoring is a continuous task so we should reduce the exposure to details. Also, tests should not hold us back when evolving the architecture. A good test suite enables coding to be fun. Write your tests in such a way that as many implementation details as possible could be changed…Automated Testing7 min readAutomated Testing7 min read
Published in CodeX·Aug 24, 2022Member-onlyDecoupling tests from APIsChanging interfaces (e.g. API web handlers, queue event handlers, web pages) is common and can impact many tests. How can we decouple them from those changes? — Ideally, when refactoring, we don’t want to update any tests. Besides the refactoring pain, think about the verbosity of making HTTP calls or resorting to HTML page selectors in the tests. Also, consider the negative impact on tests acting as documentation (one of the testing goals).Automated Testing5 min readAutomated Testing5 min read
Published in CodeX·Jun 16, 2022Accepting a payment using Stripe (Kotlin/Javalin)Stripe is a cloud-based service that enables charging customers for your products or services. With Stripe API, you don’t manage sensitive information like credit cards. Let’s learn how to use it. — 1. Setup Register a Stripe account if you don’t own one. Create a new Kotlin project. 2. Web handlers Add Javalin (web framework) and Stripe client to your build.gradle.kts dependencies: implementation(“com.stripe:stripe-java:20.+”) implementation(“org.slf4j:slf4j-simple:1.+”) implementation(“io.javalin:javalin:4.+”)Stripe3 min readStripe3 min read