<?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 Yang Jing on Medium]]></title>
        <description><![CDATA[Stories by Yang Jing on Medium]]></description>
        <link>https://medium.com/@snowmanjy?source=rss-210d8a6888cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8szUh5MoBuUzFAzBaWLiIA.png</url>
            <title>Stories by Yang Jing on Medium</title>
            <link>https://medium.com/@snowmanjy?source=rss-210d8a6888cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:20:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@snowmanjy/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[Lessons learned: How to use AIs to cross-check to make sure code quality]]></title>
            <link>https://medium.com/@snowmanjy/lessons-learned-how-to-use-ais-to-cross-check-to-make-sure-code-quality-d4842ea784b2?source=rss-210d8a6888cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4842ea784b2</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Yang Jing]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 19:36:06 GMT</pubDate>
            <atom:updated>2026-01-06T19:36:06.408Z</atom:updated>
            <content:encoded><![CDATA[<p>Last night, after Gemini 3 and Claude Code gave me green lights, I was very confident about the new project’s implementation by Google Antigravity.</p><p>But I thought there was no harm in trying the CodeX with the latest ChatGPT 5.2 model, so I just casually asked CodeX to fully review the code.</p><p>Then CodeX gave me a result report of 3 high-risk and 3 medium-risk issues in the code implementation.</p><p>TBH, my first reaction was to doubt it, mainly because I did the planning with Gemini, and Gemini divided the tasks and generated prompts to guide Antigravity to generate the implementation step by step. Also, I have asked Claude Code CLI to review the code that Antigravity generated all the way down, so how come two AIs all missed these issues…</p><p>The next step, I pasted the report to Claude Code to verify if it’s legit. Then I got the answer yes for all.</p><p>So, fast forward, after CodeX fixed the issues and Claude Code verified the fixes, I asked Gemini and Claude Code how these happened and why they couldn’t catch the issues early, then they gave me the answers.</p><p>From Claude Code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*zgqGGmOEuv5DW_fHzMBfhA.png" /></figure><p>And from Gemini:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*yXc-Ooyq85-098mR6GJMXw.png" /></figure><p>My purpose is not to hear sorry since that’s meaningless(from AI😀), but to learn where the gaps are and how to avoid them from happening again.</p><p>So lessons learned:</p><p><strong>1. No harm to do one more round of double-check</strong></p><p><strong>2. Always be careful, the AI may not think through the end-to-end scenarios, so e-2-e testing and manual testing are necessary.</strong></p><p><strong>3. 0 trust is necessary; AI could be overoptimistic.</strong></p><p>Hope these are helpful for other AI coding builders!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4842ea784b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mapping table vs. Array Column]]></title>
            <link>https://medium.com/@snowmanjy/mapping-table-vs-array-column-97df92757ea4?source=rss-210d8a6888cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/97df92757ea4</guid>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Yang Jing]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 18:44:43 GMT</pubDate>
            <atom:updated>2025-12-21T18:44:43.686Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was coding with AI, I noticed some new DB patterns that I’m not used to dealing with, so I asked Gemini 3 about it, and I feel the answer is good to share if you don’t know it yet.</p><p>My question:” I’m curious about why there is no cross/mapping table between the threads and tags? Will the thread.tags design causing performance issues when the data volume becomes super big?”</p><p>And Gemini 3 answers below:</p><p>You are asking a classic “Senior Engineer” architectural question. It shows you are thinking about the long-term scalability of your system.</p><p>The short answer is: <strong>No, it will not cause performance issues.</strong> In PostgreSQL, using an Array column (text[] or jsonb) with a GIN index is often <strong>faster</strong> and <strong>more space-efficient</strong> than a traditional Cross/Mapping table (Join Table) for this specific use case.</p><p>Here is the deep dive into why we chose the “Modern Postgres” approach over the “Old School SQL” approach.</p><h3>1. The Comparison: Join Table vs. Array Column</h3><h4>Option A: The “Old School” (Join Table)</h4><p>This is the standard way to do Many-to-Many relationships in MySQL or old relational theory.</p><ul><li><strong>Structure:</strong></li></ul><p>Threads table (id, title...)</p><p>Tags table (id, name...)</p><p>Thread_Tags table (thread_id, tag_id)</p><ul><li><strong>Query (Find threads with ‘Java’):</strong></li><li>SQL</li></ul><pre>SELECT t.* FROM threads t <br>JOIN thread_tags tt ON t.id = tt.thread_id <br>JOIN tags tg ON tt.tag_id = tg.id <br>WHERE tg.name = &#39;Java&#39;;</pre><h4>Option B: The “Postgres Way” (Arrays + GIN)</h4><p>This uses PostgreSQL’s advanced data types.</p><ul><li><strong>Structure:</strong></li><li>Threads table (id, title, tags text[])</li><li><strong>Query (Find threads with ‘Java’):</strong></li><li>SQL</li></ul><pre>SELECT * FROM threads WHERE &#39;Java&#39; = ANY(tags);</pre><h3>2. Why Array + GIN wins at High Scale</h3><p>For a system targeting billions of rows, the Array approach often outperforms the Join Table for three reasons:</p><h4>A. Read Performance (The “Locality” Win)</h4><ul><li><strong>Join Table:</strong> To fetch a list of threads and their tags, the database engine must perform a <strong>JOIN</strong>. It has to jump from the threads heap to the thread_tags index, then to the tags index. This random seeking (IOPS) kills performance at scale.</li><li><strong>Array:</strong> The tags are stored <strong>inside the thread row</strong>. When you fetch the thread, you get the tags for “free” (zero extra IOPS). This is massive for feed rendering.</li></ul><h4>B. Indexing Efficiency (The GIN Magic)</h4><p>You might worry that searching an array is slow. It would be, without an index. But we use a <strong>GIN (Generalized Inverted Index)</strong>.</p><ul><li>A GIN index maps Java -&gt; [ThreadID_1, ThreadID_2, ThreadID_3].</li><li>When you query WHERE tags @&gt; &#39;{Java}&#39;, Postgres goes straight to the entry for &quot;Java&quot; and grabs the list of IDs. It is effectively <strong>O(1)</strong> lookup time relative to the number of threads, just like a B-Tree join, but without the join overhead.</li></ul><h4>C. Write Throughput (Insert/Delete)</h4><ul><li><strong>Join Table:</strong> Creating a thread with 5 tags requires <strong>6 Insert Statements</strong> (1 Thread + 5 Link rows) and updates indexes on two tables.</li><li><strong>Array:</strong> Requires <strong>1 Insert Statement</strong>. This significantly reduces write amplification and transaction lock contention.</li></ul><h3>3. The Trade-off: When should you use a Mapping Table?</h3><p>We <em>would</em> switch to a Mapping Table (thread_tags) if your requirements changed to one of these:</p><ol><li><strong>Metadata on the Link:</strong> If you needed to store <em>extra data</em> about the relationship itself.</li></ol><p><em>Example:</em> “Who added this tag?” or “When was this tag added?” (e.g., tagged_by_user_id, tagged_at). You can&#39;t put this inside a simple string array.</p><p><strong>2. Referential Integrity (Strict):</strong> If you rename a tag “Java” to “JavaSE”, the Array approach requires you to run an UPDATE threads SET tags... which can be heavy. A Join Table only requires updating one row in the Tags table.</p><ul><li><em>Counter-point:</em> Tag renames are rare events. We optimize for reads (millions/sec), not renames (once/month).</li></ul><h3>4. Verdict</h3><p>Since tags are simple labels (“Java”, “NBA”, “Help”) and don’t carry complex metadata, <strong>the Array design is superior.</strong></p><ul><li><strong>Storage:</strong> 30–40% less storage (no redundant thread_id and tag_id columns repeating millions of times).</li><li><strong>Speed:</strong> Faster feed retrieval (no Joins).</li><li><strong>Scale:</strong> GIN indexes handle millions of entries effortlessly.</li></ul><p>One final check:</p><p>If you ever feel the array is getting too large (e.g., 1000 tags per thread), that would be a performance issue. But since we limit users to 5 tags per thread, the Array stays tiny and incredibly fast.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97df92757ea4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[小丑王日记]]></title>
            <link>https://medium.com/@snowmanjy/%E5%B0%8F%E4%B8%91%E7%8E%8B%E6%97%A5%E8%AE%B0-450abaf58084?source=rss-210d8a6888cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/450abaf58084</guid>
            <category><![CDATA[nft-collectibles]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[nftart]]></category>
            <category><![CDATA[chinese]]></category>
            <category><![CDATA[nft-marketplace]]></category>
            <dc:creator><![CDATA[Yang Jing]]></dc:creator>
            <pubDate>Sun, 20 Feb 2022 19:25:35 GMT</pubDate>
            <atom:updated>2022-02-20T19:25:35.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*waxnNBCVyO8UEm_8RypR5A.jpeg" /><figcaption><a href="https://opensea.io/assets/0x65cc7530e8c6f5a51257f7b7586361c4a22cec93/4815">BFBS #4815</a></figcaption></figure><p>我 似乎是在梦里<br>一个漫长的梦<br>污浊的空气<br>垃圾 遍地的垃圾<br>嘶喊声 惨叫声<br>枪声 火光<br>轰鸣声 巨大的爆炸 蘑菇云<br>沉寂 死一般的沉寂</p><p>灼烧的感觉 我的右半边身体仿佛在燃烧<br>冰冷的感觉 我的左半边身体却是寒彻如冰<br>截然相反却又融洽相处<br>深入骨髓 刻入灵魂</p><p>我忽然醒来<br>一时魂不守舍<br>我是谁<br>我抬起手臂<br>看到上面的编号 4815<br>大量信息随之涌来<br>我忽然记起<br>我是坏脸机器人#4815<br>我望向对面的镜子<br>镜中的我头戴王冠 双瞳异色<br>我的左瞳湛蓝如冰 右瞳却深红似火<br>忽然想起了伙伴们对我的戏称-异色瞳小丑王<br>我不由微笑了起来</p><p>那个梦<br>为何如此清晰又真实<br>仿似我的回忆<br>我不由又陷入了沉思</p><p>耳机突然不适时的响起<br>“哔～ 队长 能听到吗”<br>“哔～ 队长 敌人数量很多 请求支援”<br>我迅速起身 大步走出房间<br>穿过挂着很多伙伴画像的太空舱<br>我来到外边<br>看到伙伴们已经在跟大量绿皮们战斗在一起</p><p>我立刻启动群体技能-魂交<br>一道道无形的能量迅速将我和队员们连接在一起<br>每个bot的精神力和战斗力都得到了大幅增益</p><p>我也毫不例外<br>左眼的冰焰与右眼的火焰都更加蒸腾<br>我看到了目标<br>绿皮群里体型最大的那只<br>它们好像叫它nobz</p><p>我启动战技-时空扭曲<br>向他瞬移而去<br>nobz的周围有几个兽人近卫<br>感受到威胁立马挥舞着武器和枪械迎了过来<br>不过一切动作在被我双瞳扭曲的时空下都无限变缓<br>我从容的避过子弹和战斧<br>将左侧的几只冻成冰块 右侧的几只也燃烧了起来</p><p>眼角余光中 那只全副武装的nobz把倾泻中的火力向我移来<br>还是太慢了啊 我冷冷的想到<br>双瞳凝聚起精神力向它的眼中看去<br>战技-入魂<br>nobz好似被重重锤了一下<br>动作停滞了下来<br>我轻轻拨开我的倒影<br>进入了它的精神世界<br>混乱 欲望 暴力<br>围绕着一个生命力旺盛的绿色灵魂<br>很有趣啊<br>可惜了一个完全不同的样本<br>不过没时间研究了<br>伙伴们还在苦战当中<br>我施展战技-炼魂<br>兽人绿色的灵魂在红蓝两色的魂火当中哀嚎着消失</p><p>如同小山般的nobz轰然倒下<br>剩余绿皮的士气随之大降<br>在又被干掉几十只后四散而逃<br>我看向伙伴们<br>还好基本没有什么战损<br>骷髅头bot们大都带着邪笑 还是一副意犹未尽的样子<br>看着尸横遍野的战场<br>清理这个才是接下来要头疼的事</p><p>突然 耳机里另一个频道又响了起来<br>“哔～ 队长 能听到吗”<br>“哔～ 队长 探索飞船发现新行星 代号Earth”<br>手臂上的全息投影亮了起来<br>一个蓝色的星球被投在空中<br>大家不由都望向了它<br>一瞬间一种既视感涌上心头<br>我不由有些恍惚<br>似乎 我在哪里看到过它<br>摇了摇头 清理掉思绪<br>我不由有些期待<br>或许 一场新的冒险之旅 又将要展开了吧</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=450abaf58084" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diary of the clown king]]></title>
            <link>https://medium.com/@snowmanjy/diary-of-the-clown-king-1cb77ab92efb?source=rss-210d8a6888cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cb77ab92efb</guid>
            <category><![CDATA[nftart]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[nft-collectibles]]></category>
            <dc:creator><![CDATA[Yang Jing]]></dc:creator>
            <pubDate>Sun, 20 Feb 2022 19:21:51 GMT</pubDate>
            <atom:updated>2022-02-20T19:21:51.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*waxnNBCVyO8UEm_8RypR5A.jpeg" /><figcaption><a href="https://opensea.io/assets/0x65cc7530e8c6f5a51257f7b7586361c4a22cec93/4815">BFBS #4815</a></figcaption></figure><p>Dream<br>Such a long dream<br>Stinky air<br>Trash… trash everywhere<br>Screaming… crying…<br>Gunshots… fires…<br>Explosions… mushroom clouds<br>Then everything was still… absolutely still</p><p>Burning, my right body was burning<br>Cold, my left body was freezing cold<br>It’s such a weird combination<br>But the feeling went deeply into my bones and my soul</p><p>I suddenly woke up<br>Didn’t remember where I was or who I was<br>Until I looked down and saw the number on my arm — 4815<br>Then I remembered, I am the bad face bots #4815.<br>I looked into a mirror, I wear a crown, I have different colored eyes.<br>I remembered what my friends called me — The clown king<br>I smiled</p><p>But the dream<br>It’s so clear and so real<br>I couldn’t hold myself from thinking<br>Could that be some memories from my past?</p><p>Suddenly someone called into my headphones<br>‘Beep~ Cap, can you hear me?’<br>‘Beep~ Cap, so many Orks, we need your help!’</p><p>I stood up, rushed through the space pod<br>When I was outside, my bots were already fighting with the Orks</p><p>Immediately I started the group buff skill — Soul Flow!<br>Many invisible vibrations connected each of us<br>Then our spirits and battle abilities got great increased.</p><p>Both of my eyes were flaming<br>I saw the boss<br>The big guy in the Orks — the Nobz</p><p>I used my Battle skill — spacetime bending!<br>Teleporting to the Nobz<br>Several Ork guards surrounded him<br>They felt the threat and aimed their weapons at me.<br>But under my skill, everything became so slow <br>I just sidestepped them<br>Froze the ones on my left<br>And burned the ones on my right</p><p>Out of the corner Of my eye<br>I saw the big guy was trying hard to attack me<br>But it’s too late<br>I looked deeply into its eyes<br>Battle skill — Soul torture!<br>I saw my own reflections in there<br>then I broke in<br>I saw its soul, a green one surrounded by chaos and violence<br>An interesting and unique one<br>But I didn’t have time to play with it<br>My fellow bots were still fighting outside<br>Battle skill — Soul burning!<br>The green soul vanished with screaming by the blue and red flamings from my eyes</p><p>The Nobz down<br>So did his troops<br>We cleaned up most of the rest<br>Then I checked the bots<br>Luckily no one got badly hurt<br>Those skull guys were even laughing<br>I guess it was just a warm-up for them<br>I looked around the battlefield, such a mess<br>It’s a headache to clean it up</p><p>Suddenly my headphones beeped again<br>‘Beep~ Cap, can you hear me?’<br>‘Beep~ Cap, the explorer ship found a new planet, its name is Earth!’<br>The holographic projector on my arm projected a blue planet into the air.<br>Every bot looked at it, it’s so beautiful!</p><p>In an instant, I felt a strong Deja vu</p><p>I felt I saw it somewhere<br>But whatever, I was looking forward to another wonderful adventure already.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cb77ab92efb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An interesting system design of a rule engine prototype]]></title>
            <link>https://medium.com/@snowmanjy/an-interesting-system-design-of-a-rule-engine-prototype-29255e87b377?source=rss-210d8a6888cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/29255e87b377</guid>
            <category><![CDATA[drools]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Yang Jing]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 22:26:24 GMT</pubDate>
            <atom:updated>2018-11-28T07:56:33.916Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lu0cTKIISKcf8UVM" /><figcaption>“Matrix movie still” by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently my team is doing some design of a pricing engine system, one interesting problem is the system may contain a lot of price rules, any rule applied to a quote may cause some change, which should also go through all price rules to see if there are further rules/actions got triggered. It’s like a chain of rules but we don’t know how many times the price rules need to be checked(a for loop without knowing the N).</p><p>User case: <br>A user is buying clothes for kids on the Gymboree website, which has a event(rule) of free shipping for $75+ orders, so he chose several clothes with a $80 total price(free shipping!) and proceeded to checkout, during checkout he applied a gymbucks(promotion/rule) with $25 value, which made the total price of the order dropped to $55, the order will need to go through the price rules again to add the shipping fee, to recalculate the tax, etc., and the total price change result again need to go through the price rules one more time to make sure no more rules are fired. Also the user may then noticed the shipping fee and add a $20+ hoodie to remove it which will trigger another several rounds of rule check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*ibbRTTXeV7VgGPaTmKFV9Q.gif" /></figure><p>I couldn’t stop thinking about this interesting problem, after reading some great articles about the <strong>rule engine</strong> I realized it’s built up with two parts:<strong> if some condition then some action</strong>. Then I thought the unknown loop sounds similar to Breadth-First Search(<strong>BFS</strong>) problem, we need to check all the leaves of some tree but we don’t know the depth of it. So I thought using some <strong>message queue</strong>(for example Kafka) may be a solution to resolve this issue as it’s the solution of BFS, also with the whole history of the Kafka(event sourcing) we can figure out what happened to the quote and how often a rule got applied, etc. So I started to draw some diagram on paper, which ended up with the first draft version, a little bit messy but enough to show my idea and some key points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZWAOLO6UsIx85kNpV_KLA.jpeg" /></figure><p>The day after I wanted to turn it to some e-version using some tools to draw a diagram. Finally, I picked Google drawings and finalized the diagram as showed below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4FX-Lcf0n_L9nm1cKEbug.png" /></figure><p>So here are the key points of this system:</p><ol><li>I used arrows to mark the <strong>loop</strong>. The loop can be described as action -&gt; model change -&gt; rule engine check(if condition meet, then) -&gt;action -&gt; …</li><li>UI can publish user action, Rule engine can publish rule action, they are going into the same action queue, handled by the same set of action handler with a <strong>uniform</strong> <strong>way</strong>.</li><li>To implement the system quickly, I used Kafka for these two queues, but they are different, the action Queue is a <strong>command pattern</strong>, with a customized command manager we can maintain different queues inside such as: Todo queue, Done history queue, so we can figure out what happened(history) and implement undo/redo functions.</li><li>The quote data model is in memory instead of DB, all the calculations and action changes are in memory until everything done, the result will be persisted into a real DB.</li><li>The action handler part is a pure function without any side effect: Q’ = f(actionModel, Q), which means it can be applied to the same input and always get the same result.</li><li>After any change, I’ll publish the changed quote data model into the done queue, which then becomes a snapshot queue, with it and the point 5 we can make further event sourcing functions.</li></ol><p>So after several days of fun coding, the design turned into a small runnable system:</p><p><a href="https://github.com/snowmanjy/priceEngine">snowmanjy/priceEngine</a></p><p>And then after the implementation was done, when I was review the design diagram again, I realized that the rule engine is perfectly decoupled from the rest of the system by the Kafka/MQ, which made me going one step further to divide the system into two micro-services:</p><p><a href="https://github.com/snowmanjy/ruleEngine">snowmanjy/ruleEngine</a></p><p>and</p><p><a href="https://github.com/snowmanjy/quoteService">snowmanjy/quoteService</a></p><p>The beauty of it is the rule engine now is like a sleepy dragon, it will keep sleeping until some heroes(events) wake it up, do it’s job(kill them 🔥) and then go back to sleep, also it can be reused by lots of other services, which make it a centralized rule service. And the quote service only need to care about the operations of quotes, it has no knowledge about if there is a rule engine somewhere.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29255e87b377" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>