<?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 Martin Mička on Medium]]></title>
        <description><![CDATA[Stories by Martin Mička on Medium]]></description>
        <link>https://medium.com/@martinmicka?source=rss-a899542c33c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Eqty2s7AK_oMw3vkd1Yr3A@2x.jpeg</url>
            <title>Stories by Martin Mička on Medium</title>
            <link>https://medium.com/@martinmicka?source=rss-a899542c33c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:47:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@martinmicka/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[Finding the 80% Line in Engineering]]></title>
            <link>https://martinmicka.medium.com/finding-the-80-line-in-engineering-84a98a51b880?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/84a98a51b880</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 08:11:21 GMT</pubDate>
            <atom:updated>2025-10-16T08:11:21.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mn7x5LN79t7AnaMt" /><figcaption>Photo by <a href="https://unsplash.com/@alain_pham?utm_source=medium&amp;utm_medium=referral">Alain Pham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Early in my career, I believed everything we built had to be perfect. Clean code, every edge case handled, no compromises. It felt like the “right” way to engineer. But I learned the hard way: in software, things will never — and I mean never — be 100% right. You can get to 80% in a few days. The remaining 20% — the polish, the edge cases, the extra patterns — can take weeks or months. That last mile rarely aligns with business goals, timelines, or the messy reality of how products are used. Chasing it is how you burn time, lose runway, and end up with “development hell.” The real skill is knowing where to draw the line: solid enough to ship, but not sunk in perfection. That’s what I call the <strong>80% line.</strong></p><p>Finding the line is a mix of gut, experience, and opposition. My 80% might not be the same as sales’ 80%. That tension is healthy — it forces clarity. For me, the signal often shows up in <strong>complexity.</strong> If we’re nailing down the basics and the feature is robust enough to stand, we’re in the sweet spot. If the complexity curve starts to spike — endless edge cases, cascading dependencies, theoretical scenarios — that’s where I stop.</p><p>Prototypes are the exception, but even there I tread carefully. Too many times I’ve seen a “throwaway demo” quietly morph into production code, dragging all its shortcuts into the future. Unless it’s crystal clear that the prototype will be rebuilt, it’s safer to aim for 80% robustness from the start.</p><p>The truth is, assumptions almost always diverge from reality. Users behave differently. Markets shift. Features evolve in directions we didn’t predict. That’s why chasing 100% from day one is sunk cost.</p><p>I’ve seen teams spiral into perfection mode. On the surface, it looks like craftsmanship. Underneath, it breeds tension. Business stakeholders don’t need 100% — they need something in customers’ hands to validate. If engineers keep perfecting, it leads to nervousness, then frustration. Eventually, it becomes <strong>development hell</strong> — polishing for the sake of polish. The result: features that never ship, products that stay in the oven too long, and companies that run out of runway. Startups, especially, don’t die because the code wasn’t perfect. They die because the product never left the building. Of course, you can also fall the other way. Ship too rough — 50% or 60% — and you risk user pain, reputation damage, or tech debt that piles up faster than you can clean it.</p><p>The way to avoid that is to build safety nets around your 80%:</p><ul><li><strong>Validate the idea.</strong> Don’t just ship because someone thought it sounded good.</li><li><strong>Run QA.</strong> A simple smoke test beats blind hope.</li><li><strong>Dogfood it.</strong> Be your own user before asking customers to be.</li><li><strong>Roll out smart.</strong> Start with alpha or beta users, or canary releases. Don’t blast everyone at once.</li></ul><p>With these in place, you can confidently stop at 80%. You’ll catch the rough edges before they hit the wider market.</p><h3>Making the 80% Mindset Real</h3><p>Explaining the 80% mindset to engineers is often harder than practicing it myself. Many still cling to the idea that code should be flawless. The only way to break that is with business context.</p><p>I keep it real: <em>“This feature gets us to market in 6 months if we stop at 80%. It’ll take 15 months if we chase 100%. Those 9 months are pure expense — and we don’t even know yet if the feature will land.”</em></p><p>Engineers are clever. They get it when you frame it in terms of cost, risk, and uncertainty. The problem in many companies is that developers are kept far from the business, so they never see the trade-offs. I’ve found that once people share the responsibility, they naturally adapt. Nobody wants to sink the ship — especially if they share in the upside when it floats. Learning to find the 80% line changed how I lead. It pushed me to challenge my own technical lens — to resist over-engineering, and to teach my colleagues the same.</p><p>But it’s not just about code. Perfectionism creeps into product roadmaps, business plans, even operations. Nobody is immune. That’s why my default posture as a leader is to <strong>challenge, challenge, challenge.</strong> Doubt assumptions. Validate decisions. Ask outsiders for perspective when needed. Sometimes I even ask: <em>what if we only did 40% now, and another 40% later?</em> Breaking delivery into smaller cycles forces us to stay lean. Ship the minimum viable version, see how it lands, and then reinvest where it proves its worth. The 80% line isn’t a fixed threshold. It’s a mindset of balance: strong enough to stand, light enough to adapt.</p><p>For startups and small-scale companies this might even be on make it or break it level — investing too much into something that doesn’t need 100% may be an unwise spend of investment. I’d personally be more careful in this space, as money is more vulnerable and may be used on other important things. For bigger organizations, I’d aim for 80% too. They can afford to spend a bit more for sure, but do they need to? You can lose a lot of money on just a few bad gambles. Getting a landing done well is important in all settings.</p><p>Today, I consciously ask myself “is this enough?” That framing is sharper than asking if something is 80%. Enough to ship, enough to test, enough to learn. Everything above that is a bonus. Progress comes from consistency, not perfection. That mindset keeps me grounded and helps me keep the team grounded too.</p><p>Software will never be 100% right. The question is whether it’s right enough to move forward.</p><p>Perfection is comforting for engineers, but it’s deadly for companies. Shipping too rough is risky, but manageable with the right safeguards. The sweet spot — the 80% line — is where learning happens, where products reach customers, and where companies stay alive long enough to grow.</p><p>That’s the lesson I had to unlearn as an engineer, and relearn as a leader.</p><p>This article was originally published on <a href="https://martinmicka.me/">martinmicka.me</a>.</p><p>I write about engineering leadership, product execution, and the mindset behind building things that matter. If you want more like this in your inbox once a month, <a href="https://martinmicka.me/#/portal/signup/free">join my newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84a98a51b880" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Chaos to Clarity: Using Design Patterns to Tame Complexity]]></title>
            <link>https://medium.com/codex/from-chaos-to-clarity-using-design-patterns-to-tame-complexity-43eaa4077745?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/43eaa4077745</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 08:11:48 GMT</pubDate>
            <atom:updated>2025-09-25T12:04:57.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M0X0y-RD_eGxaxtd" /><figcaption>Photo by <a href="https://unsplash.com/@xavi_cabrera?utm_source=medium&amp;utm_medium=referral">Xavi Cabrera</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One thing I truly value in development teams is a solid grasp of design patterns. In my opinion, thorough knowledge of these patterns — and, more importantly, having the insight to pick the right one at the right time, along with other key skills — sets a senior engineer apart from a mid-level one.</p><p>When a project starts stretching beyond its original scope, keeping the code from sliding into chaos becomes one of the biggest hurdles. It’s like a town springing up overnight with no planning — streets that lead nowhere, buildings crammed into awkward spaces, and power lines twisted into a messy knot. That’s what an unstructured codebase feels like. Design patterns work as the town’s master plan: they break big problems into smaller, reusable parts, provide tried-and-true solutions for common challenges, and give the team a shared structure to follow. Whether it’s object creation, dependency handling, event wiring, or swapping behaviors on the fly, patterns help the code stay organized, clear, and adaptable as new requirements come in.</p><h3>Why Design Patterns Matter</h3><p><strong>Solving recurrent problems with proven solutions </strong>— instead of reinventing the wheel, design patterns help address common challenges in everyday software engineering. For example, when dealing with configurable object creation or flexible behavior swapping, patterns like Factory or Strategy can be applied. This allows the focus to remain on delivering features that matter, rather than spending time debugging edge cases or patching the code with quick fixes.</p><p><strong>Communication of complex ideas </strong>— design patterns are well thought out and documented. Once a team adopts them, they also become a shared vocabulary that speeds up communication, code reviews, and design discussions. A simple statement like “this component is an Observer” instantly conveys intent and structure.</p><p><strong>Boost maintainability and readability </strong>— following a common structure makes the code instantly recognizable to team members. The intent is clear: factories create, adapters translate, and so on — no guessing required.</p><p><strong>Enable scalability and flexibility </strong>— requirements change over time. Patterns such as Chain of Responsibility or Strategy allow new behaviors to be added without rewriting existing components. This is especially useful for practical enhancements, like introducing a new payment method or enabling social login.</p><p><strong>Promote best practices and consistency </strong>— when the team uses a consistent set of solutions, the codebase remains cohesive. Similar problems are solved in similar ways, reducing cognitive load and preventing ad-hoc sprawl. These patterns also encourage principles like SOLID and DRY, which are widely regarded as industry best practices.</p><h3>Beyond the Usual Suspects — Patterns with Real Impact</h3><p>Design patterns are all around us — they show up in our favorite libraries and frameworks. I’m not going to cover them at a surface level — there is a lot of content on that topic on the Internet already. Instead, I’ll focus on three patterns that tend to be overlooked but can be incredibly powerful in the right scenarios. All of them are behavioral — how objects talk to each other and how responsibilities are shared between them.</p><h3>Strategy</h3><p>Strategy pattern is about putting interchangeable behaviors behind one interface so the code picks the right one based on context or configuration, not a pile of conditionals. It shines in components that enforce logic differing by country, region, or other boundaries. Examples include payment fee and tax calculators per method and country, shipping price algorithms per carrier, discount engines with stackable rules, rate limiting strategies tuned per API client, or export formats like CSV vs JSON. The result is clean extension points, simpler testing, and no more “if method is card and country is CZ then do X” scattered across controllers and services. Here’s a code example. Let’s say I have a simple API method that calculates a discount based on the provided region:</p><pre>&lt;?php<br><br>namespace App\Controller;<br><br>use App\DiscountService\DiscountCalculator;<br>use App\Enum\Region;<br>use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;<br>use Symfony\Component\HttpFoundation\Response;<br>use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;<br>use Symfony\Component\Routing\Attribute\Route;<br><br>final class DiscountController extends AbstractController<br>{<br>    public function __construct(<br>        private readonly DiscountCalculator $discountCalculator,<br>    ) {<br>    }<br><br>    #[Route(&#39;/&#39;, name: &#39;app_discount&#39;)]<br>    public function index(<br>        #[MapQueryParameter(validationFailedStatusCode: Response::HTTP_UNPROCESSABLE_ENTITY)]<br>        ?Region $region = null,<br>        #[MapQueryParameter(validationFailedStatusCode: Response::HTTP_UNPROCESSABLE_ENTITY)]<br>        float $amount = 0,<br>    ): Response {<br>        $response = [<br>            &#39;region&#39; =&gt; $region?-&gt;value,<br>            &#39;discountedAmount&#39; =&gt; $amount,<br>        ];<br><br>        if ($region !== null) {<br>            $response[&#39;discountedAmount&#39;] = $this-&gt;discountCalculator-&gt;calculateDiscount($amount, $region);<br>        }<br><br>        return $this-&gt;json($response);<br>    }<br>}</pre><p>The controller simply takes in two arguments — amount and region, passes them to our discountCalculator service and returns a discounted amount.</p><pre>&lt;?php<br><br>namespace App\DiscountService;<br><br>use App\Enum\Region;<br>use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;<br><br>final class DiscountCalculator<br>{<br>    /**<br>     * @param DiscountMethodInterface[] $discountMethods<br>     */<br>    public function __construct(<br>        #[AutowireIterator(&#39;discount_service.discount_method&#39;)]<br>        private iterable $discountMethods,<br>    ) {<br>    }<br><br>    public function calculateDiscount(float $total, Region $region): float<br>    {<br>        foreach ($this-&gt;discountMethods as $discountMethod) {<br>            if ($discountMethod-&gt;canBeDiscounted($region)) {<br>                $total = $discountMethod-&gt;getDiscountedPrice($total);<br>            }<br>        }<br><br>        return $total;<br>    }<br>}</pre><p>Here’s our calculator — it takes in all the strategies, finds one that can apply the discount, calculates it and returns the value. If no discount method is found, it returns the original value.</p><pre>&lt;?php<br><br>namespace App\DiscountService;<br><br>use App\Enum\Region;<br>use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;<br><br>#[AutoconfigureTag(&#39;discount_service.discount_method&#39;)]<br>interface DiscountMethodInterface<br>{<br>    public function canBeDiscounted(Region $region): bool;<br><br>    public function getDiscountedPrice(float $originalPrice): float;<br>}</pre><pre>&lt;?php<br><br>namespace App\DiscountService;<br><br>use App\Enum\Region;<br><br>class EuDiscountMethod implements DiscountMethodInterface<br>{<br>    public function canBeDiscounted(Region $region): bool<br>    {<br>        return $region === Region::EU;<br>    }<br><br>    public function getDiscountedPrice(float $originalPrice): float<br>    {<br>        // In the EU region, we can give a discount of 10%<br>        return $originalPrice * 0.9;<br>    }<br>}</pre><p>This approach keeps our codebase clean and maintainable — all calculation logic is centralized in one place, and the service is easily extendable. When we need to add a new discount type, we simply create a new class implementing DiscountMethodInterface.</p><h3>Chain of Responsibility</h3><p>Chain of Responsibility pattern is about passing a request through a pipeline of handlers where each one decides whether to process it or pass it along. It replaces long if-else chains with small, focused components that can be added, removed, or reordered without breaking everything else. It’s especially useful for workflows where multiple steps may apply conditionally, like processing an incoming HTTP request, sanitizing user input, or running validation rules in sequence. Arguably one the best examples of this pattern is <a href="https://www.php-fig.org/psr/psr-15/">HTTP Request Middleware described in PSR-15</a>. Here’s a code example — let’s say we’re implementing a service that systematically prepares a username from an input string:</p><pre>&lt;?php<br><br>namespace App\UsernameService;<br><br>use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;<br><br>#[AutoconfigureTag(self::TAG_NAME)]<br>interface UsernameHandlerInterface<br>{<br>    public const TAG_NAME = &#39;username_service.username_handler&#39;;<br><br>    public function handle(string $username): string;<br>}</pre><p>At the beginning, we have a simple interface with an autoconfigured tag and a single method.</p><pre>&lt;?php<br><br>namespace App\UsernameService;<br><br>use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;<br>use Symfony\Component\String\Slugger\SluggerInterface;<br><br>#[AsTaggedItem(UsernameHandlerInterface::TAG_NAME, priority: 3)]<br>class TrimAndNormalizeSpaces implements UsernameHandlerInterface<br>{<br>    public function handle(string $username): string<br>    {<br>        $username = trim($username);<br><br>        return preg_replace(&#39;/\s+/&#39;, &#39; &#39;, $username);<br>    }<br>}<br><br>#[AsTaggedItem(UsernameHandlerInterface::TAG_NAME, priority: 2)]<br>class AddTimestamp implements UsernameHandlerInterface<br>{<br>    public function handle(string $username): string<br>    {<br>        return sprintf(&#39;%s %s&#39;, $username, time());<br>    }<br>}<br><br>#[AsTaggedItem(UsernameHandlerInterface::TAG_NAME, priority: 1)]<br>class Sluggify implements UsernameHandlerInterface<br>{<br>    public function __construct(<br>        private readonly SluggerInterface $slugger,<br>    ) {<br>    }<br><br>    public function handle(string $username): string<br>    {<br>        return (string) $this-&gt;slugger-&gt;slug($username);<br>    }<br>}</pre><p>Here are three handler implementations — each performs a simple operation on the provided input. The service orchestrating the whole pipeline receives these items in order based on their priority.</p><pre>&lt;?php<br><br>namespace App\UsernameService;<br><br>use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;<br><br>final class UsernameProcessor<br>{<br>    /**<br>     * @param UsernameHandlerInterface[] $handlers<br>     */<br>    public function __construct(<br>        #[AutowireIterator(UsernameHandlerInterface::TAG_NAME, defaultPriorityMethod: &#39;priority&#39;)]<br>        private readonly iterable $handlers,<br>    ) {<br>    }<br><br>    public function process(string $username): string<br>    {<br>        foreach ($this-&gt;handlers as $handler) {<br>            $username = $handler-&gt;handle($username);<br>        }<br><br>        return $username;<br>    }<br>}</pre><p>Here’s the final processor that ties it all together.</p><h3>Specification</h3><p>Specification pattern is about capturing business rules as small, reusable objects that can be combined into more complex conditions. Instead of scattering if statements all over the code, each rule lives in its own class with a clear isSatisfiedBy() method. These rules can then be chained together with logical operators like AND, OR, and NOT to build richer conditions on the fly. It shines in places where logic changes often or needs to be reused in multiple contexts. Examples: filtering candidates in recruitment software based on certifications and location, defining access control rules beyond simple roles, or building query filters that can be applied both in memory and in a database query. The beauty of this pattern is that the same specification can validate a single object in PHP or generate the right conditions for a Doctrine query – meaning the rules are defined once and enforced everywhere, without duplication or risk of divergence.</p><p>Here’s a code example. Let’s say we have an Item object with various properties:</p><pre>&lt;?php<br><br>namespace App\ItemSpecification\DTO;<br><br>final readonly class Item<br>{<br>    public function __construct(<br>        public string $name,<br>        public string $category,<br>        public float $price,<br>        public bool $onSale,<br>        public int $stock<br>    ) {<br>    }<br>}</pre><p>Next, we need to establish centralized business rules for filtering these items. All these rules implement a common interface:</p><pre>&lt;?php<br><br>namespace App\ItemSpecification;<br><br>use App\ItemSpecification\DTO\Item;<br><br>interface SpecificationInterface<br>{<br>    public function isSatisfiedBy(Item $item): bool;<br>}</pre><p>Below are examples of how these rules might be implemented:</p><pre>&lt;?php<br><br>namespace App\ItemSpecification;<br><br>use App\ItemSpecification\DTO\Item;<br><br>final class IsOnSale implements SpecificationInterface<br>{<br>    public function isSatisfiedBy(Item $item): bool<br>    {<br>        return $item-&gt;onSale;<br>    }<br>}<br><br>final class CategoryIs implements SpecificationInterface<br>{<br>    public function __construct(private string $category) {}<br><br>    public function isSatisfiedBy(Item $item): bool<br>    {<br>        return $item-&gt;category === $this-&gt;category;<br>    }<br>}<br><br>final class PriceBetween implements SpecificationInterface<br>{<br>    public function __construct(private float $min, private float $max) {}<br><br>    public function isSatisfiedBy(Item $item): bool<br>    {<br>        return $item-&gt;price &gt;= $this-&gt;min &amp;&amp; $item-&gt;price &lt;= $this-&gt;max;<br>    }<br>}</pre><p>Logical operators are also implementations of SpecificationInterface:</p><pre>&lt;?php<br><br>namespace App\ItemSpecification;<br><br>use App\ItemSpecification\DTO\Item;<br><br>final class AndSpecification implements SpecificationInterface<br>{<br>    public function __construct(private SpecificationInterface $left, private SpecificationInterface $right) {}<br><br>    public function isSatisfiedBy(Item $item): bool<br>    {<br>        return $this-&gt;left-&gt;isSatisfiedBy($item) &amp;&amp; $this-&gt;right-&gt;isSatisfiedBy($item);<br>    }<br>}</pre><p>Now, let’s put it all together. Imagine we have a list of items and want to filter them based on a specific set of criteria:</p><pre>&lt;?php<br><br>namespace App\Controller;<br><br>use App\ItemSpecification\AndSpecification;<br>use App\ItemSpecification\CategoryIs;<br>use App\ItemSpecification\IsOnSale;<br>use App\ItemSpecification\PriceBetween;<br>use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;<br>use Symfony\Component\HttpFoundation\Response;<br>use Symfony\Component\Routing\Attribute\Route;<br>use App\ItemSpecification\DTO\Item;<br><br>final class ItemController extends AbstractController<br>{<br>    #[Route(&#39;/items&#39;, name: &#39;app_items&#39;)]<br>    public function index(): Response<br>    {<br>        $items = [<br>            new Item(&#39;Laptop&#39;, &#39;electronics&#39;, 1500, true, 5),<br>            new Item(&#39;Desk Lamp&#39;, &#39;home&#39;, 40, false, 10),<br>            new Item(&#39;Smartphone&#39;, &#39;electronics&#39;, 900, true, 0),<br>            new Item(&#39;Headphones&#39;, &#39;electronics&#39;, 120, true, 15),<br>        ];<br><br>        $spec = new AndSpecification(<br>            new CategoryIs(&#39;electronics&#39;),<br>            new AndSpecification(<br>                new PriceBetween(100, 2000),<br>                new IsOnSale(),<br>            )<br>        );<br><br>        return $this-&gt;json(<br>            array_values(<br>                array_filter(<br>                    $items, <br>                    static fn(Item $i) =&gt; $spec-&gt;isSatisfiedBy($i)<br>                )<br>            )<br>        );<br>    }<br>}</pre><h3>Wrapping It Up</h3><p>Design patterns aren’t silver bullets, but when used with care they are one of the best tools we have to handle complexity in code. They help tame growing projects, make intent explicit, and keep the structure predictable as new requirements arrive. The patterns I highlighted — Strategy, Chain of Responsibility, and Specification — are not always the first ones developers reach for, yet they can quietly transform a codebase when applied to the right problems.</p><p>The moral of the story is simple: patterns are not academic exercises. They’re practical building blocks that let us write software that’s easier to extend, test, and reason about. If a team shares this mindset, the difference between “it works for now” and “it will keep working tomorrow” becomes clear.</p><p>And of course, these three are just a glimpse. There are plenty of other patterns worth knowing — not only behavioral ones, but also structural and creational. From factories and builders to adapters and decorators, each has its place. The more tools we have in our toolbox, the more likely we are to pick the right one at the right time — and that’s what makes design patterns such a powerful ally in software development.</p><p>This article first appeared on my blog, where I publish new pieces every month. If you’d like to read the latest posts without the wait, you can find <a href="https://martinmicka.me/">them here</a>.</p><p>I also share a monthly newsletter — reflections on tech, leadership, and learning. If that sounds useful, <a href="https://martinmicka.me/#/portal/signup/free">you can subscribe here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43eaa4077745" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/from-chaos-to-clarity-using-design-patterns-to-tame-complexity-43eaa4077745">From Chaos to Clarity: Using Design Patterns to Tame Complexity</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony in Review: My Opinion on Recent Developer Experience Updates]]></title>
            <link>https://martinmicka.medium.com/symfony-in-review-my-opinion-on-recent-developer-experience-updates-b1fb3fc27b75?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1fb3fc27b75</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Fri, 15 Aug 2025 06:40:59 GMT</pubDate>
            <atom:updated>2025-08-15T06:40:59.646Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZoFvn_6tRHkq5oAP" /><figcaption>Photo by <a href="https://unsplash.com/@fakurian?utm_source=medium&amp;utm_medium=referral">Milad Fakurian</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Symfony is a technology I’ve worked with since 2017 on different projects. It’s always been my go-to framework in the PHP ecosystem — I’ve always liked how modular it is and how it has evolved over time. It’s no secret that even at Nelisa, Symfony is an integral part of our tech stack. I wrote a <a href="https://medium.com/@martinmicka/features-i-like-in-symfony-6-3-5a390fbd6f8a?ref=martinmicka.me">blog post</a> two years ago about Symfony 6.3 features and how they help us with concise code. The framework has noticeably evolved since then, and I want to discuss it in today’s post.</p><p>The evolution of the codebases I’ve worked with aligns with Symfony’s natural progression, highlighting the framework’s focus on separation of concerns, meaningful DX improvements, and genuinely useful components. A significant influence was also PHP itself — how it evolved as a language. Overall, I like where Symfony and PHP are heading, and I appreciate the path it took to get to where it is now. Here are some key features that have been integrated into the framework, playing a crucial role in how I leverage its capabilities.</p><p>Besides major updates, there are many DX improvements that came out in Symfony 7.3. These are mostly conveniences for existing parts of the framework, like the improved MapQueryString attribute, native adaptation of <a href="https://www.php.net/manual/en/language.oop5.lazy-objects.php?ref=martinmicka.me">PHP Lazy Objects</a>, and using log channels per exception. There are many more minor improvements. I recommend checking out the <a href="https://symfony.com/blog/category/living-on-the-edge?ref=martinmicka.me">Symfony blog</a> for more details.</p><h3>Stateless CSRF</h3><p>A significant feature introduced in Symfony 7.2. A classic problem with traditional CSRF in Symfony is that it depends on sessions. This isn’t a huge issue by itself, unless the application runs in a replicated setup and uses centralized session storage like Redis / Valkey.</p><p>I typically set a time-to-live (TTL) for sessions and enable the “Remember Me” feature. This approach refreshes the session and allows the project to function properly without requiring sticky sessions or other workarounds. However, it has one significant drawback: if a user submits a form after their session expires but before it’s refreshed, the CSRF check fails and their submission may be rejected. This can become a serious issue in certain scenarios.</p><p>Stateless CSRF effectively solves this problem. However, this approach has its own drawbacks. It relies on cookies and Origin/Referer headers, which can cause bugs or inconsistent behavior when not configured properly, especially when running behind a reverse proxy. More information about this feature is in <a href="https://symfony.com/blog/new-in-symfony-7-2-stateless-csrf?ref=martinmicka.me">this Symfony blog post</a>.</p><h3>ObjectMapper Component</h3><p>A component that was introduced in Symfony 7.3 as an experimental feature. As the name suggests, its main purpose is to bridge the gap between mapping of different objects. It allows us to use conditionals and renaming via attributes, which is handy, and it also includes formatter support.</p><p>I think this is a powerful addition to the framework. If I want to have a clear separation of concerns — let’s say between application layers or between domains — I am inclined to use DTOs or value objects, and in services I usually use information from these objects to create or update entities. This component can reduce a lot of boilerplate code and/or factory methods while keeping things tidy. I hope this component will make it to the stable phase and that it will be further extended. More about this feature in <a href="https://symfony.com/doc/current/object_mapper.html?ref=martinmicka.me">Symfony docs</a>.</p><h3>JsonPath Component</h3><p>Another experimental component from Symfony 7.3. This one allows us to query and extract data from JSON via JSONPath expressions. Before having this component, I usually decoded JSON and used PropertyAccess component. Thanks to this addition, I can work directly with JSON when needed. I like that it supports multiple approaches — querying via expressions, via fluent interfaces (building queries programmatically), and filtering as well. The component also comes with a bunch of assertions for testing. More about this feature in <a href="https://symfony.com/doc/current/components/json_path.html?ref=martinmicka.me">Symfony docs</a>.</p><h3>JsonStreamer Component</h3><p>This experimental component, introduced in Symfony 7.3, focuses on JSON encoding and decoding in a very fast and efficient manner. It’s a lot faster than the Serializer component while using significantly less memory. It works very well with DTOs and value objects and is a better fit for performance-demanding scenarios. It also allows value transformation, which is great for advanced scaffolding. More about this component in <a href="https://symfony.com/doc/current/serializer/streaming_json.html?ref=martinmicka.me">Symfony docs</a>.</p><p>Although all new components are still experimental, some of them are already being integrated into projects like <a href="https://api-platform.com/?ref=martinmicka.me">API Platform</a>, so I believe they are here to stay. I like the direction where Symfony is headed — it goes in the direction of performance, better developer experience, and all these additions help me write better code with less boilerplate. I look forward to seeing what’s coming next!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1fb3fc27b75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Thoughts on Unbundling the Enterprise]]></title>
            <link>https://martinmicka.medium.com/my-thoughts-on-unbundling-the-enterprise-fe5eeece6fb6?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe5eeece6fb6</guid>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Wed, 18 Dec 2024 09:19:59 GMT</pubDate>
            <atom:updated>2024-12-18T09:19:59.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GhO-agIniSUxtzpc" /><figcaption>Photo by <a href="https://unsplash.com/@videmusart?utm_source=medium&amp;utm_medium=referral">Syd Wachs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We’re living in the middle of the digital era. Information exchange has never been more convenient, and AI is on the rise, thanks to recent accomplishments by OpenAI with ChatGPT and other LLMs. The rate at which the Internet (and overall access to information) is expanding is not slowing down. No one really expected the Internet to become so popular at the beginning of the 21st century when it was in its infancy. And of course, no one foresaw the implications the Internet would have on businesses.</p><p>Throughout the years, we have witnessed how technology has changed the way we communicate and interact with the world. The landscape has significantly shifted, and we’ve seen how some businesses failed to adapt and are now fading into obscurity. On the other hand, this new landscape has unlocked new possibilities.</p><p><a href="https://itrevolution.com/product/unbundling-the-enterprise/">Unbundling the Enterprise</a> offers an interesting look at this change and how to navigate it. Not only that, but the book provides good advice on how to trigger happy accidents and thrive. There are many concepts revolving around experimentation, prototyping, and discovery. These concepts and their importance are explained via three methods, dubbed as OOOPs — creating optionality through unbundled APIs, identifying opportunities through value dynamics, and driving optimization through feedback loops. There are also many examples of how these methods were adopted by companies like Amazon and Google.</p><p>I appreciated the perspective and explanation of concepts I know and have experience with. The book offers great advice, and I recommend it not only to business-oriented people within companies but also to developers. The authors nailed the language, making the book fully understandable to both groups, which are often separated in understanding. Although the main theme of the book is the transformation to a digital landscape, many digitally-oriented businesses still lack many practices described here.</p><p>The advice offered here is no snake oil. It provides a practical overview of practices that can lead to great results. It’s not a step-by-step tutorial or a remedy for how to tame technology. Transformations are difficult. There will be mistakes. It might get painful. But there are ways to leverage all that and transform it into results. The introduced concepts can be studied separately, and knowledge can be built upon the learnings from this book.</p><p>This is a great read for a wide audience — software developers, business executives, or anyone who works for a digitally-oriented business or even a traditional business that needs to transform and adapt to the digital era.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe5eeece6fb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Software Development to DevOps — Roadmap to Kubernetes]]></title>
            <link>https://medium.com/codex/from-software-development-to-devops-roadmap-to-kubernetes-c37a6b8c38fd?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c37a6b8c38fd</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 11:05:12 GMT</pubDate>
            <atom:updated>2024-09-13T11:05:12.972Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>From Software Development to DevOps — Roadmap to Kubernetes</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RlK8nIKgLQ2hCkcA" /><figcaption>Photo by <a href="https://unsplash.com/@chrislinnett?utm_source=medium&amp;utm_medium=referral">Chris Linnett</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently, I ventured into the realm of DevOps to expand my knowledge and improve an existing solution that proved to be insufficient for the project. After considering multiple approaches, I decided to fully embrace and learn the Kubernetes ecosystem. It has been quite an adventure for me, as someone with a strong background in software development and architecture. In this post, I want to share my thoughts on the topic.</p><p>Kubernetes is a container orchestrator that is known worldwide as a scalable, highly available solution. It’s been widely adopted and has become the norm in the DevOps world for containerized solutions. My goal was to gain a solid understanding of Kubernetes (K8s for short, which I’ll use from now on) and to form an opinion on whether the hype around it is justified. I opened the documentation and started reading, and I became frustrated pretty quickly — I realized that the learning curve for K8s is steep. Suddenly, I was in awe of all the foreign concepts and the various ways K8s handles workloads, resolves issues, and manages conflicts. It was overwhelming at first. Not to mention, K8s has a lot of abstractions with implementations provided by third-party technologies, which adds even more to the confusion.</p><p>Instead of banging my head against the wall trying to make sense of everything, I decided to take a step back and make sure I nailed down the basics. I can’t stress enough how useful this decision turned out to be.</p><p>I told myself to forget about K8s for a bit and focus on mastering the underlying concepts first. One technology that is often mentioned alongside K8s is Docker. Docker is also <em>that thing that works with containers</em>, but it’s much simpler. It doesn’t focus as much on orchestration concepts; rather, it’s all about creating and running containers.</p><p>After learning the ins and outs of images and containers, I began digging into Docker Compose, networking, and volumes. Prior to that, my knowledge of Docker as a developer was pretty limited. Since I had already been using it daily, the additional learning proved valuable in other areas. I improved my local development environment significantly as I gained more Docker knowledge, and I realized just how great the technology is! It saves a lot of headaches, and I now use it to run my hobby projects in production as well.</p><p>With all the knowledge I gained from learning Docker, I felt more confident and ready to dive into container orchestration. Docker has its own offering, Docker Swarm, which I decided to explore. It was a good starting point — it wasn’t as overwhelming as K8s because Swarm isn’t as robust. That’s both its major advantage and disadvantage, and likely why I haven’t seen Swarm used in many projects.</p><p>For learning purposes or relatively simple projects, Swarm works fine. It builds on what can be achieved with Compose on a single machine by adding functionality to coordinate and schedule containers across multiple machines (called nodes). It also offers additional networking options, allowing containers to communicate with each other even when scheduled on different nodes. The configuration is similar to Compose, so transitioning to Swarm felt like a natural next step in the learning journey.</p><p>Okay! After mastering the underlying concepts, becoming familiar with container virtualization, and understanding how a relatively simple orchestrator works, I was ready to tackle the beast. Concepts that had previously confused me started to make sense, and I began to appreciate the depth at which K8s operates. After learning the foundations and exploring the different workloads K8s offers, I also delved into <a href="https://about.gitlab.com/topics/gitops/">GitOps</a>. In the end, I successfully launched the project on K8s, and I’m happy with how it turned out.</p><p>I found my journey with K8s exciting. It opened up a whole new world beyond just writing code. Of course, containers aren’t the only way to run a production environment, but I find it convenient, and the benefits of this approach are strong for my use cases. I recommend this learning path to all developers, as it provides a bigger picture of the entire software lifecycle. As with many things in life, we may feel overwhelmed by the complexity of something, and staring at the peak can make it hard to imagine reaching it. Instead, it’s better to lower our heads, plan the path forward, and stay consistent. Eventually, we will reach the summit.</p><p>When it comes to learning K8s, if you jump straight in without first mastering the fundamentals of containers, it won’t make much sense. Start small, and you’ll get there eventually.</p><h3>Learning Roadmap</h3><p>Here’s my recommendation on how to learn Kubernetes from start to finish. I’ll be focusing solely on Kubernetes and Docker. There are plenty of additional tools that can help with certain areas when using these technologies, but that’s a topic for another day.</p><p>I recommend starting with the Docker and Kubernetes documentation, as both are very well-written and easy to understand. Everything you need is there. If you find some concepts confusing along the way, just Google it or ask AI — a second or third explanation of a particular topic can often make things clearer.</p><h4>Docker</h4><ol><li><strong>Images</strong>— What images are and how to create them.</li><li><strong>Dockerfiles</strong> — Semi-required; it may not be essential for understanding K8s, but it offers great insight into how Docker handles layers and how images work. Besides, it’s the current standard to have a Dockerfile to build an app’s container.</li><li><strong>Containers</strong> — How to run them, port forwarding, bind mounts, and volumes.</li><li><strong>Compose</strong> — How to run multiple containers at once, networking, and container configuration.</li><li><strong>Swarm</strong> — Orchestration concepts for Docker, including node types, workloads (e.g., stacks), and networking in Swarm.</li></ol><h4>Kubernetes</h4><p>There’s a lot to learn, as K8s handles a wide variety of workloads. You don’t have to learn everything at once. It’s helpful to have clear requirements for what you want to achieve and focus on learning what’s necessary for your specific goal. You can expand your knowledge from there. Additionally, there’s <em>a lot of</em> reading on theoretical concepts — how K8s operates under the hood. While it’s not required to get started, I found it helpful to understand how K8s handles certain situations when it comes to nodes and scheduling, even though I likely won’t need it, as these problems are usually resolved automatically.</p><p>Here are some prerequisites:</p><ol><li>Cluster architecture, control plane, components, and their responsibilities.</li><li>How nodes are managed and scheduled.</li><li>Node problems and rescheduling.</li><li>kubectl — K8s CLI.</li></ol><p>After that, I’d recommend setting boundaries for your project and start learning about what you actually want to run on K8s. For example, let’s say you want to run a stateless application that is highly available.</p><ol><li><strong>Pods</strong> — What they are and what they can do; they are the fundamental concept of running containers on K8s. The more you know about them, the better.</li><li><strong>Workload Management</strong> — This operates at a level above pods. We don’t usually manage pods directly; instead, we manage workloads that control pods. For a stateless application, you might need <strong>Deployments</strong>, and maybe <strong>Jobs</strong> or <strong>CronJobs</strong>. Autoscaling can also be part of this.</li><li><strong>Services and Networking</strong> — This is a level above workloads. Once the application is running, we need to expose it within the cluster and configure K8s to handle networking, load balancing, and possibly exposing it to the Internet. For that, there are two key concepts: <strong>Ingress</strong> (with Ingress Controllers) or the <strong>Gateway API</strong>. There are some differences between them, so I recommend reading about both and deciding which suits your use case.</li></ol><p>There are additional topics that might not be essential at the beginning, but I recommend learning about them after you have a solid understanding of the core concepts. Some of these may be required for production hardening:</p><ol><li>Secrets</li><li>Pod Eviction and Preemption, Disruption Budgets</li><li>Resource Requests and Limits</li><li>Storage — Volumes and Classes</li><li>Network Policies</li><li>Node Affinity/Anti-Affinity Rules</li><li>Service Accounts</li><li>Custom Resource Definitions (CRDs)</li></ol><p>And that’s all! There’s certainly a lot to take in, but I hope this roadmap is useful to you. Maybe you already have some experience, so you don’t need to start from scratch. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c37a6b8c38fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/from-software-development-to-devops-roadmap-to-kubernetes-c37a6b8c38fd">From Software Development to DevOps — Roadmap to Kubernetes</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stuff I Found Interesting in 2024]]></title>
            <link>https://martinmicka.medium.com/stuff-i-found-interesting-in-2024-30c14da61a49?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/30c14da61a49</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 11:52:20 GMT</pubDate>
            <atom:updated>2024-07-16T11:52:20.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hkFWAGOtRiCL3AK8" /><figcaption>Photo by <a href="https://unsplash.com/@impatrickt?utm_source=medium&amp;utm_medium=referral">Patrick Tomasso</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As we reach the midpoint of 2024, I’ve come across some fascinating reading that I’d like to review and share my opinions on. I’d also like to take this opportunity to offer some recommendations.</p><h3><a href="https://world.hey.com/dhh/programmers-should-stop-celebrating-incompetence-de1a4725">Programmers should stop celebrating incompetence</a></h3><p>This article caught my attention a bit late, but it remains highly relevant today. It drives the point home and aligns perfectly with my view of programming as a profession. It thoroughly demonstrates the qualities I value in (senior) developers: the ability to understand the code, comprehend what’s happening under the hood, and make the computer do what they want it to do. Additionally, the skill to communicate ideas about code is crucial.</p><h3><a href="https://robindev.substack.com/p/cloudflare-took-down-our-website">Cloudflare took down our website after trying to force us to pay 120k$ within 24h</a></h3><p>This is concerning and serves as a reminder that excessive reliance on vendors can lead to significant complications in the long run. Vendor lock-in is a double-edged sword. While avoiding all vendor solutions can result in reinventing the wheel and unnecessary overhead, overusing vendor services can also be problematic, as highlighted in this blog post. It’s not the first time I’ve encountered issues like this, but never to such an extreme.</p><p>It’s also up to specific cases when unpleasant stuff happens. The last time I approached this topic was earlier this year when Amazon started applying some unpopular measures on AWS, like <a href="https://www.theregister.com/2024/02/05/aws_ipv4_cash/">charging people for public IPv4s</a>. That in itself isn’t that egregious, given that <a href="https://www.datacenterdynamics.com/en/opinions/the-ipv4-run-out-one-year-on/">we’ve been running out of IPv4s for quite some time</a>. The problem is that for some, migration to IPv6 might be problematic, as AWS support for IPv6 on certain services is non-existent. Here’s a <a href="https://github.com/DuckbillGroup/aws-ipv6-gaps">good compilation of these implications inside AWS</a>.</p><p>Naturally, that made some people angry, and talks of migration from AWS became a topic again. In the midst of all those changes, people were also upset because of the <a href="https://www.digitalocean.com/resources/article/aws-egress-costs">egress fees that AWS had in place</a>. For some, migrating would not only be painful if they were too reliant on specific AWS offerings, but it might also have been very expensive. Luckily, Amazon has announced that <a href="https://www.forrester.com/blogs/aws-joins-google-cloud-in-removing-egress-costs/">they are removing egress costs when moving data outside</a>.</p><p>It all basically boils down to trust in a given platform and its value. My recommendation here is to do thorough research and be cautious when considering vendor lock-in. It depends on the situation. Are you locking in the whole solution, or are you using a single service within a larger system? Think about worst-case scenarios — if the service suddenly stopped working, what would it take for you to get your system up and running? Also, consider open-source solutions. In some cases, it makes perfect sense to choose an open-source variant that you can self-host or easily deploy elsewhere. Of course, these solutions might have their own cascade of quirks, but again, it depends! Is it more important for you to stay less reliant on a provider, or do you prioritize better performance, pricing, or whatever the selling point of the proprietary solution is?</p><h3><a href="https://www.amazon.com/Software-Architecture-NET-applications-microservices/dp/1805127659">Software Architecture with C# 12 and .NET 8 by Gabriel Baptista and Francesco Abbruzzese</a></h3><p>Although C# and .NET are outside of my usual tech stack, it has still been an interesting read — it gave me a bit of insight into technologies I don’t primarily use. This book is a good bundle; it’s not only about the framework and programming language itself but also offers an opinion on how to run it — particularly on Microsoft Azure. Besides that, there are chapters on DevOps, CI/CD, Domain-Driven Design, and Design Patterns. If C# is your tool of choice, this book might be a good read, as it offers a comprehensive package on different topics of modern software development.</p><p>I also recommend this book to seasoned developers. The overview is quite comprehensive, covering everything from how to utilize the language to how to run it. It might serve as a good anchor for transitioning from development to architecture or DevOps. On the other hand, professionals from the DevOps and automation world might find this book useful for its programming content. I can see and appreciate its appeal to a broader audience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30c14da61a49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2023 Post Mortem]]></title>
            <link>https://martinmicka.medium.com/2023-post-mortem-1401159b6aea?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1401159b6aea</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[goals-in-life]]></category>
            <category><![CDATA[blogging]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Sat, 06 Jan 2024 19:40:01 GMT</pubDate>
            <atom:updated>2024-01-06T19:40:01.906Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GMB8hlrw5q9Na-4A" /><figcaption>Photo by <a href="https://unsplash.com/@jdiegoph?utm_source=medium&amp;utm_medium=referral">Diego PH</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hi. It’s been a while since I posted anything. I’ve been busy. 🌝</p><p>A lot has happened in the last 10 or so months. Overall, I have grown a lot through the experiences this year brought. I reached both professional and personal milestones. I’m grateful for what this year brought and what’s about to come next.</p><h3>Being a CTO</h3><p>In the first quarter of 2023, I took on the challenge of leading a tech-driven startup as a CTO. As the market shifted and resources became scarce, we had to make some drastic measures within the company. On top of all that, we made the decision to rewrite our entire product.</p><p>We successfully drove that initiative to completion, and now we’re in the midst of a transition. The incredible work has already garnered attention from our clients, and receiving all the positive feedback makes me happy that we’ve pulled through. I’m proud of my colleagues, especially my fellow developer Jakub. Not only did he support me at every step and significantly contribute to shaping the new product, but his enthusiasm and motivation to learn more about topics beyond our usual tech stack deserve recognition. If you’re reading this, thanks again for the great work!</p><p>In the past two years, we’ve made numerous decisions in our startup, and unfortunately, many of them ended in failure. However, it has been an invaluable learning experience. 2023 was the year of learning for us, and we all hope to apply that experience in our future endeavors.</p><p>As for me personally, it has been an incredible ride so far, and I’m very curious about what the future has to offer. I’ve experienced significant growth. This opportunity has helped shape both my technical knowledge and soft skills, leading to various realizations. The most significant one is that every endeavor we undertake is not just about the individual but also about others. It’s equally important to place trust in and support others, alongside individual contributions to the effort. Decision-making isn’t always easy, and being in an executive role has exposed me to many challenging situations, ultimately aiding me in becoming a better leader and colleague. I have no regrets and can say with a clear head that I wouldn’t do anything differently. I’m proud of what we have accomplished despite all the circumstances.</p><h3>Personal Achievements</h3><p>A lot has happened in my personal life as well. A few significant lifelong dreams of mine came true in 2023, and they were truly amazing experiences.</p><p>The first one was that, for the first time in my life, I finished a half marathon run. The dreaded 21.1 km run. When I look back on myself a few years ago, it was unthinkable that I would pull this off one day, but here I am, proudly declaring I did it. My time was 2:08:11. I’m satisfied with that, considering it was my first attempt.</p><p>I wrote an article about <a href="https://byrslf.co/my-journey-of-losing-weight-ee1fd0e696f3?ref=martinmicka.me">my weight loss journey</a> a few years back. After that, I had some nasty injuries that took me two years to recover from. I had to say goodbye to running for a while, and 2023 was the year I got back into it. Running a half marathon was an incredible ending to my personal running season. Now I want to focus on gaining a bit of strength by lifting weights and going back to the gym, so I can start my 2024 running season in better shape and take on more challenges.</p><p>Another significant experience I had was traveling to Japan. Both my dear girlfriend and I had wanted to go there for years. As someone who studies psychology, Japan sometimes seemed like an outlier in a lot of studies and phenomena. Its unique society and culture always intrigued me. I like stories, and the Japanese are great storytellers as well. <em>I’m looking at you, Naruto, One Piece, Berserk, and other great pieces of anime and manga.</em></p><p>We went there in October 2023, for two weeks. Our trip started with Tokyo, then we went to Kyoto, Nara, Osaka, Hiroshima, and Nikko. We tried to mix both countryside and nature, as well as modern/historic cities and sights. What an unreal experience that was. I was prepared for some culture shock, but I hadn’t expected such a stark difference in some aspects from the Czech/European way of life. It was very refreshing to see a world where the society is built on mutual respect, yet everyone behaves so individually. For example, I noticed that even when being in one of the busiest parts of Tokyo called Shibuya during peak hours, I saw approximately the same amount of cars as in Prague city center. The catch is that Tokyo is approximately 10 times bigger than Prague. Traffic is also quieter, as I saw that the majority of cars there are electric/hybrid. The air also felt cleaner. Instead, most people move around by public transport, which is very convenient to get around. The same applies to commuting between cities — trains rarely have delays and are pretty fast.</p><p>What I’m trying to say is that I strongly felt that the Japanese have strong mutual respect for other people and don’t put themselves at the expense of the comfort of others. When most people use public transport instead of cars, everyone there can enjoy less air and sound pollution. That’s a strong contrast from Prague, where a lot of people would rather go by car and then complain about the traffic, also at the expense of other people who then breathe fumes and have to listen to rumbling engines on the street. If there is something that I truly miss, it is exactly that human quality — having respect for others, sometimes even at the expense of personal comfort.</p><p>I’ve had a ton of great experiences and interesting interactions with other people. Be it the politeness of staff in <a href="https://en.wikipedia.org/wiki/Izakaya?ref=martinmicka.me">Izakayas</a> or banter with locals in <a href="https://en.wikipedia.org/wiki/Sent%C5%8D?ref=martinmicka.me">public baths</a>. I wish to go back there at some point in the future and travel more across the country.</p><p>2023 was indeed an interesting year. I’m looking forward to what 2024 brings.</p><p>This article has originally been published on <a href="https://martinmicka.me/">my website</a>. In upcoming weeks, I want to start there a newsletter with more tips and interesting ideas to share. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1401159b6aea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Features I Like in Symfony 6.3]]></title>
            <link>https://martinmicka.medium.com/features-i-like-in-symfony-6-3-5a390fbd6f8a?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a390fbd6f8a</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 06:02:01 GMT</pubDate>
            <atom:updated>2023-06-30T06:02:01.346Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4o5L1BQlg2L56qzn" /><figcaption>Photo by <a href="https://unsplash.com/@gwundrig?utm_source=medium&amp;utm_medium=referral">Manuel Nägeli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It has been a month since the release of a new version of my favorite PHP framework. Today, I want to share my thoughts on the features that I enjoy working with in this new version.</p><h3>Request Payload Mapping</h3><p>This is probably my favorite feature of this release. Before it was available, we had to implement data mapping ourselves or use a component like Symfony Forms or Serializer to do it for us.</p><p>As someone who generally avoids using Symfony Forms for various reasons and finds implementing serializers just for simple data mapping to be overly complicated, I’ve had a difficult time finding a simple solution.</p><p>After trying multiple approaches, I found that creating a custom Request class was effective. This class populates data into a desired DTO and runs Symfony Validator against its rules. If there are any errors, an HTTP Exception is raised within the Request class. To reduce code duplication, I used an abstract class that generally runs validation and populates data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5o_N43MaXyQj4OeVLVVww.png" /><figcaption>Custom abstract “Request DTO” class</figcaption></figure><p>My custom child Request class would act as a data transfer object (DTO) and have its own logic for populating and validating data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lMRywpWqDc2_XYTHRECx0w.png" /><figcaption>“DTO Request” with custom data population and validation</figcaption></figure><p>This request class is then passed as a Controller method argument, “connecting” it to the whole Request-Response lifecycle. If the request data is invalid, it will never pass down to the Controller in the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OS-Chc1R0kXnwF_a7LMW6Q.png" /><figcaption>Usage of my “DTO Request” class</figcaption></figure><p>That’s still a lot of code for such basic functionality. Fortunately, Symfony 6.3 includes native request data mapping that is much simpler. To use it, we need a DTO with validation constraints:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZllT_qN1x0tmVCkXP2FCw.png" /><figcaption>Basic DTO with some constraint</figcaption></figure><p>Now we can pass this DTO with proper attribute to Controller method, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFGpR928PkDueoAf3h8eBg.png" /><figcaption>Request Payload Mapping!</figcaption></figure><p>Symfony will map Request properties according to our DTO and run the Validator before the execution reaches the Controller. If any errors are present, an exception will be raised.</p><p>The MapRequestPayload attribute accepts arguments that modify its default behavior. For example, you can specify which validation groups should be used.</p><h3>Webhook Component</h3><p>Another great feature of this framework is its new component for webhooks. Webhooks are commonly implemented without any standards, so having a convenient abstraction for them is a nice improvement.</p><p>Although I have not yet tried this component as it is still experimental and lacks documentation, I like the idea of having a standardized way to deal with webhooks.</p><h3>Dependency Injection Improvements</h3><p>There are several improvements for dependency injection (DI) within a Symfony application. In my opinion, the most useful ones are enhancements to the Autowire attribute. It now supports nesting other autowiring attributes, such as tagged locators or iterators. Additionally, it can autowire parameters and environment variables via arguments.</p><h3>Query Parameters Mapper</h3><p>Another great feature is the ability to map query parameters to controller method arguments via attributes. This feature complements the Request Payload Mapping functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osAJcbcYQzh9d11VVj-ESw.png" /><figcaption>Query Parameter Mapping!</figcaption></figure><p>The new release of Symfony includes many great features, and it seems that the web framework is heading in a good direction. Although other frameworks might have had these features for years, it’s still nice to see them being adapted.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a390fbd6f8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personal Project Overview — Infrastructure]]></title>
            <link>https://martinmicka.medium.com/personal-project-overview-infrastructure-571952d28007?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/571952d28007</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Mon, 29 May 2023 07:01:54 GMT</pubDate>
            <atom:updated>2023-05-29T07:01:54.436Z</atom:updated>
            <content:encoded><![CDATA[<h3>Personal Project Overview — Infrastructure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OCQxusF7HhXPZ4MZ" /><figcaption>Photo by <a href="https://unsplash.com/@ianjbattaglia?utm_source=medium&amp;utm_medium=referral">Ian Battaglia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Continuing with my series of tech articles, today I will discuss my thought process regarding the infrastructure of my project. As mentioned previously, there are several moving parts to consider: a frontend app (built with Next.js and TypeScript) that communicates with the backend API (built with Node.js and Nest framework, also with TypeScript), and a few other dependencies such as a database.</p><p>The main requirements that guided my infrastructure planning were as follows:</p><ul><li>I can easily replicate the infrastructure on different servers and setup multiple environments</li><li>I can have infrastructure as configuration</li><li>I can scale easily</li><li>Server envrionment is similar to local environment</li></ul><p>After experimenting with different approaches, I have decided to use Docker for both server environments and local development. Having a managed Kubernetes cluster would be unnecessary overhead and more expensive to run. Since this project is for personal use or small-scale implementation, going full cloud doesn’t make much sense.</p><p>Docker is perfect for my needs. It can scale, provides sufficient virtualization and abstraction, and solves many of the issues that I would encounter with a dedicated solution. I can also use Docker Compose for versioning and full configuration capability. I can spin it up on multiple servers and use it for local development as well.</p><h3>Backend and Frontend Applications</h3><p>I began by dockerizing both parts of my application for local development. Each project has a versioned docker-compose.yaml file. Let’s take a look at them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53ErzDHgRqqax0NQCXlFeQ.png" /><figcaption>Local backend docker-compose.yml</figcaption></figure><p>I am using Traefik as a reverse proxy here because it is convenient to use, has service discovery, and works well with minimal configuration. To learn about all the cool stuff you can do with it, I suggest browsing <a href="https://doc.traefik.io/traefik/">their docs</a>. Traefik takes care of routing requests and other conveniences, such as SSL. I generated and self-signed a certificate, so the setup is closer to how things run on the server. The configuration of Traefik is also pretty straightforward here; the container has forwarded ports 80 and 443, and basic configuration of host, TLS, and service exposure of Traefik Dashboard are in labels. The container also has a bound Docker socket, so it can listen and discover other containers as Traefik services, as well as one configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5d5jWBjJdLlYHb80OANtdg.png" /><figcaption>Traefik configuration</figcaption></figure><p>Configuring Traefik is fairly straightforward. First, I turned on the Dashboard to monitor its activity and troubleshoot any issues. Then, I set up two providers: a Docker provider for the services that Traefik needs to serve, and a file provider for managing TLS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJ1h5o9TrojVZDjmSO5SGg.png" /><figcaption>Dynamic Traefik configuration — file provider for TLS</figcaption></figure><p>Returning to Traefik configuration, after configuring providers, I set up a proxy to redirect all unsecured traffic to HTTPS, as shown in the web entrypoint. For development purposes, I have turned on logging and access logs, and I have disabled TLS verification, which would fail since the certificates are self-signed. To generate certificates, I am using <a href="https://github.com/jsha/minica">minica</a>.</p><p>In addition to Traefik, I use a MySQL database (I switched from Mongo since my last update). My approach is simple: I create one volume to persist data, establish a separate network connection (so I don’t have to expose MySQL to containers that don’t need to interact with it), use a deterministic database name and root password in the environment, and forward a port for local access to third-party database clients. Of course, in production, I do not forward the port.</p><p>Lastly, I also containerized my backend application. I used a multistage build for my application and used my Development target. My backend container is connected to two networks — one that exposes the container to Traefik and the second one for interacting with the database. Additionally, this container has a bind mount for the source code. Below is my Dockerfile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*39MZeEO5uuHa2cJDuRxCrQ.png" /><figcaption>Quizae backend Dockerfile</figcaption></figure><p>The setup process is straightforward. In the first stage, only necessary files such as NPM state and Prisma configuration are copied, followed by the installation process. In the second step, the built application from the previous stage is copied and assigned to a rootless user, then run. At the time of writing, I encountered some extension issues on Alpine image, so I used a base image instead. The third stage is also simple — it does the basic setup, installs dependencies, and copies the application code. Let’s take a look at frontend next:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O49QH_JCbu7amxzJWMuExA.png" /><figcaption>Frontend docker-compose.yml</figcaption></figure><p>It builds a development target from my own image based on the Node image. It binds the local context (source code) inside the container and is on the same network as the backend and Traefik. There’s a Traefik router configuration in the labels, and some basic environment variables are set — mostly for authentication libraries and links to the backend. I’ve disabled Node TLS verification to prevent self-signed certificate errors.</p><p>It’s also worth mentioning the additional hosts that need to be routed outside of Docker to ensure correct API communication from inside the container, as well as proper functioning of HMR and websockets in the Next.js framework.</p><h3>Continuous Integration</h3><p>I need to have a production-ready image of my app in order to deploy it. For this, I have decided to use Github Pipelines and I have found it to be a helpful tool. I will demonstrate this process for the backend app, as the frontend app is not yet fully ready to be deployed. I have two workflows in place: one that is triggered and enforced to pass on every pull request, while the second is triggered automatically on release. Since I have locked my main branch, I am 100% certain that the code heading for the release has passed tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2Vd-KMBzRzsxVXpFOvUyw.png" /><figcaption>Test CI Workflow for Quizae Backend</figcaption></figure><p>Pretty neat, right? Since the backend is headless and Nest offers some useful functionality for end-to-end testing, the only dependencies required are Node runtime and a MySQL database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXS_h0-lMdug2hh-RrVtcw.png" /><figcaption>Image Build Workflow for Quizae Backend</figcaption></figure><p>In terms of the build process, I still rely on Docker. I have previously shared the Dockerfile and some of my reasoning behind that choice. As for my workflow, I do not use any proprietary tools since only basic functionality is required. Instead, I use Docker actions to generate image metadata with semantic versioning, which aligns with how I version my projects. After that, I set up QEMU and Buildx, log in to Github Container Registry, and build my image for the production target. If everything goes smoothly, the image is then pushed to my Container Registry.</p><h3>Server Environments</h3><p>For server environments, I have created a separate repository that contains a few Docker Compose files and Traefik configuration. Although this introduces a bit of code duplication, it gives me full control over how I want to orchestrate the containers on the server.</p><p>I have decided to use <a href="https://portainer.io/">Portainer as my container management tool</a>. It works well with Docker and allows me to control my apps through a visual UI, instead of using complicated scripts on the server. My initial compose file includes the basics: Traefik as my server-wide proxy and Portainer, which will orchestrate my backend and frontend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODpKjetOPD3DZfbJFpX5Mw.png" /><figcaption>Base environment — Traefik and Portainer services</figcaption></figure><p>I don’t use Traefik in a significantly different way from my local setup. However, I added HTTPS verification, which works well with Traefik. It not only generates certificates but also verifies them for all domains and subdomains used with the server, without requiring any additional effort on my part.</p><p>Additionally, I have configured HTTP Basic middleware for the Traefik Dashboard. This serves as an adequate security measure at the moment. For debugging purposes, I have enabled it, if necessary.</p><p>Regarding the second compose file for the “backend” part of Quizae, it includes two service definitions: one for the database and the other for the backend application. Although containerizing databases is not ideal, for the scope of my project, I am willing to accept some performance penalty in exchange for the convenience this setup provides. Furthermore, the project scope does not justify spending additional money on a managed database server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rrXgsOp0JrGz3TjIG5zh6Q.png" /><figcaption>Backend docker-compose.yml for server environment</figcaption></figure><p>This compose file is fully utilized by Portainer. What I appreciate about it is the ability to easily manage my service. For instance, if I need to add more containers to the backend, I can do so from the UI. Portainer also offers webhook functionality that can be utilized for Continuous Deployment.</p><p>Currently, to apply backend changes on the server, I must access the Portainer UI and instruct it to redownload the latest backend image and redeploy it. The only downside to my current setup is that Portainer, in combination with Docker, lacks any zero-downtime deployment feature. However, considering the scope of this project, I can accept this limitation. If I needed zero-downtime deployment, I would have to upgrade to Swarm or switch to Kubernetes. If that would introduce too much overhead, PaaS offerings such as <a href="https://www.digitalocean.com/products/app-platform">DigitalOcean App Platform</a> or <a href="https://platform.sh/">Platform.sh</a> could be viable alternatives.</p><p>Thank you for reading my article! If you want to see all the code mentioned here, you can access my Quizae project publicly on <a href="https://github.com/Mareddie">my Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=571952d28007" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personal Project Overview — Backend, Part 2]]></title>
            <link>https://martinmicka.medium.com/personal-project-overview-backend-part-2-a07a64063c6?source=rss-a899542c33c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a07a64063c6</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[nestjs]]></category>
            <dc:creator><![CDATA[Martin Mička]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 06:01:17 GMT</pubDate>
            <atom:updated>2023-04-24T06:01:17.442Z</atom:updated>
            <content:encoded><![CDATA[<h3>Personal Project Overview — Backend, Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7n8KX5kw5Pu_ldNf" /><figcaption>Photo by <a href="https://unsplash.com/@seanpollock?utm_source=medium&amp;utm_medium=referral">Sean Pollock</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome back to my personal project overview series. In the first part of this series, I provided an overview of the backend of my application, including my reasoning for implementing domains with a presentation layer. In this part, I will dive deeper into my reasoning behind the business logic and data layer.</p><h3>Business Logic</h3><p>The system is split into the Domains, where the business logic (alongside with data layer) is. I have a bunch of handlers that take data from controller (at this point we can assume that the data are valid) and do additional checks and preparations with persist logic. I’ve chosen Mongo and Prisma ORM for this app. Prisma integrates nicely into Nest, and supports Mongo also pretty well. What I like about Prisma is the clear separation of schema from data mapping, and data classes / object representation. Prisma also has its own agnostic query logic, which I don’t mind, but I can see that some people wouldn’t prefer it. I won’t dive deep into this topic in this post, but Prisma has documented concepts with reasoning on their website, <a href="https://www.prisma.io/docs/concepts/overview/why-prisma">feel free to check it out</a>.</p><p>When it comes to Mongo as my choice, I wanted to try building the whole app on NoSQL technology. As someone who uses relational databases most of the time for data store, this was quite a change. Mongo is great for building stuff, as it’s not as restricting when it comes to schema, but I miss relational modeling and it took time to get used to some quirks that NoSQL brings, like data duplication in documents. Of course, I’ve tried embedding documents and other deduplication techniques, but I’m still not sure whether they’re worth it.</p><p>Let’s take a look at the core domain. I primarily split logic into two patterns that separate read and write / mutation concerns. Classes that mutate (store or modify domain data) are called handlers. For strictly fetching data, if needed, I use facade pattern. I’m careful with that one, as facades can turn big and ugly real quick, when not thought out properly. I also adapt a repository pattern as the deepest layer in my domains. Repositories are responsible for querying and retrieving data from database (or some other low-level storage / system in the application).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pglRcyQdnbJPuMVvPpL5lw.png" /><figcaption>Handler for Groups</figcaption></figure><p>Here’s how such handler in my application looks like — this one’s responsible for creating / updating User Group. Every Group has owner and members, with rule that only owners can update groups. Let’s break it down a bit.</p><p>Because of granularity and layering, there are arguments that have already been validated — DTO validation was invoked by Nest before the app got to the controller, and the same goes for groupId and ownerId — because this handler is accessed via protected routes, we are certain that the User is authenticated. We also validated beforehand, whether groupId is at least correct ObjectID.</p><p>On this layer, business logic and data processing is added — let’s consider update method — Group is prefetched (and therefore checked whether it even exists, method also searches by owner), and then the Group is updated with new data (and members).</p><p>I’m also using a Repository pattern for a little bit more granularity as well — in case I wanted to change data logic (e.g. adapt other data sources than my database and Prisma), and I also wanted to separate query / mutation logic from business logic. This way, data layer can be more reused and is overall more modular. It’s also easier to mock and test business logic this way. Tests for updateGroup method within the handler look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xrcY01UWWaMzBp584xkkg.png" /><figcaption>Tests for Group Handler</figcaption></figure><p>Repository for this part of application is pretty straightforward as well. On this level, I have some basic conditions that only influence how Prisma queries look like. It’s too deep for any business logic or data validation. On this level, it’s appropriate to solve database-related errors and query logic only. My group repository looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdOC6Jd-16C5d6SZMlySXg.png" /><figcaption>Group Repository</figcaption></figure><p>When there’s more logic, I usually build repositories not around an entity, but rather against a specific use-case of entity. For example, when I have an entity User that’s used in general sense, I have multiple facades / repositories for any given use case. I’m also not very fond of leaking repositories from domains into Presentation layer (controllers, high-level services), but for some use cases, it’s a big overhead to introduce some sort of pattern between repository and controller. My personal app is too small for appreciating such separation of concerns.</p><p>And that’s how I made this (simple) backend. My takeaway from it is that Nest is solid framework, that offers a lot of possibilities and is a bit more opinionated than traditional Express framework. With this, I only scratched a surface — Nest is very capable and does much more than this. If you want to know more, read <a href="https://docs.nestjs.com/">Nest documentation</a> and try it on your own, I can nothing but recommend it. If you want to see the whole app, it’s on my <a href="https://github.com/Mareddie/quizae">Github</a>.</p><p>In my next article, I’ll share my insights of project infrastructure and server environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a07a64063c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>