{
    "componentChunkName": "component---src-templates-post-template-js",
    "path": "/pl/yoda_principle_in_command_design/",
    "result": {"data":{"post":{"id":"3515133d-74bc-50dc-a99a-80e399869b17","html":"<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 626px; height: auto\"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b559c6d70cdf5430d251306c8b61d60b/b09c1/2026-04-20-cover.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 62.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADaklEQVQ4yx2T209aBwCHeWsVETkH8AIM1MP1gCCCgNyRA3IOFy+zqLVa7928rFjNYqe2W5Zd7Lo128OSxd2SXV7arFn2tCXL/rNvqQ+/fPnevpefTrAO0j/oQLAMYLUOMTrsJegLIwfGiUYDJJMhHHYH3lEffk+AiBxhea7OxuoCzVqZmfQUEyPDDIsi7ZgbXT47TTZdpq7OM9taYrbVZql9H2W6yVgoTjoVoqrE2Vi/xzub97l8fMDrV8/59ZdPeHb1kIMHc6jFOIaebsZcVnSaNsvG+h47Wwfs7jxke/OQ7a1DdrYPaTbuUi6lUYphTjprPH92xB+vv+Kfv6/5+afPOO6soKmTpDMyjkERffdtdFqjTWtumXK1SSqrkMyUiSVyJDMFLPZRQuMyd5cVjt5d4HC/zXJ7mqeXu3z0dI/TRysszmUoZIOkJnwMmIzojOZBuo1muowmbhv7uNVrxOnx4Rh1ozcJGEwCFSXBpx/v0VQzrK/VaGop1OokK+0iiYlRMikf2akwNlFEpzf1oRcEegSBXtFMr9lCjyhiNPffrMvYR2TMzf5OgxcvHnF6ukYhH2Flscpk1E/AayMeHaVeT5KO+dH1ihb6rIP0WYfoEUT0JhGD8KbMjN4okC9muTw/4s5CjrOzTXZ256lVYzeezwRJxNz4PDZCsouGlkbnlEI4pCBOKYh92Id5yIlB7MclSXz45JT//n3J7799S6U4QbkQIRQcIRaRSEQlEhMSYdmJ3+PAPTyA7LWjC0YyBMJTeOU43kDshpIvyjdff85ff/7I9XdXXJ536BeNhGUXPrediOxE9tiRXAM47WbGxvxUlBzxcT+6RHqGeFIhOllkPJ4jMJZkRm3y6uX3/HD9JSfHezx+/5Ahs4jNYUb2Owl4HQR9DpwOC4Kpl6mpJNWqQioeQ1eq3qFYXSRXapEvNYnGSnQ67/HF1QXbW6us3WtzcrpPIhzE0HULt8eGJNmw2y0Yum4zYnegajMoShGtVkGnqfOo2iJqfQW1uUpBWeT4+IQnF8eUy3laLY29Bxs0VQWbwYBFNCIIBvr7erH1GMilEjQaNaqVEmpNefOUBnW1SUObpdF4G63e5oPzMy7OO8zNquSyU6yvL7G0vEDY5UIyCXisFmRLP8G3nNRqFapKiUq5SKmQ43+v/sNA+sEiigAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"cover\"\n        title=\"cover\"\n        src=\"/static/b559c6d70cdf5430d251306c8b61d60b/b09c1/2026-04-20-cover.png\"\n        srcset=\"/static/b559c6d70cdf5430d251306c8b61d60b/36ca5/2026-04-20-cover.png 200w,\n/static/b559c6d70cdf5430d251306c8b61d60b/a3397/2026-04-20-cover.png 400w,\n/static/b559c6d70cdf5430d251306c8b61d60b/b09c1/2026-04-20-cover.png 626w\"\n        sizes=\"(max-width: 626px) 100vw, 626px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<blockquote>\n<p>Try not. Do. Or do not. There is no try!</p>\n</blockquote>\n<p>I’m calling this the Yoda Principle.</p>\n<p><a href=\"https://www.youtube.com/watch?v=BQ4yd2W50No\">Master Yoda said that to Luke Skywalker a long time ago in a galaxy far, far away</a>. He was teaching Luke how to name commands properly while trying to untangle some legacy enterprise mess.</p>\n<p>I’m sure you’ve also seen a death star of weirdly-named stuff. Some of them have already tripped you hours of thinking whether someone named this thing badly, or there’s some hidden truth behind it.</p>\n<p><strong>Let’s discuss that by the example: E-Commerce order fulfilment.</strong></p>\n<p>The order is placed automatically once the customer confirms the items in the shopping cart. We’re not making any product reservations before the shopping cart is confirmed, as this would lock it for other customers, and, as you know, they tend to drop items from their carts.</p>\n<p>Once we receive the event notification that the cart has been confirmed, we’ll start the order fulfilment process. It starts (as mentioned) with the order initiation, which acknowledges and initiates the multi-step fulfilment process.</p>\n<p>The first step is checking product availability before confirming the order. We need to determine whether we can proceed with completing the shipment and initiating product payment. If the product is unavailable, we need to either ask the customer to wait until we have it again or cancel the order.</p>\n<p>We have dedicated modules for order fulfilment and for inventory. Fulfilment is the orchestrator, and inventory is responsible for tracking the state in warehouses.</p>\n<p>The ordering module would need to call the inventory module to verify product availability. We could send a command (through the messaging system or web api). How would we name it?</p>\n<p>What about <strong><em>VerifyProductExists</em></strong>? We’d send the product id and quantity from the order information, and return true if we have enough products, false otherwise. Sounds fair, right?</p>\n<p>Well, it may seem nice at first glance, but what happens if more than one order verifies the same product availability, and we’re running short?</p>\n<p>Then we’re vulnerable to race conditions I described in <a href=\"/pl/tell_dont_ask_how_to_keep_an_eye_on_boiling_milk/\">Tell, don’t ask! Or, how to keep an eye on boiling milk</a>. The information we get is only valid at the time of querying. If we don’t lock the product quantity, it can change before we get a response (think: Black Friday-like demand).</p>\n<p><strong>Naming our command like <em>VerifyProductExists</em> is a mistake</strong>.</p>\n<p><em>VerifyProductExists</em> is not even a command; it’s a query. Command is a request (intention) to run business logic. Query is a request to return data.</p>\n<p>Of course, pragmatically, our <a href=\"/pl/can_command_return_a_value/\">command can return status information about the result of our operation</a>. But the intention is different.</p>\n<p><strong>What’s our real intention here?</strong></p>\n<p>The real intention is that we’d like to reserve products so we can ship them and get payment for them, not to verify if they exist. It’d be better to name our command as ReserveProducts or LockProducts.</p>\n<p>Why does it matter?</p>\n<p>If we’re naming our commands with Verify/Validate/Check prefixes, we’re putting ourselves into the wrong mindset. We’re not focused on actions and integrations, but just brief checking. If we’re in such a mode, it’s easy to handwave the integration complexity.</p>\n<p>Locking for shipment may require sending someone to double-check that the product is in the warehouse and hasn’t been stolen, damaged, or other steps. It may be an async process on its own. Still from the ordering module, we should not care, as we’re telling what our intention is and expect to get events informing us whether the reservation succeeded, failed, or timed out (we don’t want to lock products forever in case of order fulfilment issues, but only for some time).</p>\n<p><strong>Prefixes like Verify/Validate/Check, etc., are just synonyms for trying.</strong> And well, commands are always a form of trying. The handling module can reject the command, as its business rules and state are the source of truth.</p>\n<p>We should always assume that the command processing can fail. We should not be discouraged by that, and we should double-check everything. We should not be intimidated by the potential failure, but prepared for it.</p>\n<p><strong>We should try not. Do or do not. There is no try.</strong></p>\n<p>What if we have both? So <em>VerifyProductExists</em> and <em>LockProducts</em>? It can work if the first one is a query used by the Shopping Cart module, without any guarantee that the data isn’t stale, on a best-effort basis.</p>\n<p>If we’re always requiring VerifyProductExists from the handling module before LockProducts, we’re making our communication chatty. I described that in <a href=\"/pl/what_does_mr_bean_opening_the_car_have_to_do_with_programming/\">What does Mr Bean opening the car have to do with programming?</a> that this is not only a bad developer experience, but also just redundancy. Locking should already verify whether the product exists, so why require someone to memorise those scenarios instead of checking it internally?</p>\n<p>The same goes for cases like:</p>\n<ul>\n<li>verify payment has been made,</li>\n<li>check if the order wasn’t already fulfilled,</li>\n<li>validate if the shipment has been completed,</li>\n<li>etc.</li>\n</ul>\n<p>All of them either hide a missing business concept or should be a business rule verified within the specific action (e.g., confirming an order).</p>\n<p>I recognise this may seem nitpicky, but big things are built on small details.</p>\n<p>If we don’t think about such things, we’ll not only end up with misnamed integrations but also fight <a href=\"/pl/dealing_with_race_conditions_in_eda_using_read_models/\">race conditions</a> and incorrect boundaries.</p>\n<p>Then <a href=\"https://www.youtube.com/watch?v=cTwZZz0HV8I\">we’ll be doomed</a>.</p>\n<p>So better think twice and do or do not.</p>\n<p>May the force be with you!</p>\n<p>Oskar</p>\n<p>p.s. <strong>Ukraine is still under brutal Russian invasion. A lot of Ukrainian people are hurt, without shelter and need help.</strong> You can help in various ways, for instance, directly helping refugees, spreading awareness, putting pressure on your local government or companies. You can also support Ukraine by donating e.g. to <a href=\"https://www.icrc.org/en/donate/ukraine\">Red Cross</a>, <a href=\"https://savelife.in.ua/en/donate/\">Ukraine humanitarian organisation</a> or <a href=\"https://www.gofundme.com/f/help-to-save-the-lives-of-civilians-in-a-war-zone\">donate Ambulances for Ukraine</a>.</p>","excerpt":"Try not. Do. Or do not. There is no try! I’m calling this the Yoda Principle. Master Yoda said that to Luke Skywalker a long time ago in a…","fields":{"slug":"/yoda_principle_in_command_design/","prefix":"2026-04-20","langKey":"pl"},"frontmatter":{"title":"Yoda Principle for better integrations","author":"oskar dudycz","category":"Event Sourcing","disqusId":null,"useDefaultLangCanonical":true,"cover":{"childImageSharp":{"resize":{"src":"/static/b559c6d70cdf5430d251306c8b61d60b/2a4de/2026-04-20-cover.png"}}}}},"authornote":{"id":"f1fb8a26-256d-5b24-9b06-ad19a0c2961b","html":"<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; height: auto\"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/f748655e118b2b9d5ce6b7dd6f9f4f85/d2429/2021-10-13-cover.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 55.99999999999999%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAA6cAAAOnAEHlFPdAAAChUlEQVQozyXOTU/acBwA4J+FFmgp/5RCX2AlFVgUgxTCYZNA6KZMooPSiAoaZ8bLjTmEbALRePAygyaLBEl0lyWePGji1YsnT8YDBxMTE+9+iiXu+QQPPDw8nJ2dtVqtZrNZr9cbjUYul8tkMvl8vt1un5yc3Nzc3N7eDofDu7u74+Pj+/v7x8fH6+vr8/NzGA6HOzs73W53f3+/0+mUSqVisbi3t3d0dNTv9w8PDy8uLnq93sHBQblcrtfrp6enl5eXrVarUqnA8/OzruvLy8uDwUDTtJmZmWw22+12Nzc3q9VqKpUqFovT09OFQsHr9SaTyZWVlVgspmlaoVCAl5cXRVE4jotGowghiqJIkpybm/N4PAsLCwghRVF0Xff5fHa7HQDi8Xg6nQaASCQCT09PwWAQXrEsa7VaZVlOp9NjY2Nut1uWZYIgWJYVRZEkSYZhLBaL0WgkCCIUCkGv1xMEAcMwo9EIABRFEQQhSVI0GhUEwWAw0DQ9OjqK4zhFUQzD2O12HMc5jhMEAa6urmRZRgglEgmHwzEyMuJyuXZ3d2u12tTUFAAQBOF0Onmep2mae2V6heM4bG1tIYR4nk8kEqIoAkAgEOh0OvF4XJIkADCZTDzPu1wuk8lks9kQQhiGmc1mkiTB65U5zun3+xFCPp+P5znaRquqGg6HcdyIYRiO4+VyeWlp6f+CpmmDwWAxm0VRAFX9kM3mVlfXJidDPv/bN24pHI4kkyrDMCRJjo8HJMnz6dNsq9W2WmmzhWRZB2W1BSaCmqbDxrfK9naj/r2az2fWvxTfvY98La2pakxRJuY/zy4u5jLZtPox/uPnxvp6YTalLurz7WZt8PvX3z/9f7APp/oT02NdAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"cover\"\n        title=\"cover\"\n        src=\"/static/f748655e118b2b9d5ce6b7dd6f9f4f85/a331c/2021-10-13-cover.png\"\n        srcset=\"/static/f748655e118b2b9d5ce6b7dd6f9f4f85/36ca5/2021-10-13-cover.png 200w,\n/static/f748655e118b2b9d5ce6b7dd6f9f4f85/a3397/2021-10-13-cover.png 400w,\n/static/f748655e118b2b9d5ce6b7dd6f9f4f85/a331c/2021-10-13-cover.png 800w,\n/static/f748655e118b2b9d5ce6b7dd6f9f4f85/d2429/2021-10-13-cover.png 805w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Through my window, I see the result of good plans but poor execution. Opposite my flat, there is a partially completed construction place. Buildings were supposed to be eye-catching Mediterranean style apartments.  Delivery date? Two years ago. Actual? More and more unknown.</p>\n<p>Some time ago, I heard that using Event Sourcing makes creating Event-Driven Architecture easier. The arguments were correct, that if we’re already publishing events to trigger business workflows, then at some point, we may want to also store events to not lose information. Agreed. However, I also heard that keeping the state as events will simplify things. We’ll have a source of truth with a record of the system behaviour. This will allow, e.g. to confront the results of the operations with the recorded state. I’d agree with that, with one distinction. It’s easier as long as you already know Event Sourcing.</p>\n<p>Many people in the DDD community claim that the essential is to properly break down the system into autonomous parts called bounded contexts. Once we have it, the rest is secondary and will sort itself out. For sure.</p>\n<p>Many seasoned programmers speak similarly about new technologies. They claim that they can translate past experience into new technologies. That’s true that by analogy, they can catch the big picture quicker. But isn’t it a bold assumption to say that Win.Forms specialist will learn Angular quickly?</p>\n<p>The end result may differ a lot from the initial ideas. I saw the plan of those buildings next to me. Now I can see the effects of the execution. Or actually, the lack.</p>\n<p>I believe that we should carefully acknowledge not only the point of view of our authorities but also their seating point. If we want to find out how to form a wall, do we ask an architect or a foreman? An architect may know the theory, but the practice is what we’re looking for. On the other hand, if you want to know where to put the wall, you prefer the architect to do measurements. At least if you don’t want to have the roof falling to your head.</p>\n<p>After I had torn a ligament in my knee, I went to two qualified orthopedists. One said I should have surgery and do a reconstruction. The second stated that there is no need for that; rehabilitation should be enough. Guess which one had a specialization in surgery and which in rehabilitation?</p>\n<p>People usually give us advice from the point where they’re currently standing. They are entitled to a biased view. An architect who rarely does programming will tend to downplay the value of implementation and tactical patterns. Midlevel developers will focus on technicalities instead of the global system impact. The team manager or consultant will emphasize the importance of soft skills (or esoteric techniques known only to them).</p>\n<p>The truth is that we need all of them. The excellent plan will fall on the bad execution. The best execution for the wrong case will be just a waste of time. We should carefully evaluate the advice considering what we need and what an expert can give us.</p>\n<p>Therefore, when we’re reading an article, watching a talk, let’s also pay attention to the place where the person is standing. The perspective from there may be much different from where we are right now. That can be good, as it may push us in the right direction. But it may also be misleading, as we accidentally take biases of this person without understanding the tradeoffs. Personally, I prefer to follow not only people from pedestal but also those that are closer to my position. A bit further in the journey, but not too far. That helps me to calibrate my view as those people are more relative to my daily struggles.</p>\n<p>Polish historical leader <a href=\"https://en.wikipedia.org/wiki/J%C3%B3zef_Pi%C5%82sudski\">Józef Piłsudzki</a> reportedly used to say: <em>“Right is like an ass, everyone has its own”</em>.</p>\n<p>Cheers!</p>\n<p>Oskar</p>"},"site":{"siteMetadata":{"facebook":{"appId":""}}}},"pageContext":{"slug":"/yoda_principle_in_command_design/","lang":"pl","langKey":"pl","prev":{"id":"b926df88-a08c-5390-a100-75bcdf3bcffe","fields":{"slug":"/passive_aggressive_events/","prefix":"2026-04-13","source":"posts","langKey":"pl"},"frontmatter":{"title":"Anti-patterns in event modelling - Passive-Aggressive Events","category":"Software Architecture"}},"source":"posts"}},
    "staticQueryHashes": ["2742854296"]}