<?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 Sergey Atroshchenko on Medium]]></title>
        <description><![CDATA[Stories by Sergey Atroshchenko on Medium]]></description>
        <link>https://medium.com/@kapxapot?source=rss-a38e5a13d2b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TgbZnN-33KfnVfZMBX86bQ.jpeg</url>
            <title>Stories by Sergey Atroshchenko on Medium</title>
            <link>https://medium.com/@kapxapot?source=rss-a38e5a13d2b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 21:12:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kapxapot/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[Code Readability in the Age of LLM-Written Code]]></title>
            <link>https://medium.com/@kapxapot/code-readability-in-the-age-of-llm-written-code-4ebb0ac165fc?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ebb0ac165fc</guid>
            <category><![CDATA[code-readability]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 13:51:56 GMT</pubDate>
            <atom:updated>2026-07-06T13:51:56.240Z</atom:updated>
            <content:encoded><![CDATA[<p>We used to talk about <strong>code readability</strong> mostly as a human problem.</p><blockquote>Can another developer understand this function?<br>Can I return to this file in six months and still know what is going on?<br>Can the next person change this without breaking half of the system?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uX0ylXUPIWPQZX-e_c-gKQ.png" /></figure><p>That still matters.</p><p>But now there is another reader in the room.</p><p><strong>The LLM.</strong></p><p>And if most of the code in a modern codebase is written, edited, refactored, or “quickly fixed” by LLMs, then code readability is no longer only about humans. It is also about whether future LLM sessions can understand the codebase well enough to make good changes.</p><p>There is such a thing as <strong>code readability for LLMs</strong>.</p><p>And I think it is becoming more important than we admit.</p><h3>This is not only a feeling</h3><p>There is already research around this topic.</p><p>An <strong>Atlassian</strong> industrial case study, <a href="https://arxiv.org/abs/2501.11264">“Code Readability in the Age of Large Language Models”</a>, looked at code readability in the context of real LLM-based development. The paper surveyed practitioners and compared code generated by Atlassian’s LLM-based software development agent framework with human-written code in real-world scenarios.</p><p>The interesting result is not that “LLM code is always bad.” It is more subtle than that. The study found that readability still remains critical for developers, and that their <strong>LLM-generated code was comparable in readability to human-written code</strong>. That is important. It means LLM-generated code can be readable. But it also means readability does not become irrelevant just because the code was generated by AI.</p><p>Another recent paper, <a href="https://arxiv.org/abs/2605.13280">“The Readability Spectrum: Patterns, Issues, and Prompt Effects in LLM-Generated Code”</a>, looked at thousands of code-generation scenarios and compared readability patterns between human-written and LLM-generated code. Again, the result was not simply “LLM code is unreadable.” The paper found that LLM-generated code can have overall readability comparable to human-written code, but <strong>it also has distinct readability issue patterns</strong>. The authors also found that prompt details like function signatures, constraints, and style descriptions influence readability, but <strong>prompt engineering alone has limited impact</strong>.</p><p>That last part matters a lot.</p><p>You can write a better prompt. You should write a better prompt. <strong>But a prompt does not fully protect a codebase from technical debt.</strong></p><p>There is also research on non-functional quality of LLM-generated code. The paper <a href="https://arxiv.org/abs/2511.10271">“Quality Assurance of LLM-generated Code: Addressing Non-Functional Quality Characteristics”</a> reviewed existing research, ran industry workshops, and analyzed LLM patches. One of its important observations is that academic work often focuses on security and performance, while <strong>industry practitioners care strongly about maintainability and readability</strong>. The paper also warns that <strong>generated code may accelerate technical debt</strong> if quality is not controlled.</p><p>This matches what many developers already feel in practice.</p><p>The problem is not only whether AI code works today.</p><p>The problem is whether it leaves the codebase in a state where humans and future AI agents can safely continue tomorrow.</p><p>There are also more specific signals from research that support this. <a href="https://openreview.net/forum?id=8t5TlFzUAU">“Revealing What LLMs Actually Understand About Code”</a> studies the role of structure and naming in LLM code understanding, and shows that removing meaningful names harms intent comprehension. Another paper, <a href="https://aclanthology.org/2024.findings-acl.809/">“Enhancing Code LLMs with Comment Augmentation”</a>, shows that comments and natural-language alignment can improve code-focused LLM performance.</p><p>So this is not only an aesthetic preference.</p><blockquote>Names matter.<br>Structure matters.<br>Comments matter.<br>Readable code matters.</blockquote><p>Not only for humans.</p><p>For models too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6_kyo80RObCOKBK-hR8aw.png" /></figure><h3>Human readability vs LLM readability</h3><p>Human-readable code helps a developer understand intent.</p><p>LLM-readable code helps a model infer intent from limited context.</p><p>These two things overlap, but they are not identical.</p><p>Humans can ask around. Humans remember previous discussions. Humans can say, <em>“Ah yes, this ugly part exists because of that production incident from last year.”</em> Humans can smell something weird even if the code technically compiles.</p><p>An LLM usually sees a slice of the codebase. A file. A few related files. Some search results. Maybe a README. Maybe not. <strong>Then it tries to continue the pattern it sees.</strong></p><p>That means LLM-readable code needs to make important things very explicit:</p><ul><li>what this module is responsible for</li><li>what it must never do</li><li>which layer owns which logic</li><li>what business rule is being protected</li><li>where side effects happen</li><li>what pattern should be copied</li><li>what pattern should not be copied</li></ul><p>For humans, a clever abstraction can sometimes be acceptable if the team understands it.</p><p>For LLMs, cleverness is often just fog.</p><p>The more implicit the architecture is, the more the model has to guess. And when LLMs guess inside a codebase, they often produce code that looks plausible but weakens the structure.</p><h3>Models are pattern-continuation machines</h3><p>This is the core thing.</p><p><strong>Models are pattern-continuation machines.</strong></p><p>They do not understand your codebase like a senior engineer who has carried the system in their head for three years. They mostly continue what they see.</p><p>If the nearby code is clean, typed, consistent, and boring, the model usually extends that style.</p><p>If the nearby code is messy, duplicated, vague, and full of workarounds, the model learns that this is acceptable.</p><p>Or, more directly:</p><p><strong>If the codebase contains clean, consistent patterns, the model usually extends them. If the codebase contains muddy patterns, the model treats the mud as the house style.</strong></p><p>This is why uncontrolled LLM coding is dangerous.</p><p>Not because every LLM change is bad. Many are good. Some are very good.</p><p>The danger is that small bad changes become examples for the next change.</p><blockquote>One vague helper becomes two.<br>One duplicated validation block becomes a pattern.<br>One any added to “fix TypeScript” becomes normal.<br>One business rule hidden in a React component gets copied into another component.<br>One route handler becomes a place where everything happens.<br>One workaround becomes architecture.</blockquote><p>And after a while, the code still works, but it becomes harder to reason about.</p><p>For humans.</p><p>And for LLMs.</p><h3>The codebase can become unreadable even for the LLM</h3><p>This is the part that feels new.</p><p>We already know code can become unreadable for humans. We call it <em>legacy code</em>, <em>spaghetti code</em>, <em>a big ball of mud</em>, <em>technical debt</em>, whatever.</p><p>But with LLMs, there is a second-order problem.</p><p>The codebase can become worse training material for its own future changes.</p><p>A human developer can sometimes look at a messy codebase and say:</p><p><em>“Okay, this is bad. I will not copy this pattern.”</em></p><p>An LLM is much more likely to say, implicitly:</p><p><strong><em>“This is the pattern.”</em></strong></p><p>If your codebase contains three different ways to handle errors, the LLM may invent a fourth.</p><p>If auth checks are sometimes in middleware, sometimes in route handlers, sometimes in UI components, the LLM may put the next auth check wherever it happens to be editing.</p><p>If storage access is sometimes wrapped in services and sometimes called directly from components, the LLM may not preserve the boundary.</p><p>If naming is vague, the model loses semantic anchors.</p><p>If comments describe outdated behavior, the model may trust them.</p><p>If tests are weak, the model optimizes for passing TypeScript instead of preserving intent.</p><p>This is how code becomes less readable for LLMs:</p><p><strong>The model has less signal and more noise.</strong></p><blockquote>It cannot distinguish architecture from accident.<br>It cannot distinguish intended pattern from historical garbage.<br>It cannot distinguish business rule from workaround.<br>It cannot distinguish “this is how we do it” from “this was rushed at 2 AM.”</blockquote><p>And then it writes more code in the same muddy style.</p><h3>Context debt</h3><p>Technical debt is when the code is harder to change later.</p><p><strong>Context debt is when the code is harder to explain later.</strong></p><p>LLM-heavy development creates context debt very easily.</p><p>A model can generate a lot of code very quickly. That feels productive. But if the generated code does not preserve structure, naming, boundaries, and intent, then every future change becomes more expensive.</p><p>Not immediately.</p><p><strong>That is the trap.</strong></p><blockquote>The app still builds.<br>The feature still works.<br>The UI looks okay.<br>The PR does not look catastrophic.</blockquote><p>But the codebase becomes a little less obvious.</p><blockquote>Then the next LLM session needs more context.<br>Then the next prompt needs more corrections.<br>Then the model edits the wrong file.<br>Then it fixes a symptom instead of the cause.<br>Then it duplicates logic because it did not find the existing one.<br>Then it weakens types because the existing types are confusing.<br>Then you spend more time reviewing AI code than you would have spent writing it yourself.</blockquote><p>This is the hidden cost.</p><p>The cost is not just bad code.</p><p>The cost is worse future AI assistance.</p><h3>A clean codebase makes the LLM better</h3><p>This is the positive side.</p><p><strong>A clean codebase makes the LLM better. A muddy codebase makes the LLM worse.</strong></p><p>This is not motivational advice. It is practical.</p><p>If the codebase has clear file names, strong types, consistent patterns, small modules, explicit business rules, and useful tests, the LLM has better material to work with.</p><blockquote>It can find the right place to edit.<br>It can copy the right pattern.<br>It can infer the intended architecture.<br>It can avoid inventing new abstractions.<br>It can keep changes smaller.</blockquote><p>In a good codebase, the LLM feels smarter.</p><p>In a bad codebase, the same model feels much dumber.</p><p>That is not magic. That is context quality.</p><p>The model is only as good as the codebase it is asked to continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6BDUL6sqcqvMOQN3ik-Sw.png" /></figure><h3>What uncontrolled LLM coding does to a codebase</h3><p>The most common damage is not dramatic. It is boring.</p><p>That is why it is dangerous.</p><p>Uncontrolled LLM coding usually does not destroy the system in one commit. It slowly lowers the quality bar.</p><p>Typical symptoms:</p><p>Vague names start appearing. handleData, processResult, item, payload, config, utils.</p><p>Logic gets duplicated because the model did not find the existing function.</p><p>Types get weaker because it is easier to satisfy the compiler with any than to understand the domain.</p><p>Components get smarter and services get thinner.</p><p>Business rules move closer to the UI because that is where the visible problem was.</p><p>Error handling becomes inconsistent.</p><p>Fallbacks appear everywhere.</p><p>Comments explain what the code does, but not why it should exist.</p><p>Tests are updated to match the new behavior instead of protecting the intended behavior.</p><p>The code still looks “reasonable” in small pieces, but the whole system becomes harder to modify.</p><p>This is exactly how <em>a big ball of mud</em> is created.</p><p>Not by one terrible decision.</p><p>By many small decisions that were never reviewed as architecture.</p><h3>Treat LLM output as a junior developer PR</h3><p>This is the rule I keep coming back to:</p><p><strong>Treat LLM output as a junior developer PR.</strong></p><p>Not because the LLM is useless.</p><blockquote>A junior developer can write good code.<br>A junior developer can be fast.<br>A junior developer can solve real problems.</blockquote><p>But you do not let a junior developer silently redefine the architecture of your system.</p><blockquote>You review the diff.<br>You check the boundaries.<br>You ask why a new helper exists.<br>You reject unrelated refactoring.<br>You do not accept “it works” as the only criterion.<br>You do not allow types to be weakened just to make an error disappear.</blockquote><p>LLM output should be treated the same way.</p><blockquote>The model can produce the first draft.<br>The model can implement the boring parts.<br>The model can suggest a fix.<br>The model can help with tests.<br>The model can speed things up.</blockquote><p>But the responsibility for code quality stays with <strong>the developer</strong>.</p><p>Especially architectural quality.</p><h3>The dangerous prompt: “just fix it”</h3><p>A lot of LLM code damage starts with vague prompts.</p><blockquote>“Fix this.”<br>“Refactor this.”<br>“Make it better.”<br>“Clean this up.”<br>“Implement this feature.”</blockquote><p>These prompts are too open.</p><p>The model may touch too many files.</p><p>It may introduce unnecessary abstractions.</p><p>It may change behavior accidentally.</p><p>It may hide the real issue behind a fallback.</p><p>It may make the local problem disappear while making the system worse.</p><p>A better prompt is narrower:</p><blockquote>“Make the smallest change needed.”<br>“Follow the existing pattern in this file.”<br>“Do not introduce new abstractions.”<br>“Do not change public behavior.”<br>“Do not weaken types.”<br>“Explain every file you changed.”<br>“If the existing code is unclear, point that out instead of guessing.”</blockquote><p>This sounds slower, but it is usually faster.</p><p>Because the expensive part is not generating code.</p><p>The expensive part is recovering from bad generated code after it has polluted the codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SaNIRzZQ1k_3_fxNRt1jQg.png" /></figure><h3>LLM-readable code is boring code</h3><p>The best code for LLM-assisted development is usually boring.</p><ol><li>Explicit names.</li><li>Small files.</li><li>Clear module boundaries.</li><li>Strong types.</li><li>Few clever abstractions.</li><li>Consistent error handling.</li><li>Business rules close to the code that enforces them.</li><li>Tests that describe intended behavior.</li><li>Comments that explain constraints, not syntax.</li></ol><p>For example, this kind of comment is useful:</p><p><em>“Do not expose precise location to team members.”</em></p><p>This is much better than:</p><p><em>“Loop through locations.”</em></p><p>The first comment gives the LLM a constraint. The second comment just repeats the code.</p><p>LLMs need constraints. They need strong signals. They need clear examples of what matters.</p><p>A codebase full of implicit knowledge is fragile in the age of AI coding.</p><h3>The real risk: AI accelerates entropy</h3><p>Every codebase naturally moves toward entropy.</p><blockquote>People rush.<br>Requirements change.<br>Deadlines happen.<br>Temporary fixes become permanent.<br>Nobody has time to clean up everything.</blockquote><p>LLMs accelerate this process if they are not controlled.</p><p>They produce more code.</p><p>They produce it faster.</p><p>They make it easier to add one more helper, one more fallback, one more duplicated block, one more abstraction.</p><p>So the risk is not that LLMs write bad code.</p><p>The risk is that LLMs make it very easy to write too much code without enough judgment.</p><p>And judgment is the scarce part.</p><blockquote>Not typing.<br>Not boilerplate.<br>Not syntax.</blockquote><p><strong>Judgment.</strong></p><blockquote>Where should this logic live?<br>Should this abstraction exist?<br>Is this fallback hiding a bug?<br>Is this type correct?<br>Is this change local or architectural?<br>Will the next developer understand this?<br>Will the next LLM understand this?</blockquote><p>These are still human questions.</p><h3>How I would keep an LLM-heavy codebase healthy</h3><p>I would use a few simple rules.</p><ol><li>Every LLM change should be small enough to review properly.</li><li>No unrelated refactoring inside feature work.</li><li>No new abstraction without a clear reason.</li><li>No weakening of types unless explicitly justified.</li><li>No duplicate business rules.</li><li>Important product constraints should be written near the code.</li><li>Tests should protect behavior, not just increase coverage.</li><li>The project should have a short AI coding guide.</li></ol><p>Something like:</p><blockquote>“Make minimal changes. Follow existing patterns. Do not introduce new libraries. Do not move business logic into UI components. Do not weaken types. Do not change auth, privacy, payment, or storage behavior unless explicitly requested.”</blockquote><p>That kind of document is not bureaucracy.</p><p>It is context.</p><p>And in LLM-assisted development, context is infrastructure.</p><h3>The new definition of clean code</h3><p>Clean code used to mean code that humans can read, understand, and safely change.</p><p>That is still true.</p><p>But now I would extend it.</p><p><strong>Clean code is code that humans and LLMs can both continue without making the system worse.</strong></p><p>That means the codebase itself becomes part of the prompt.</p><blockquote>Every file is an instruction.<br>Every naming convention is an instruction.<br>Every duplicated block is an instruction.<br>Every messy workaround is an instruction.<br>Every clean boundary is an instruction too.</blockquote><p>The LLM will learn from whatever you leave behind.</p><p>So leave behind code that teaches the right thing.</p><p>Because the future of software development is not just humans reading code.</p><p>It is humans and machines repeatedly editing the same codebase.</p><p>And in that world, readability is not a luxury.</p><p><strong>It is control.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ebb0ac165fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best IP Geolocation APIs in 2026: Pricing, Accuracy & Free Tier Comparison]]></title>
            <link>https://medium.com/@kapxapot/best-ip-geolocation-apis-in-2026-pricing-accuracy-free-tier-comparison-14e9691b2055?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/14e9691b2055</guid>
            <category><![CDATA[geolocation]]></category>
            <category><![CDATA[ip-geolocation]]></category>
            <category><![CDATA[mapfolks]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 00:00:53 GMT</pubDate>
            <atom:updated>2026-03-24T05:21:28.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*raNZ7ezNO_n-1rEO.png" /></figure><p><em>This article is a part of the series of blog articles from my project </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em>, that allows to share your approximate location (up to country, region or city) with your friends and teammates privately and securely.</em></p><p>Choosing the right IP geolocation API is not just about price. It affects accuracy, HTTPS security, timezone detection, scalability, and long-term reliability.</p><p>In this guide, we compare the most popular IP geolocation APIs in 2026, including:</p><ul><li>Free tier limits</li><li>Pricing</li><li>HTTPS support</li><li>Timezone data quality</li><li>Accuracy considerations</li><li>Real-world usage in Mapfolks</li></ul><h3>What Is IP Geolocation?</h3><p>IP geolocation is the process of estimating a user’s physical location based on their IP address.</p><p>It typically returns:</p><ul><li>Country</li><li>Region / state</li><li>City</li><li>Latitude / longitude</li><li>ISP</li><li>Timezone</li></ul><p>It does <strong>not</strong> provide GPS-level precision and should not be treated as exact location data.</p><h3>How Accurate Is IP Geolocation?</h3><p>Accuracy varies by provider and IP type.</p><p>Typical real-world accuracy:</p><ul><li><strong>Country:</strong> 95–99%</li><li><strong>Region:</strong> 80–95%</li><li><strong>City:</strong> 50–80%</li><li><strong>Mobile IPs:</strong> Often less accurate</li><li><strong>VPN users:</strong> Frequently inaccurate</li></ul><p>IP geolocation databases rely on ISP allocation data and routing patterns. Mobile carriers and VPNs significantly reduce precision.</p><p>IP geolocation should be treated as <strong>approximate</strong> location.</p><h3>IP Geolocation vs Device GPS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*8hHWdTkaHANd1XThGNJY4w.png" /></figure><p>For production applications, GPS (device geolocation) is far more reliable. IP geolocation is best used for onboarding, timezone detection, and fallback scenarios.</p><h3>Free vs Paid IP Geolocation APIs</h3><p>Free tiers are suitable for:</p><ul><li>MVP validation</li><li>Development</li><li>Low traffic projects</li><li>Non-critical timezone prefill</li></ul><p>Paid tiers are needed when:</p><ul><li>Traffic increases</li><li>Commercial use requires SLA</li><li>Higher accuracy is required</li><li>Proxy / VPN detection matters</li></ul><h3>Top 5 IP Geolocation APIs Compared</h3><h3>IP-API</h3><p><a href="https://ip-api.com/">ip-api.com</a></p><p><strong>Why popular:</strong> Extremely simple integration.</p><h4>Free Tier</h4><ul><li>45 requests/minute</li><li>No API key required</li><li>❌ No HTTPS support on free tier</li><li>Returns single timezone string</li><li>City-level precision</li></ul><h4>Paid Tier</h4><ul><li>~€13–15/month</li><li>Removes limits</li><li>HTTPS enabled</li></ul><h4>Strengths</h4><ul><li>Clean timezone field</li><li>Fast and easy setup</li><li>Reliable for development</li></ul><h4>Weaknesses</h4><ul><li>Free tier lacks HTTPS</li><li>Not suitable for production without upgrade</li></ul><p><strong>Mapfolks experience:</strong> We originally used IP-API during development. It returned a single accurate timezone string and provided good city-level detection. However, the lack of HTTPS on the free tier made it unsuitable for production deployment.</p><h3>FreeIPAPI</h3><p><a href="https://freeipapi.com/">freeipapi.com</a></p><p><strong>Why interesting:</strong> Free tier supports HTTPS.</p><h4>Free Tier</h4><ul><li>HTTPS supported</li><li>No aggressive rate limiting</li><li>Returns <strong>array of timezones</strong></li><li>Basic city precision</li></ul><h4>Strengths</h4><ul><li>Production-ready free HTTPS</li><li>Simple deployment</li></ul><h4>Weaknesses</h4><ul><li>Timezone returned as array (not ideal for precise timezone detection)</li><li>Slightly less accurate than IP-API in testing</li></ul><p><strong>Mapfolks experience:</strong> We switched to FreeIPAPI to ensure HTTPS support in production. It works well for offset calculations, but because it returns multiple possible timezones, it is less helpful for determining the exact user timezone.</p><h3>IPinfo</h3><p><a href="https://ipinfo.io/">ipinfo.io</a></p><h4>Free Tier</h4><ul><li>Requires signup</li><li>Limited monthly requests</li><li>HTTPS supported</li><li>Clean timezone field</li></ul><h4>Paid Tier</h4><ul><li>Starts around $49/month</li></ul><h4>Strengths</h4><ul><li>High data reliability</li><li>Regularly updated database</li><li>Suitable for commercial products</li></ul><h4>Weaknesses</h4><ul><li>Higher entry price</li></ul><p>Best suited for products generating revenue.</p><h3>IPGeolocatio.io</h3><p><a href="https://ipgeolocation.io/">ipgeolocation.io</a></p><h4>Free Tier</h4><ul><li>~30,000 requests/month</li><li>HTTPS supported</li><li>API key required</li><li>Returns timezone field</li></ul><h4>Paid Tier</h4><ul><li>Starts around $15/month</li></ul><h4>Strengths</h4><ul><li>Generous free tier</li><li>Balanced pricing</li><li>Good middle-ground option</li></ul><h4>Weaknesses</h4><ul><li>Requires signup</li></ul><h3>IPstack</h3><p><a href="https://ipstack.com/">ipstack.com</a></p><h4>Free Tier</h4><ul><li>Very limited monthly usage</li><li>HTTPS supported</li><li>API key required</li></ul><h4>Paid Tier</h4><ul><li>Starts around $12.99/month</li></ul><h4>Strengths</h4><ul><li>Established provider</li><li>Clean API structure</li></ul><h4>Weaknesses</h4><ul><li>Free tier too small for active apps</li></ul><h3>IP Geolocation API Pricing Comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*rZlFFPMewLOA4fxoF-Qxpw.png" /></figure><h3>Timezone Detection Comparison</h3><p>Timezone data format matters more than most developers expect.</p><p><strong>Single timezone string</strong> (IP-API, IPinfo, IPGeolocation.io, IPstack)</p><p><strong>Array of timezones</strong> (FreeIPAPI)</p><ul><li>Usable for offset calculation</li><li>Harder for precise timezone resolution</li></ul><p>If your product depends on exact timezone (e.g., scheduling, event timing), format consistency matters.</p><h3>Which IP Geolocation API Is Best for Startups?</h3><p><strong>If you need free HTTPS:</strong> FreeIPAPI or IPGeolocation.io</p><p><strong>If you want clean timezone field without paying:</strong> IP-API (development only)</p><p><strong>If you are launching paid product:</strong> IPinfo or IPGeolocation.io paid tier</p><p><strong>If accuracy and reliability matter long term:</strong> Plan to migrate to a commercial-grade provider once revenue allows.</p><h3>How Mapfolks Uses IP Geolocation</h3><p>Mapfolks does not rely solely on IP-based location.</p><p>We use a layered model:</p><ol><li>Device geolocation (GPS / browser API) — primary source</li><li>IP geolocation — fallback</li><li>Manual city selection — user override</li></ol><p>IP geolocation is used to:</p><ul><li>Prefill timezone</li><li>Suggest approximate region</li><li>Improve onboarding UX</li></ul><p>Once device location is shared, it becomes authoritative.</p><p>IP geolocation remains a convenience layer — not a source of truth.</p><h3>Frequently Asked Questions</h3><h4>Is IP geolocation accurate?</h4><p>It is accurate at country level (95–99%), moderately accurate at region level, and inconsistent at city level, especially for mobile or VPN users.</p><h4>Do free IP geolocation APIs support HTTPS?</h4><p>Some do (FreeIPAPI, IPGeolocation.io, IPinfo). IP-API’s free tier does not.</p><h4>Can IP geolocation detect exact timezone?</h4><p>Some providers return a single timezone string, which helps. However, VPN usage and IP inconsistencies can still reduce reliability.</p><h4>Is IP geolocation reliable for production apps?</h4><p>It can be used as a fallback or onboarding helper. For precise tracking, device geolocation is significantly more reliable.</p><h3>Should startups pay for IP geolocation?</h3><p>Free tiers are sufficient for MVPs. Once traffic or reliability requirements increase, paid plans become necessary.</p><h3>Final Thoughts</h3><p>IP geolocation APIs vary significantly in:</p><ul><li>Free tier restrictions</li><li>HTTPS availability</li><li>Timezone data structure</li><li>Accuracy</li><li>Pricing</li></ul><p>For early-stage products, free tiers can work. For revenue-generating platforms, upgrading to a paid provider improves reliability and long-term scalability.</p><p>Mapfolks currently uses FreeIPAPI for secure free HTTPS support but plans to migrate to a more robust paid provider once revenue allows.</p><p><em>This article is a part of the series of blog articles from my project </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em>, that allows to share your approximate location (up to country, region or city) with your friends and teammates privately and securely.</em></p><p><em>Originally published at </em><a href="https://mapfolks.com/blog/best-ip-geolocation-apis-2026-pricing-accuracy-free-tier-comparison"><em>https://mapfolks.com</em></a><em> on February 19, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14e9691b2055" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UI Grammar vs Clarity: How We Write Copy in Mapfolks]]></title>
            <link>https://medium.com/@kapxapot/ui-grammar-vs-clarity-how-we-write-copy-in-mapfolks-dfb790388783?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfb790388783</guid>
            <category><![CDATA[mapfolks]]></category>
            <category><![CDATA[geolocation]]></category>
            <category><![CDATA[grammar]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 00:00:34 GMT</pubDate>
            <atom:updated>2026-03-13T08:20:09.186Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article is a part of the series of blog articles from my project </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em>, that allows to share your approximate location (up to country, region or city) with your friends and teammates privately and securely.</em></p><p>When you build a product, sooner or later you run into this question:</p><p><strong>Should UI text always be grammatically correct? Or is it better to shorten copy, even if that means breaking “proper” English?</strong></p><p>This isn’t a theoretical debate. It shows up in real product decisions every day.</p><p>In <a href="https://mapfolks.com/">Mapfolks</a>, it surfaced with a simple notification:</p><blockquote>“Sergey invited you to Test team.”</blockquote><p>Should it be:</p><blockquote><em>“the Test team”?</em></blockquote><p>Short answer: <strong>yes — in this case, absolutely.</strong></p><p>Long answer: let’s talk about how we approach UI copy in <strong>Mapfolks</strong>, and why.</p><h3>UI Copy Is Not Formal English (and That’s OK)</h3><p>First, an important clarification.</p><p><strong>UI copy is not the same as written prose.</strong> It lives under very different constraints:</p><ul><li>limited space</li><li>fast scanning instead of reading</li><li>repetition</li><li>international users</li><li>mobile screens</li></ul><p>Because of that, <strong>perfect grammatical correctness is not the primary goal</strong>.</p><p>Clarity, speed, and tone matter more.</p><p>That’s why you see patterns like:</p><ul><li>“Invite sent”</li><li>“Location updated”</li><li>“Added to team”</li><li>“Join team”</li></ul><p>These are not full sentences — and that’s fine.</p><p>This isn’t laziness. It’s a <strong>UI dialect</strong> that users intuitively understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/0*saHhfY6-F2d-8v_A.png" /></figure><h3>But There Is a Line You Shouldn’t Cross</h3><p>While shortening text is often good UX, <strong>not all UI text is equal</strong>.</p><p>The moment your product:</p><ul><li>addresses a user directly</li><li>mentions another person</li><li>describes a social action</li><li>sends a notification or invite</li></ul><p>…it stops being “interface chrome” and starts being <strong>human communication</strong>.</p><p>And <em>that</em> is where grammar matters.</p><h3>The Mapfolks Example (Why “the” Matters)</h3><p>Let’s look at the example again:</p><blockquote><em>“Sergey invited you to Test team.”</em></blockquote><p>From a UX point of view, this line:</p><ul><li>names a real person</li><li>describes a personal action</li><li>represents the product speaking <em>on someone’s behalf</em></li></ul><p>That means it should read the way a person would actually speak.</p><p>Grammatically correct version:</p><blockquote><em>“Sergey invited you to the Test team.”</em></blockquote><p>Without <strong>“the”</strong>, the sentence feels:</p><ul><li>system-generated</li><li>slightly ESL (English as a Second Language)</li><li>less polished</li><li>less trustworthy</li></ul><p>It’s a small word — but small things compound.</p><p>Especially in a product like <strong>Mapfolks</strong>, where trust, privacy, and human relationships are central.</p><h3>When Shortcuts Are OK (and Encouraged)</h3><p>We intentionally relax grammar in places where:</p><ul><li>the text is structural</li><li>the meaning is obvious</li><li>speed matters more than tone</li></ul><p>Examples that are perfectly fine:</p><ul><li>“Invite to team”</li><li>“Join team”</li><li>“Pending invites”</li><li>“Team settings”</li><li>“Invite sent”</li></ul><p>These are <strong>labels or states</strong>, not messages from a person.</p><p>Users don’t expect full sentences here.</p><h3>When Grammar Must Be Correct</h3><p>In <strong>Mapfolks</strong>, we treat these as <strong>non-negotiable</strong>:</p><ul><li>notifications</li><li>invitations</li><li>emails</li><li>user-to-user actions</li><li>anything that could be read aloud naturally</li></ul><p>If the text sounds wrong when spoken, it’s wrong in the UI.</p><h3>The Mapfolks Copy Style Guide</h3><p>This is the internal rule set we follow.</p><h3>1. Labels and Buttons</h3><ul><li>Short</li><li>Fragment-style</li><li>Articles optional</li></ul><p>✅ “Invite to team”<br>✅ “Join team”<br>✅ “Team members”</p><h3>2. Status Messages and Toasts</h3><ul><li>Compact</li><li>Neutral</li><li>Grammar relaxed but clear</li></ul><p>✅ “Invite sent”<br>✅ “Location updated”<br>✅ “Settings saved”</p><h3>3. Notifications and Invites</h3><ul><li>Full sentences</li><li>Grammatically correct</li><li>Human tone</li></ul><p>✅ “Sergey invited you to the Test team”<br>❌ “Sergey invited you to Test team”</p><h3>4. Emails</h3><ul><li>Fully correct English</li><li>Friendly but precise</li><li>No UI shortcuts</li></ul><p>Emails are not UI chrome — they represent the brand directly.</p><h3>A Simple Rule of Thumb</h3><p>We use this decision rule internally:</p><blockquote>If the text could be spoken aloud by a person, it must be grammatically correct. If it’s a UI label or state, grammar can be relaxed.</blockquote><p>It’s simple, but it scales surprisingly well.</p><h3>Why This Matters for Mapfolks</h3><p><strong>Mapfolks</strong> is not a CRUD dashboard or an internal admin tool.</p><p>It’s about:</p><ul><li>people</li><li>location</li><li>trust</li><li>social context</li><li>privacy</li></ul><p>Language is part of the product experience.</p><p>Tiny grammatical slips don’t just look sloppy — they subtly undermine confidence.</p><p>And confidence is everything when you’re asking users to:</p><ul><li>share where they are</li><li>invite others</li><li>join teams</li><li>trust a map with real human connections</li></ul><h3>Final Thoughts</h3><p>Shortening UI text is good UX. Breaking grammar blindly is not.</p><p>In <a href="https://mapfolks.com/">Mapfolks</a>, we don’t aim for academic English — we aim for <strong>clear, human, intentional language</strong>.</p><ul><li>❌ “Sergey invited you to Test team” is not acceptable</li><li>✅ “Sergey invited you to the Test team” is</li></ul><p>It’s a small detail — and small details are what make a product feel thoughtful instead of rushed.</p><p><em>This article is a part of the series of blog articles from my project </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em>, that allows to share your approximate location (up to country, region or city) with your friends and teammates privately and securely.</em></p><p><em>Originally published at </em><a href="https://mapfolks.com/blog/ui-grammar-vs-clarity"><em>https://mapfolks.com</em></a><em> on January 4, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfb790388783" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I Learned from Internationalizing my Web Projects]]></title>
            <link>https://medium.com/@kapxapot/what-i-learned-from-internationalizing-my-web-projects-f5a9d2d6d8b9?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5a9d2d6d8b9</guid>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[i18n]]></category>
            <category><![CDATA[translation]]></category>
            <category><![CDATA[i18next]]></category>
            <category><![CDATA[internationalization]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 10:36:34 GMT</pubDate>
            <atom:updated>2026-03-07T12:53:08.270Z</atom:updated>
            <content:encoded><![CDATA[<h3>What I Learned from Internationalizing My Web Projects</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kT4uIoa1ITCo8orpvcjwLw.jpeg" /><figcaption>A team working hard on a global project</figcaption></figure><h3>Why internationalize?</h3><p>First of all, why should you translate your projects into other languages? In other words, why should you internationalize them?</p><ol><li>By adding other UI languages to your project you make it <strong>more accessible</strong>.</li><li>The more languages your project supports, the <strong>wider</strong> your project’s <strong>audience</strong> is.</li><li>Sometimes internationalization is a must, e.g., when your target audience lives in <strong>different countries</strong> and speaks different languages.</li></ol><p>In other words, if you want to make your project (or your product) <strong>global</strong>, you should support several languages.</p><blockquote>By the way, my native language is Russian, but I write my articles in English to get as wide audience as one language can give me.</blockquote><h3>Should every project be internationalized from the start?</h3><p>If internationalization is so beneficial, why don’t internationalize all projects from the start? Like any other decision in tech, this is also a tradeoff.</p><blockquote><strong>“Internationalization”</strong> is a very long word. Let’s use <strong>“i18n”</strong> instead. This abbreviation is often used in i18n libraries. I wish there was a shorter version for “internationalize” too! 😅</blockquote><p>I wouldn’t say these are <em>the cons</em> of i18n, but it definitely brings several complexities which slow the development process as a result:</p><ol><li><strong>You have to write extra code</strong> that handles the current language, the language switching, etc. There are libraries for every platform and programming language which can help, but you have to choose one and to learn using it. Good news is that usually it should be done just once — you find a library of choice and can use it all the time after that. Also, writing your own translation logic is not that hard (I did that for one of my projects!), but it requires <em>additional work and time</em> anyway.</li><li><strong>You have to restructure your code.</strong> The texts must be extracted and put in separate resource files for more convenient translation and management. In the ultimate case there should be no user-facing texts in your code at all! 😲 Also, the code logic has to be corrected sometimes. Without translation it is just a static text, but to translate it, you need a context (you have to know the current language, dude!)</li><li><strong>You have to translate the texts!</strong> This one is really unexpected, right? I know, I know! The more languages you support, the more translation work has to be done. In many cases, you need additional people for that. Also, the texts can change with time (along with the UI and code changes), especially during the early development stages when a lot of churn can happen. This is not the best time to translate everything, I assure you.</li></ol><p>So, as a summary, let’s agree that not every project has to be internationalized from the start. Moreover, not every project should be translated into other languages at all.</p><ul><li>The project <strong>must</strong> be internationalized from the start, if the target audience speaks different languages.</li><li>The project <strong>should</strong> be internationalized, if there is a chance that the target audience speaks different languages. It can be internationalized from the start or on a later stage.</li><li>The project <strong>should not</strong> be internationalized, if it’s targeted for a specific audience speaking just one language. I18n will be just a waste of time and resources.</li></ul><h3>What about internationalizing an already existing project?</h3><p>It’s totally possible, so it’s never too late to translate your project into several languages.</p><p>I did exactly that with three of my projects:</p><ol><li><a href="https://brightwood-builder.onrender.com/"><strong>Brightwood Builder</strong></a>: A local-first React app that allows editing interactive stories. Initially it was in English, later I added Russian, Spanish, Italian and Japanese to it.</li><li><a href="https://t.me/BrightwoodBot"><strong>Brightwood Bot</strong></a>: A Telegram bot that plays interactive stories (it works in a pair with the builder). This one was in Russian initially, then I added English to it too.</li><li><a href="https://gptoid.botfarm.store/"><strong>GPToid Bot</strong></a>: Another Telegram bot that allows talking to ChatGPT and generating DALL-E images for free. It was also in Russian initially, now it’s in English too.</li></ol><p>There must be a couple of considerations though:</p><ol><li>As I mentioned above, consider <strong>using a library</strong> to speed up the process and avoid reinventing the wheel. In two of my projects I used the <a href="https://www.i18next.com/"><strong>i18next</strong></a> package that works perfectly with <strong>React</strong> and <strong>Node.js</strong>.</li><li>Sometimes it’s enough just to extract the text lines into resource files (like <a href="https://github.com/kapxapot/brightwood-builder/blob/master/src/translation/locales/ru.json">this one</a>), but in more complex cases <strong>the code has to be refactored</strong> and restructured to support i18n. For example, my bot <strong>GPToid</strong> uses text descriptions generated from several chunks that must be structured differently in different languages. Internationalizing that required additional work and even now it’s not perfect and I will have to modify the code to add more languages. 😕</li><li>Someone still has to <strong>translate those texts</strong>. It’s good when you know both languages, but it’s also a work anyway. <strong>AI</strong> can help with that too. I used my own bot <a href="https://gptoid.botfarm.store/"><strong>GPToid</strong></a> to translate my projects, including <strong>GPToid</strong> itself. 😁 The <a href="https://www.cursor.com/"><strong>Cursor</strong></a> IDE also works like a charm when you need to do a translation, but it’s a paid service.</li></ol><h3>So… What I’ve Learned?</h3><p>I’ve learned a lot, first of all, that I should build my own projects with i18n from the start if I plan them for the global audience.</p><p>Now let’s dive deeper in <strong>the technical details</strong> of the i18n.</p><p>Let’s take a look at how translation is organized in the code. For example, we have a <strong>React</strong> project with the following markup:</p><pre>export function SaveStories() {<br>  return &lt;span&gt;There are no saved stories yet.&lt;/span&gt;;<br>}</pre><h4>Using Special Dictionary Keys</h4><p>If we use <a href="https://react.i18next.com/">react-i18next</a> for i18n, the modified code could look like this:</p><pre>import { useTranslation } from &quot;react-i18next&quot;;<br><br>export function SaveStories() {<br>  const { t } = useTranslation();<br><br>  return &lt;span&gt;{t(&quot;noSavedStories&quot;)}&lt;/span&gt;;<br>}</pre><p>The translations are put in a separate file (or files) and can look like this:</p><pre>{<br>  &quot;en&quot;: {<br>    &quot;noSavedStories&quot;: &quot;There are no saved stories yet.&quot;<br>  },<br>  &quot;ru&quot;: {<br>    &quot;noSavedStories&quot;: &quot;Сохраненных историй пока нет.&quot;<br>  }<br>}</pre><ul><li>t() is a function that translates a text string.</li><li>The first parameter is the key that is used to find a translation in the dictionary.</li><li>If no translation is found, the default language is used (it’s English in this case).</li><li>If the default language’s dictionary doesn’t contain the key, the key is displayed.</li><li>Additional languages can be added at any time. Just add a dictionary and it’s done!</li></ul><p>Note that we used a special dictionary key in this case. This is the recommended way to localize code.</p><p>This approach gives the following results:</p><ol><li>The text is removed from the code completely. Only dictionary keys are left.</li><li>As a result we have a “textless” code which has a clean look.</li><li>The reverse side of this medal is that we can’t understand the UI texts from the code only, we need to check the dictionary files to understand what’s being displayed in the UI.</li><li>Another benefit of this approach is that to change the texts we don’t have to touch the code at all. It means that text and translation changes can be done by non-technical people or integrated systems.</li><li>This also makes translation more convenient when a translator just takes the original language dictionary (English in this case) and creates another dictionary based on it.</li></ol><p>I recommend using this approach for large projects, large teams and when the project is internationalized in more than 2 languages.</p><h4>Using Text as Dictionary Keys</h4><p>The original text in the default language also can be used as dictionary keys. It is not a recommended approach but it still can be done and has its benefits. Let’s take a look.</p><p>The code will look like this:</p><pre>import { useTranslation } from &quot;react-i18next&quot;;<br><br>export function SaveStories() {<br>  const { t } = useTranslation();<br><br>  return &lt;span&gt;{t(&quot;There are no saved stories yet.&quot;)}&lt;/span&gt;;<br>}</pre><p>And the dictionary will be like this:</p><pre>{<br>  &quot;en&quot;: {},<br>  &quot;ru&quot;: {<br>    &quot;There are no saved stories yet.&quot;: &quot;Сохраненных историй пока нет.&quot;<br>  }<br>}</pre><p>Note that the original dictionary is very skinny here, in many cases it will be empty because all the texts are still in the code.</p><p>So what’s good and what’s bad here?</p><ol><li>As I already mentioned, the default dictionary is almost empty because its texts are still in the code.</li><li>This way the code can be read as usual — we don’t need to switch between code and dictionaries to understand what’s going on.</li><li>The translation changes become more complicated though. In some cases we still need to use special keys. For example, a phrase <strong>“Save Story”</strong> can be translated differently depending on the context. It can be a noun in a title and a verb in a button. 😮 In this case we need 2 different entries in the dictionary and we can’t use the same text for both because all keys must be unique. We can use <strong>“saveStoryNoun”</strong> and <strong>“saveStoryVerb”</strong> keys for example or use <strong>“Save Story”</strong> for a noun and <strong>“saveStoryVerb”</strong> for a verb (like I did <a href="https://github.com/kapxapot/brightwood-builder/blob/master/src/translation/locales/en.json">here</a>). Do you see how complicated it has become? <strong>This is the main drawback of this approach.</strong></li><li>Also, when some keys are just text and some keys are special keys (like above), how do we understand which one is which? You have to check the original dictionary for that always when you are not sure if it’s a special key or an original text used as a key. 😪</li><li>When I asked people to translate resource files for such a project, they also had problems with understanding what to translate. I couldn’t give them the default dictionary since it’s almost non-existent and the only reference for them was another language dictionary done by me.</li></ol><p>Shortly speaking, this approach can be <strong>fine for a small project</strong> developed by someone who is both a developer and a translator. In all other cases I do not recommend it.</p><h4>Value Interpolation</h4><p>What if we need to add a variable to our localized text? No problem:</p><pre>import { Language, Story } from &quot;types&quot;;<br>import { useTranslation } from &quot;react-i18next&quot;;<br><br>type Props = {<br>  stories: Story[];<br>  language: Language;<br>};<br><br>export function SaveStories({ stories, language }: Props) {<br>  const { t } = useTranslation();<br><br>  return (<br>    &lt;span&gt;<br>      {t(&quot;yourStories&quot;, {<br>        storyCount: stories.length,<br>        language: language.name<br>      })}<br>    &lt;/span&gt;<br>  );<br>}</pre><p>The dictionaries:</p><pre>{<br>  &quot;en&quot;: {<br>    &quot;yourStories&quot;: &quot;You have {{storyCount}} stories in {{language}} language.&quot;<br>  },<br>  &quot;ru&quot;: {<br>    &quot;yourStories&quot;: &quot;У вас {{storyCount}} историй на {{language}} языке.&quot;<br>  }<br>}</pre><p>Strictly speaking, language must be in <strong>the Prepositional case</strong> in Russian here but it’s another story. 😅</p><h4>Templates as Translations</h4><p>More than just texts need to be internationalized. Take <strong>dates</strong>, for example. Date formats can be different in different languages and l18n comes to help here too:</p><pre>{<br>  &quot;en&quot;: {<br>    &quot;dateFormat&quot;: &quot;MMM d, yyyy&quot;<br>  },<br>  &quot;ru&quot;: {<br>    &quot;dateFormat&quot;: &quot;dd.MM.yyyy&quot;<br>  }<br>}</pre><p>Then just use the localized date format in your code like this and you are done:</p><pre>formatDate(expiresAt, t(&quot;dateFormat&quot;));</pre><p>Templates are handy in other use cases too. For example, you need to build a phrase in different order in different languages. Just create a localized template for that in the translation dictionaries and use them based on the current language.</p><p>In other words, when <strong>any string or structure has to be different in several languages</strong>, i18n can help with that.</p><h4>Building Your Own Translation System</h4><p>I recommend using already existing i18n libraries in most cases. But it’s not that hard to create your own translation system.</p><p>You need to consider the following things:</p><ol><li>There must be a default fallback language when it’s impossible to detect the user’s language or the user doesn’t have a preference.</li><li>Usually it’s convenient if the user can switch languages. Your system must react accordingly.</li><li>If you add i18n to an existing project, all previously existing users must continue to see the UI in the same language as before. For example, if your project’s initial language was French and you add English and make it a default, all previously existing must still see the UI in French though they didn’t have any preference before.</li><li>All best practices mentioned above still apply.</li></ol><p>Let’s have a closer look at my example. I had an existing project that already used value interpolation and text parsing. Also, it was just a backend project that didn’t need a “hot switch” for the UI language. I decided to invent my own square wheel in this case.</p><p>This is how it looks (yes, it’s <strong>PHP</strong>):</p><pre>return<br>  StoryMessageSequence::textFinalized(<br>    &#39;❌ [[You\&#39;ve uploaded a document, but in a wrong place.]]&#39;,<br>    &#39;[[If you want to upload a story, use the {{upload_command}} command.]]&#39;<br>  )<br>  -&gt;withVar(&#39;upload_command&#39;, BotCommand::UPLOAD);</pre><ul><li>Notice that I already use {{..}} for value interpolation.</li><li>Initially it was just {..} but later I switched to double curly braces.</li><li>I use [[..]] to mark the text parts that need to be translated.</li><li>Yes, I use the original text keys here which is not recommended, but it is my solo project so it’s fine.</li></ul><h3>Conclusion</h3><p>Let’s summarize my lessons once again:</p><ol><li>If your project is targeted at the global audience or different countries, you should internationalize it from the start.</li><li>In other cases it’s up too you. If the need to localize a project arises later it can be done with a medium effort (depending on the project’s size and complexity).</li><li>It’s better to use existing i18n libraries to not reinvent the wheel.</li><li>Use special keys for dictionaries and extract all texts from your code. It’s especially efficient for larger projects and more than 2 languages.</li></ol><p>Thank you for reading! 🙏</p><blockquote>Feel free to follow me on <a href="https://x.com/kapxapot">X</a> and check my <a href="https://github.com/kapxapot">GitHub</a>.</blockquote><blockquote>My newest project is 🗺 <a href="https://mapfolks.com/">Mapfolks</a> — a web app that helps to share your approximate location with friends and teammates privately and securely.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5a9d2d6d8b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C#: Using “default!” for non-nullable strings]]></title>
            <link>https://medium.com/@kapxapot/c-using-default-for-non-nullable-strings-2599520568e4?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2599520568e4</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 09:32:50 GMT</pubDate>
            <atom:updated>2026-03-07T12:29:03.442Z</atom:updated>
            <content:encoded><![CDATA[<h3>C#: Using “default!” for non-nullable variables</h3><p>Let’s talk about a C# project with nullable references disabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uL6gRH6oF927IXxO" /><figcaption>Photo by <a href="https://unsplash.com/@andyjh07?utm_source=medium&amp;utm_medium=referral">Andy Holmes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Non-nullable references</h3><p>Usually, it’s configured on the project level in the .csproj file like this:</p><pre>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;<br>  &lt;PropertyGroup&gt;<br>    ...<br>    &lt;Nullable&gt;disable&lt;/Nullable&gt;<br>    ...<br>  &lt;/PropertyGroup&gt;<br>  ...<br>&lt;/Project&gt;</pre><p>Anyway, in such a project it is not possible to do things such as:</p><pre>string val;</pre><p>Or:</p><pre>public string UserName { get; set; }</pre><p>The compiler and the IDE are unhappy about that and consider that an error. Such strings must be initialized with a non-null value or changed to string? so they can be nullable.</p><p>But if a null is not an acceptable value, string? is not the right solution, so the variable or a property must be initialized.</p><h3>Non-nullable strings and “default!”</h3><p>The easiest way to do it is to assign a string.Empty to it (which is the same as &quot;&quot;). And that’s what I would do usually.</p><p>But there is another approach using the default keyword. This keyword means “use the type’s default value” which can be a different thing for different types. E.g., for a number it’s 0, and for a bool it’s false.</p><p>But for a string it’s null even if the project doesn’t allow nullable references. 🤯</p><p>The workaround for this is to use default! which means “it’s not a null, I assure you”. But it’s a null in this case anyway. So what’s really happening here is that we assign a null to a non-nullable string.</p><p>Let’s look into this and try to understand the pros and cons of this practice.</p><h3>Pros of “default!”</h3><p><strong>Avoids Compiler Warnings</strong>: Using default! can help you avoid compiler warnings about non-nullable fields not being initialized. This can be particularly useful in scenarios where the actual initialization happens later, such as in constructors or methods.</p><p><strong>Explicit Intent</strong>: The use of the null-forgiving operator (!) makes it explicit that you are intentionally bypassing the nullability check, which can be informative for other developers reading your code.</p><h3>Cons of “default!”</h3><p><strong>Potential for Runtime Errors</strong>: Using default! can lead to NullReferenceException at runtime if the variable is accessed before being properly initialized with a non-null value. This undermines the safety that non-nullable reference types are supposed to provide.</p><p><strong>Code Quality</strong>: Relying on default! can be seen as a workaround rather than a proper solution. It may indicate that the design of your class or method needs revisiting to ensure that all non-nullable fields are initialized correctly.</p><p><strong>Maintenance</strong>: Future maintainers of the code might overlook the default! usage and introduce bugs if they assume the variable has been properly initialized.</p><h3>Alternatives</h3><p><strong>Constructor Initialization</strong>: Ensure that all non-nullable fields are initialized in the constructor. This is the most straightforward and safest approach.</p><pre>public class MyClass<br>{<br>    private string _myString;<br><br>    public MyClass(string myString)<br>    {<br>      _myString = myString<br>          ?? throw new ArgumentNullException(nameof(myString));<br>     }<br>}</pre><p><strong>Lazy Initialization</strong>: If the value of the string is not immediately known, consider using a lazy initialization pattern.</p><pre><br>public class MyClass<br>{<br>    private string _myString;<br>    public string MyString =&gt; _myString ??= InitializeMyString();<br>    <br>    private string InitializeMyString()<br>    {<br>        // Initialization logic here<br>        return &quot;InitializedValue&quot;;<br>    }<br>}</pre><p><strong>Optionals or Wrappers</strong>: Use optional types or wrappers that explicitly handle the absence of a value.</p><pre>public class MyClass<br>{<br>    private string? _myString;<br>    public string MyString =&gt; _myString<br>        ?? throw new InvalidOperationException(“String not initialized”);<br>}</pre><h3>Example with “default!”</h3><p>If you still decide to use default!, here is how it might look:</p><pre><br>public class MyClass<br>{<br>    private string _myString = default!;<br><br>    // Ensure to initialize _myString in the constructor or before access.<br>    public MyClass()<br>    {<br>        _myString = &quot;InitializedValue&quot;;<br>    }<br>}</pre><h3>Conclusion</h3><p>While default! can be a quick fix, it’s generally better to ensure that non-nullable fields are properly initialized through constructors or other means. This approach maintains the integrity and safety of your code, making it more robust and easier to maintain.</p><p><em>This article was prepared using my Telegram bot </em><a href="https://t.me/GPToid_Bot"><em>GPToid</em></a><em>.</em></p><ul><li><em>Feel free to visit my </em><a href="https://github.com/kapxapot"><em>GitHub</em></a><em> profile.</em></li><li><em>Check out my newest project 🗺 </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em> that helps sharing your approximate location with your friends and teammates privately and securely.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2599520568e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Money in C#: Composite vs. Scalar]]></title>
            <link>https://medium.com/@kapxapot/money-in-c-composite-vs-scalar-598d5b5fa9bc?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/598d5b5fa9bc</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[scalar]]></category>
            <category><![CDATA[money]]></category>
            <category><![CDATA[composite]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Fri, 29 Mar 2024 18:26:21 GMT</pubDate>
            <atom:updated>2024-03-29T18:26:21.753Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0FcZJAwGqXJhWYf3C_P9w.png" /><figcaption>The AI’s grammar is preserved ;)</figcaption></figure><p>Some composite objects have a valid scalar representation.</p><p>For example, <strong>money</strong> consists of a currency and an amount, but calculations usually involve the amount part. When we deal with $100 and want to add $25, we do just 100 + 25.</p><p>But we would like to get not just 125, but $125 as a result. Let’s see how it can be accomplished in C#.</p><h3>Setup</h3><p>Let’s assume we have a class Money that looks like this:</p><pre>public class Money(Currency currency, decimal amount)<br>{<br>    public Currency Currency { get; } = currency;<br>    public decimal Amount { get; } =<br>        Math.Round(amount, 2, MidpointRounding.AwayFromZero);<br>}</pre><blockquote><strong>Note:<br></strong>We use decimal for the amount because it allows to store fractional numbers and stores the <strong>exact</strong> value which is crucial for financial calculations. Also, we need to store only 2 fractional digits because there cannot be fractions of cents, etc.</blockquote><p>Currency is just an enum:</p><pre>public enum Currency<br>{<br>    RUR,<br>    USD,<br>    EUR<br>}</pre><p>Let’s also define operator overloads so Money can be converted to decimal and int:</p><pre>public static implicit operator decimal(Money m) =&gt; m.Amount;<br><br>public static implicit operator int(Money m) =&gt; (int)m.Amount;</pre><blockquote><strong>Note:</strong><br>If money is converted to int, its fractional part is <strong>discarded</strong>. E.g., 1.4 becomes 1, 1.6 also becomes 1.</blockquote><p>We will also need a + operator overload to add numbers to Money and Money to Money:</p><pre>public static Money operator +(Money money1, Money money2)<br>{<br>    var converted = money2.ConvertTo(money1.Currency);<br>    return money1 + converted.Amount;<br>}<br><br>public static Money operator +(Money money, int amount) =&gt;<br>    money + (decimal)amount;<br><br>public static Money operator +(Money money, decimal amount) =&gt;<br>    new(money.Currency, money.Amount + amount);</pre><p>ConvertTo() method allows to convert money from one currency to another. Is looks like this and uses an extension method that abstracts the currency conversion details:</p><pre>public Money ConvertTo(Currency newCurrency)<br>{<br>    var newAmount = Amount.Convert(Currency, newCurrency);<br>    return new(newCurrency, newAmount);<br>}</pre><p>The remaining operations such as -, * and / can be implemented similarly and are out of this article’s scope.</p><h3>Playground</h3><p>The Money class with its overloaded operators and extension methods allows to perform the following operations seemlessly without conversions, casts and accessing the Amount property:</p><ul><li>Money + Money =&gt; Money</li><li>Money + int =&gt; Money</li><li>Money + decimal =&gt; Money</li><li>int + Money =&gt; int</li><li>decimal + Money =&gt; decimal</li></ul><p>E.g.:</p><pre>Money m = new(Currency.RUR, 100);<br>int x = 200;<br>var sumMoney = m + x; // gives `300 RUR`<br>var sumInt = x + m; // gives (int)300</pre><p>Other than the arithmetic operations, Money can be passed as an argument anywhere where decimal or int is expected:</p><pre>int TotalSum(int partOne, int partTwo) =&gt; partOne + partTwo;<br><br>Money m = new(Currency.USD, 100);<br>var total1 = TotalSum(m, 1000); // (int)1100<br>var total2 = TotalSum(1000, m); // (int)1100</pre><blockquote><strong>Note:</strong><br>The result is int in both cases regardless of the arguments order because it is converted to int upon a return.</blockquote><p>But be careful and keep in mind that consecutively adding several Money and/or numbers you can get unexpected results because of implicit conversions.</p><p>E.g., 100 RUR + 200 USD + 1000 will give a totally different result than 1000 + 100 RUR + 200 USD:</p><pre>Money m1 = new(Currency.RUR, 100);<br>Money m2 = new(Currency.USD, 200);<br>int x = 1000;<br><br>// everything is converted to the first currency<br>// converts $200 (m2) to RUR, adds 100 RUR (m1), after that adds another 1000<br>Console.WriteLine($&quot;{m1} + {m2} + {x} = {m1 + m2 + x} (gives `19152 RUR`)&quot;);<br><br>// everything is treated as numbers<br>Console.WriteLine($&quot;{x} + {m1} + {m2} = {x + m1 + m2} (gives (int)1300)&quot;);</pre><blockquote>Mathematically speaking, the money addition is not a <a href="https://en.wikipedia.org/wiki/Commutative_property">commutative</a> operation:<br>a + b != b + a</blockquote><p>Perform operations carefully:</p><ul><li>Prefer adding only two arguments, no more.</li><li>Be careful with the order: everything will be converted to the left argument’s type.</li><li>Use brackets to specify the operation order.</li></ul><p>E.g., if we want to calculate the Money sum first and then add it to a number, we can do it like this:</p><pre>Money m1 = new(Currency.RUR, 100);<br>Money m2 = new(Currency.USD, 200);<br>int x = 1000;<br><br>// converts USD to RUR, then adds RUR to 1000 and gives a number<br>Console.WriteLine($&quot;{x} + ({m1} + {m2}) = {x + (m1 + m2)} (gives (int)19152)&quot;);<br><br>// converts RUB to USD, then adds USD to 1000 and gives a number<br>// note that 201.11 USD is converted to int and becomes 201 (!)<br>Console.WriteLine($&quot;{x} + ({m2} + {m1}) = {x + (m2 + m1)} (gives (int)1201)&quot;);</pre><p>The full code example can be found in my GitHub repository: <a href="https://github.com/kapxapot/money-example">https://github.com/kapxapot/money-example</a></p><h3>Conclusion</h3><p>In this article we created a composite class which instances can be converted to scalar values and can take part in usual arithmetic operations as well as passed as scalar function arguments.</p><p>But be careful when writing a code like this. It is powerful and eloquent but can produce not so obvious results.</p><p>Note that the type conversion is not limited to numbers and arithmetics. Any class can be converted to any other. For example, a Customer can be a Person or a Company and that can be achieved not only by OOP or interfaces, but also by implicit type conversions. But that is another story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=598d5b5fa9bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Update the Page Preview in Telegram]]></title>
            <link>https://medium.com/@kapxapot/how-to-update-the-page-preview-in-telegram-beb24ddae5df?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/beb24ddae5df</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <category><![CDATA[twitter-summary-card]]></category>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[open-graph]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Sat, 17 Feb 2024 17:54:21 GMT</pubDate>
            <atom:updated>2026-03-07T12:21:16.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tb6SpZ8FW2VCfovL" /><figcaption>Photo by <a href="https://unsplash.com/@lanacodes?utm_source=medium&amp;utm_medium=referral">Lana Codes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>TLDR: Use <a href="https://t.me/WebpageBot">Webpage Bot</a>.</p><p><strong>Telegram</strong> shows page “cards” when a link is posted in any message. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*mHF97Ir8-RS7lQ5MQXamPA.jpeg" /><figcaption><a href="https://timezoned.vercel.app/">Timezoned</a> is a project of mine — check it out!</figcaption></figure><p>The card’s content is based on <strong>meta tags</strong> such as <a href="https://ogp.me/">Open Graph</a>, <a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary">Twitter Summary Cards</a>, or just ordinary titleand description meta tags.</p><p>This content is cached by Telegram and isn’t updated immediately when the page’s metadata changes. It means that once the link is posted, the card will look the same for all consecutive mentions even if the page is already updated and has different metadata.</p><p>But there is a way to refresh the page preview. Actually, there is a dedicated bot for that: <a href="https://t.me/WebpageBot">Webpage Bot</a>. It looks nothing like <a href="https://t.me/BotFather">BotFather</a>, for example, it doesn’t have an avatar or a description. But it works!</p><p>When you start a conversation with the bot, it asks you to paste up to 10 links to update them. Just send the links to the bot and it will refresh their previews!</p><p><em>BotFather has got a rich interface now and allows to edit localized metadata of your bots, but I also have my own tool for that: </em><a href="https://telebottle.vercel.app/"><em>Telegram Bot Manager</em></a><em> — it’s quick and simple and totally free!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=beb24ddae5df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Null[able] Hacks in C#]]></title>
            <link>https://medium.com/@kapxapot/null-able-hacks-in-c-65d79829d75c?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/65d79829d75c</guid>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[null]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 15:22:09 GMT</pubDate>
            <atom:updated>2026-03-07T12:17:26.202Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NqxTIqdrk4OvGCSI4WZxg.jpeg" /></figure><p>Did you know how null (and Nullable) work in different operations and logical statements in C#? Some aspects of it are not obvious.</p><p><em>This article is aimed at junior and middle C# developers.</em></p><h3>Arithmetics</h3><p>null “devours” other values in arithmetic operations and turns them into null:</p><pre>null + null: null<br>null + 1: null<br>1 + null: null<br>1 + 1: 2</pre><p><strong>How can it be used?</strong></p><p>No idea, but it’s interesting. Just keep this in mind.</p><h3>Comparison to numbers</h3><p>When null is compared to numbers, it is <strong>both not less and not greater</strong> than any number:</p><pre>null &gt; 0: false<br>null &lt; 2: false</pre><p><strong>How can it be used?</strong></p><p>For example, we work with a string but we don’t know if it’s null or not, and we need to check its length. The straightforward check can be like this:</p><pre>if (!string.IsNullOrEmpty(str) &amp;&amp; str.Length &gt; 10)<br>{<br>  // ...<br>}<br><br>// or<br><br>if (!string.IsNullOrWhiteSpace(str) &amp;&amp; str.Length &gt; 10)<br>{<br>  // ...<br>}</pre><p>IsNullOrWhiteSpace (just like IsNullOrEmpty) is a good (great!) practice, but in this case, it’s redundant since we check the string’s length immediately after that (which we have to do anyway). That’s why it can be written simply as:</p><pre>if (str != null &amp;&amp; str.Length &gt; 10)<br>{<br>  // ...<br>}</pre><p>Now our null hack comes to help and we can write it even shorter:</p><pre>if (str?.Length &gt; 10)<br>{<br>  // ...<br>}</pre><p>If str == null, the result of the statement is false since str?.Length == null and null &gt; 10 is false. If the string is not null, the ordinary length check is performed.</p><p>We can write a useful extension method using this approach:</p><pre>public static class Extensions<br>{<br>  public static string Truncate(this string str, int length)<br>  {<br>    return (str?.Length &gt; length)<br>      ? str.Substring(0, length)<br>      : str;<br>  }<br>}<br><br>// usage:<br><br>string? str1 = &quot;Hello, World!&quot;;<br>string? str2 = null;<br><br>Console.WriteLine(str1.Truncate(5)); // &quot;Hello&quot;<br>Console.WriteLine(str2.Truncate(5)); // null</pre><p>If the string is null, the result will be null. If the string is not longer than length, it will be returned as is. Otherwise, a substring will be returned.</p><h3>Comparison to booleans</h3><p>There are no surprises with boolean values. null is neither equal to true, nor equal to false:</p><pre>null == false: false<br>null == true: false<br>null != false: true<br>null != true: true</pre><p><strong>How can it be used?</strong></p><p>null is again an entity from another dimension that’s incompatible with everything. But this quality allows us to check bool? variables’ values more elegantly.</p><p>Boolean fields are common in database entities, and they can be nullable.</p><p>Let’s look at this code:</p><pre>using (var model = new Model())<br>{<br>  var project = model.Projects.Where(p =&gt; p.Id == 12345);<br>  // ...<br>}</pre><p>We need to check if the project is special, there is a bool? property project.IsSpecial for that. It can be null, false or true. The first two are <em>falsy</em> and only the third means truth.</p><p>Therefore, to check that the property is true, we need to check that it is not empty (it is not null) and that it is equal to true. If the property would not be nullable, we would write the check just like this:</p><pre>if (project.IsSpecial)<br>{<br>  // ...<br>}</pre><p>But the property is nullable, and it is needed to write a check like this:</p><pre>if (project.IsSpecial.HasValue &amp;&amp; project.IsSpecial.Value)<br>{<br>  // ...<br>}<br><br>// or<br><br>if (project.IsSpecial != null &amp;&amp; project.IsSpecial.Value)<br>{<br>  // ...<br>}</pre><p>We have to do 2 checks and also have to repeat the variable name. It can get even worse with a longer name:</p><pre>if (campaign.Project.IsSpecial != null &amp;&amp; campaign.Project.IsSpecial.Value)<br>{<br>  // ...<br>}</pre><p>This is both a code repetition and a not-very-readable code. We can declare an intermediate variable and make the code more readable:</p><pre>var isSpecial = campaign.Project.IsSpecial;<br><br>if (isSpecial != null &amp;&amp; isSpecial.Value)<br>{<br>  // ...<br>}</pre><p>While it is a good practice in general, there is a better option. Of course, using a nullable hack:</p><pre>if (project.IsSpecial == true)<br>{<br>  // ...<br>}<br><br>// or<br><br>if (project.IsSpecial ?? false)<br>{<br>  // ...<br>}</pre><p>Simple and elegant!</p><p>For a nested structure, it looks similar:</p><pre>if (campaign?.Project?.IsSpecial == true)<br>{<br>  // ...<br>}</pre><p>Note that we also don’t need to check separately the intermediate members for null.</p><p>What to do when we need to check a bool? value for a <em>falsy</em> value? Here you are:</p><pre>if (project.IsSpecial != true)<br>{<br>  // ...<br>}</pre><p>Note that the following code is not correct since the null value is also <em>falsy</em> and it is not taken into account:</p><pre>if (project.IsSpecial == false)<br>{<br>  // ...<br>}</pre><h3>Sorting</h3><p>We have found out that null is neither equal to true, nor equal tofalse. But what happens if the array of bool? is sorted?</p><p>Let’s take a look:</p><pre>var array = new bool?[]<br>{<br>  true, true, null, false, false, null, true<br>};<br><br>foreach (var item in array.OrderBy(i =&gt; i))<br>{<br>   Console.WriteLine(item == null ? &quot;null&quot; : item.ToString());<br>}</pre><p>The result:</p><pre>null<br>null<br>False<br>False<br>True<br>True<br>True</pre><p>The reverse order gives a reversed result (check it yourself).</p><p>It means that null is considered to be less than any other value during sorting. And it doesn’t depend on the type. Numbers and strings give the same result.</p><p><em>I hope you found this article helpful. Please, </em><strong><em>subscribe</em></strong><em> to me to get in touch. I also invite you to connect with me on </em><a href="https://x.com/kapxapot"><em>X</em></a><em> and </em><a href="https://github.com/kapxapot"><em>GitHub</em></a><em>.</em></p><p><em>Check my newest project 🗺 </em><a href="https://mapfolks.com/"><em>Mapfolks</em></a><em> where you can share your approximate location with friends and teammates!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65d79829d75c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To Rewrite or not to Rewrite?]]></title>
            <link>https://medium.com/@kapxapot/to-rewrite-or-not-to-rewrite-f82b5dd2767c?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f82b5dd2767c</guid>
            <category><![CDATA[maintenance]]></category>
            <category><![CDATA[rewrite]]></category>
            <category><![CDATA[legacy-systems]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[codebase]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Sun, 28 Jan 2024 16:40:45 GMT</pubDate>
            <atom:updated>2024-01-30T15:52:56.097Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This code is *****, it is needed to rewrite it!</blockquote><p>My 5 cents on this.</p><p><strong>In short:</strong> it’s not that simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxdnmIsYdxPd6yOeYBRcQA.jpeg" /></figure><h3>I am new here and your code stinks</h3><p>Of course, if a new developer on a legacy system says such words immediately — that’s a sign of arrogance and unprofessionalism—<strong>a red flag</strong> in other words.</p><p>1. There can be <strong>reasons</strong> for the code to be as it is. And it’s required to work with that code first, to implement new features and fix bugs first to understand it deeper.</p><p>2. <strong>“Don’t touch it if it works.”</strong> That’s applicable to codebases that just work. It can be terribly written, but if it works just like the business wants it to work, think ten times before making significant changes to it. And even then you should know that codebase like your native alphabet first.</p><p>3. Ok, you have studied the codebase, you have worked with it, and know its nooks and crannies. And you still think this codebase must be rewritten.</p><p>Even at this point the costs and risks must be considered:</p><ul><li>How long will it take to rewrite the code?</li><li>How exactly the developer will guarantee that it keeps the functionality? (<strong>A hint:</strong> integration or end-to-end tests can help, but that is also a lot of work.)</li><li>What happens if the developer working on the rewrite stops their work for any reason?</li></ul><h3>We have to do something!</h3><p>But there can be objective reasons for the desire to rewrite everything. Sometimes the codebase becomes an obstacle and maintaining it becomes more and more cumbersome and hence costly. This situation can cause a righteous desire to burn everything down and build a system anew from its ashes.</p><p>But that is also usually not the best decision. First of all, previously described problems with costs and risks apply as well. Secondly, there are other ways to help with the situation.</p><p>1. <strong>Tests and refactoring.</strong> Gradual refactoring can help. I enjoy this process a lot, making diamonds from piles of dung is very satisfying. But as with any code change, there are risks of breaking something and introducing bugs.</p><p>Tests can help with that again:</p><ul><li>Write a test to “capture” the expected behavior.</li><li>Make a change (refactor the code).</li><li>Check that everything still works as expected using the test.</li></ul><p>2. Extract or implement new features in <strong>a separate codebase</strong> or as <strong>a separate (micro)service</strong>. That is not always possible, but it still can be done occasionally. Again, the codebase must be well-known and analyzed first to understand its parts and what can be separated. <strong>CQRS</strong> and <strong>vertical slicing</strong> also can help with that.</p><h3>The end of the road</h3><p>And finally, there is another reason for rewriting the code. It can become unmaintainable or deprecated, hard or costly to deploy, or the developers leave the project and refuse to work on the system (and the salary raise again becomes too costly).</p><p>For example, the system needs to be moved into <strong>a cloud</strong> and the cloud doesn’t support the system’s <em>mammoth</em> tech stack. Yes, (almost) everything can be “dockerized”, but that is also a tradeoff.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82b5dd2767c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Recipe of the Ideal Mobile Game]]></title>
            <link>https://medium.com/@kapxapot/the-recipe-of-the-ideal-mobile-game-a5e363ed2aaf?source=rss-a38e5a13d2b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5e363ed2aaf</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[mobile-games]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[game-design]]></category>
            <dc:creator><![CDATA[Sergey Atroshchenko]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 16:11:13 GMT</pubDate>
            <atom:updated>2026-03-07T12:45:15.628Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Disclaimer 1.</strong> I don’t work in the game dev industry, but I am a web developer and a kind of “retired gamer” with a lot of experience (playing mobile games too). Currently, I play <strong>Genshin Impact</strong> and <strong>Omniheroes</strong>.</p><p><strong>Disclaimer 2.</strong> The focus here is on the <strong>“battle farm”</strong> game type. These games want you to log in daily, power up your heroes, progress in the campaign, etc. These games are usually played for months and even years. Games that evolve and expand. Examples: <strong>Hustle Castle</strong>, <strong>AFK Arena</strong>, and <strong>Age of Magic</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xquzRVW2qiht-OSyNT98kw.png" /></figure><h3>Intro</h3><p>Previously, I played on PC and consoles quite a lot, but recently I played mobile games mostly. I played numerous mobile games, some of them lasted for months and even years (meaning that they were decent). But I dropped them regardless. Why does it happen?</p><p>There are several reasons to continue playing a game and to quit it. I’ve been contemplating this for some time and extracted several patterns that can be seen in different games. I am going to try to portray the ideal mobile game based on that.</p><p>This article doesn’t pretend to be a revelation, mobile developers and designers may be well aware of these patterns, but there are a lot of new games that still have the same problems and mistakes, so maybe this text will be helpful.</p><h3>To play or not to play</h3><p>For starters let’s try to organize the reasons to play a game or to quit it, based on my experience.</p><p>Reasons to continue playing:</p><ul><li>There are daily activities (including free daily gifts).</li><li>I manage to do everything I want to do during the day (I don’t miss any opportunity).</li><li>The progress is steady and continuous (I don’t waste my time).</li><li>There is a challenge (some content requires effort but is manageable after some time due to progression).</li></ul><p>Reasons to quit:</p><ul><li>The game requires me to log in too often (especially at a specific and inconvenient time). And if I don’t log in I miss something (some gift or an opportunity).</li><li>It takes too much time (I spend too much time on it). Note that this is not only about chores but even about fun.</li><li>I don’t feel I am progressing (I waste my time).</li></ul><p>Eventually, all these reasons are linked to the time that the player spends on the game and if it’s fun/joy/satisfaction.</p><p>It means that the developers should aim to make the game fun and more satisfying and not require the player to spend much time on it (especially on chores).</p><h3>Motivation to log in</h3><p>Most of the games do it right — they motivate the player to log in every day, give gifts (that “grow on the farm”), and require them to earn other rewards (“battling”) — this is the formula of the “battle farm” in a nutshell.</p><p>But this motivation shouldn’t be overused. If the game makes you log in at 4 AM (otherwise you will miss some opportunities and will lag behind others) — it’s a bad game. Quit it immediately because you are going to quit it anyway eventually but you’ll have spent a lot of time on it by that time. Example: <strong>Deck Heroes</strong>.</p><p><strong>Solution 1.</strong> Complex and intermediate. Take the player’s timezone into consideration and make them log in at a specific time that is convenient to them (during the day). This approach complicates things and is not the ultimate solution. Example: <strong>Juggernaut Wars</strong>.</p><p><strong>Solution 2.</strong> Simple and final. The player is required to log in daily just once at any time. It can be one session or several shorter sessions — it doesn’t matter. Examples: <strong>AFK Arena</strong>, <strong>Call of Antia</strong> (and many other games).</p><h3>Energy</h3><p>Many players (especially those who come from “big” gaming platforms) don’t like the energy system because it limits them and motivates them to spend money (to overcome the limits). This is true, but the energy system is kind of a standard for mobile games, and even games without it have other limitations. For example, <strong>Hearthstone</strong> doesn’t have an energy system, but it puts a hidden daily limit on the rewards.</p><p>If the player has self-control and their credit card doesn’t burn their wallet, the energy system is helpful — it helps them not to spend too much of their time on the game. But, at the same time, the energy system is an additional motivation to log in (which is not good) — you have to spend it when it’s full, otherwise, the player’s efficiency with suffer. It can be compensated with energy recovery speed regulation. At the very least, it shouldn’t recover too fast so it is wasted because of the average human’s sleep duration (8–10 hours). Rejoice if your energy in the game recovers too slowly!</p><p>But the worst case about the energy is when everything is based on it in a game. If your game uses the energy system, add alternative modes that don’t use it so the player is not stuck without energy and still can progress. Although, many popular games do it right — e.g., the campaign requires energy but the “tower” mode doesn’t.</p><p><strong>Summary:</strong> energy is fine, but it shouldn’t recover too fast and shouldn’t be required in all game modes.</p><h3>Auto-battle</h3><p>“Battle” here does not necessarily mean the actual battle, it can be any kind of successful level or challenge completion (even if it’s playing solitaire).</p><p>If your game requires battling every day (especially with the same opponents) and these battles take minutes instead of seconds, it <strong>must</strong> have the auto-battle feature, otherwise, your game will eventually be abandoned even if it’s fun.</p><p>Ideally, there should be a switch between manual and automatic battles. And the majority of games have it.</p><p>Also, it is fine if the auto-battle brings lesser rewards than the manual battle potentially can bring. Again, the player should decide which is more effective for them at that moment. Spending more time vs. getting fewer rewards is a good trade-off.</p><p>If you are that “big platform” person again, you look for a challenge and love to control every action your characters take, it’s fine. But when you have to do the same action or pass the same level for the 10th (and even for the 100th!) time, this is not a challenge but a terrible chore, and eventually, you would want to delete such a game and forget about that nightmare.</p><p>Besides that, mobile games with auto-battle are convenient in such a way that you can start the battle and check the results after a minute or two, doing your own business in the meantime. And if the probability of success is just 20% and it will take 10 such attempts, it will take about 0 minutes of the actual player’s time.</p><p>The auto-battle seems to be another standard for “battle” games, but there are still wonderful games that lack it (or at least it wasn’t there at the time I played them): <strong>Sdorica</strong>, <strong>Legend of Solgard</strong>.</p><h3>Skipping the completed battles (auto-victory)</h3><p>The second derivative (???) from the battle is skipping of already completed battles (let’s call it “auto-victory”). Usually, to unlock this mode you have to complete all the objectives or pass the “battle” flawlessly (at 3 stars). Also, to skip it and receive rewards usually you have to spend energy or special tickets (which can also be an alternative energy system). It means that the amount of auto-victories can be limited but that’s fine from the player’s standpoint.</p><p>The most prominent example of when the auto-victory is necessary is the daily battles which are mandatory to complete hundreds of times (the guild boss battle or the daily quests). And if the game unlocks the additional modes with time which require to be “farmed” every day, eventually it becomes a boring chore that drives the players away.</p><p>Partially, it’s mitigated with auto-battles, but sometimes the AI is too dumb and can’t achieve the same results (= rewards) as the player. Also, the auto-battles still consume the screen time and the battery even if the player doesn’t spend their time on it.</p><h3>Challenge</h3><p>The mobile games have a zero entry level and if they provide the auto-battles, they can be played successfully even by a monkey. But the seasoned players most likely won’t be satisfied with that.</p><p>They will be likely eager to think over the strategy or to try different setups to pass the hard level, and overall characters and resources management can be entertaining. Once again, this shouldn’t become a chore and mustn’t block the progression (see above).</p><h3>More game modes and more content</h3><p>The more the player progresses through the game (and the game itself is developed) the more game modes and content are usually unlocked and added. The “farm” expands and more resources are available for farming. This is great, of course, but as a result the time needed to consume all this content also grows linearly and it is yet another path to the game’s demise.</p><p>If the new modes are added, the old ones should be able to “farm” faster or even instantly (alternatively, the old content can be finished once and forever and won’t need the player’s attention anymore).</p><p>This “improvement” destroyed <strong>AFK Arena</strong> for me which seemed to be ideal for a long time. I played it for more than a year and was not happy when the developers started to add new time-consuming modes and content (which was quite entertaining in its way). This negated the main feature — the “afk” feature (when your “farm grows” on its own) — and the game started to take too much time.</p><h3>More heroes!</h3><p>This is classic. Everyone understands why devs continuously add new heroes and new content with “opportunities”. They want money and some of the players want to spend their money on new heroes. And while they hug and kiss each other happily, common players (especially <strong>f2p</strong> ones) stay aside and watch solemnly.</p><p>As a result, common players have difficulties with collecting old heroes (or this process takes longer time) and they don’t need new heroes at all. It slows progression, makes players frustrated in general, and leads to their quitting.</p><p>There are ways to solve these problems too, e.g., allow players to put priorities on heroes so they drop more often (see <strong>AFK Arena</strong>). Or allow players to buy specific heroes in “shops”. Ideally, it should be possible to mark some heroes as “unwanted” so they don’t drop anymore, but this is just a dream… Meanwhile, we continue to get additional <strong>Dionas</strong> in <strong>Genshin Impact</strong> even after she is already at the full constellation.</p><p>Also, the devs can just add fewer heroes or at least use some metrics to understand if it’s the right moment to add new heroes or not yet.</p><h3>Compensations</h3><p>The good-mannered developers give players some gifts after every maintenance or fix. Usually, it’s “gems” which are always welcome by players.</p><p>Nowadays it is almost a gold standard for all games, which is good!</p><p>Also, I have a feeling that players are usually more grateful when devs are generous which also leads to players more willingly spending their real money on the game. I believe, there could be some metrics and research for this too.</p><h3>Conclusion</h3><p>That’s all for now, I believe. If you notice some other harmful or useful patterns in mobile games, feel free to share them in the comments.</p><p>And the last one. The most cursed games have <strong>“merge”</strong>, <strong>“tap”</strong> and <strong>“click”</strong> in their titles. Beware! ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5e363ed2aaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>