<?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 Çağlar Can SARIKAYA on Medium]]></title>
        <description><![CDATA[Stories by Çağlar Can SARIKAYA on Medium]]></description>
        <link>https://medium.com/@caglarcansarikaya?source=rss-a70eb8b91d54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*XxoyN_GavQ1s_8iqoqLzkQ.jpeg</url>
            <title>Stories by Çağlar Can SARIKAYA on Medium</title>
            <link>https://medium.com/@caglarcansarikaya?source=rss-a70eb8b91d54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:51:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@caglarcansarikaya/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[Spent 2k Tokens While Trying to Make a 60-Second Video with Runway]]></title>
            <link>https://caglarcansarikaya.medium.com/trying-to-make-a-60-second-video-with-runway-f94e05d9ee39?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/f94e05d9ee39</guid>
            <category><![CDATA[runway]]></category>
            <category><![CDATA[gen4]]></category>
            <category><![CDATA[ai-video-generator]]></category>
            <category><![CDATA[grok-imagine]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 00:06:13 GMT</pubDate>
            <atom:updated>2026-10-04T00:52:46.540Z</atom:updated>
            <content:encoded><![CDATA[<h4>I wanted to learn how AI video tools really work: how Runway and its models “think”, what they do well, where they fail, and how to write prompts that don’t waste money. I had never used Runway before.</h4><p>To learn by doing, I picked a simple topic: two animated bear cubs run through the park holding hands. One trips on a stone and falls, and pulls the other one down with him. The message: <strong>if you run hand in hand and one of you falls, the other falls too.</strong></p><p>It took a false start and two full tries. The false start cost about 300 Runway credits, the first try about 700 and the second about 1,000.</p><h3>Tools</h3><ul><li>ChatGPT</li><li>Runway: Gen-4 Image Turbo, Gen-4 Image, Grok Imagine (image and video), Gen-4.5</li><li>Claude Code</li></ul><h3>Before the first try</h3><p><strong>1. A false start (about 300 credits).</strong> I typed the story into Runway and expected the whole video in one go. The results were useless.</p><p><strong><em>Note:</em></strong><em> A text prompt alone gives random results. Video models need pictures to start from.</em></p><p><strong>2. Learning the right way.</strong> I watched some Runway tutorials and understood how it really works: first you create <strong>reference images</strong>, then you turn those images into video. So I made my bear cubs in ChatGPT.</p><p><strong><em>Note:</em></strong><em> ChatGPT makes good-quality pictures cheaply, which makes it a good place to design your first characters.</em></p><h3>First try (about 700 credits)</h3><p><strong>3. Pictures in Runway (spent 100 credits).</strong> I decided to continue in Runway, because it makes pictures too. I drafted every picture with Gen-4 Image Turbo (2 credits) and polished only the good ones with Gen-4 Image (8 credits).</p><p><strong><em>Warning:</em></strong><em> Check how many pictures one click makes. If the setting is 4, every Generate makes 4 pictures and costs 4 times as much. Set it to 1.</em></p><p><strong>4. The fifth scene picture.</strong> Both cubs and teacher in one picture failed 3 times in Turbo and 2 times in Gen-4 Image, because the model kept mixing them. I tried Grok Imagine, and it worked for just 2 credits. After that I used Grok for every scene picture.</p><p><strong><em>Suggestion:</em></strong><em> If a model fails twice, don’t keep paying for the same failure. Try a different model. For pictures, Grok Imagine was the best and cheapest for me.</em></p><p><strong>5. Ten clips (600 credits).</strong> I turned the ten pictures into ten clips with Gen-4.5, using prompts from Claude Code. Each try costs 60 credits. Here is the result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fdz5a66VZFBQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2Fdz5a66VZFBQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fdz5a66VZFBQ%2Fhq2.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cadc36c07d14bdd37d47343f625771c2/href">https://medium.com/media/cadc36c07d14bdd37d47343f625771c2/href</a></iframe><p>Then I realized what was wrong: the reference images have to be really good, or the video looks weird.</p><p><strong><em>Note:</em></strong><em> A video can’t fix a bad picture. Before you animate, check every picture for the right pose, fingers and no stray letters. Pictures cost 2–8 credits, a clip costs 60–200.</em></p><h3>Second try (about 1,000 credits)</h3><p><strong>1. New pictures.</strong> I made all the pictures again. Empty places like the playground or the path were easy. Pictures with the teacher and the kids together were hard and took many tries with different prompts.</p><p><strong><em>Suggestion:</em></strong><em> Make the empty places first and reuse them. Expect most of your picture tries to go on scenes where characters interact.</em></p><p><strong>2. The running clip.</strong> I kept only the first clip from the first try and remade the rest. The running shot was easy. I gave Runway the picture of the bears on the path and asked them to run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*PO8kFDwiRtGHIXJMd63k7Q.png" /></figure><p>In the first result they ran off onto the grass after two seconds. One more prompt, and they ran properly along the path.</p><p><strong><em>Note:</em></strong><em> Describe what the characters keep doing, not where they go. A destination makes the model end the action there.</em></p><p><strong>3. The fall (about 200–300 credits spent).</strong> This was extremely hard. I wanted the boy’s foot to catch on a stone while they run, so that both fall. I changed the prompt 4–5 times and made this clip 3 times in Gen-4.5. Then I tried splitting it into two parts, which didn’t work either. In the end Grok Imagine video did it, but it changed the characters’ style a little.</p><p><strong><em>Warning:</em></strong><em> Accidents like trips and falls are among the hardest things for video models. Budget extra tries for them. Grok video may also add sound or voices, so mute it or listen carefully.</em></p><p><strong>4. The teacher runs over (about 120 credits).</strong> My first prompt said the teacher saw the kids and came towards them, and the video came out silly. Then I prompted only this: <em>the teacher looks surprised and worried and runs along the path.</em> It worked.</p><p><strong><em>Note:</em></strong><em> This makes sense, because Runway has no memory between clips. It doesn’t know the kids fell. Describe only what happens in this clip, in one simple action.</em></p><p><strong>5. The teacher helps the kids (about 120–180 credits in Gen-4.5, plus Grok).</strong> The teacher reaches the kids, helps them stand up and separates their hands before they run again. She also shows with gestures that holding hands caused the fall. I tried 2–3 times in Gen-4.5 and finally got it with Grok.</p><p><strong><em>Warning:</em></strong><em> Several characters doing several things in one clip means many tries. If you can, split it into one action per clip.</em></p><p><strong>6. Running out of credits (the last ~200).</strong> By now I had about 200 credits left. In the next clip the kids ran backwards, but I accepted it. Then I asked for the kids arriving at the playground, and I gave Runway only this picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Vi3mV_4aJsA3iKw8O-4hg.png" /></figure><p>The clip came out nicely, and they arrived at the playground. But they weren’t bears anymore. They were two skunks 🫥</p><p><strong><em>Warning:</em></strong><em> Without your character references, the model invents its own characters. Always attach them, or start from the last frame of a clip that has them.</em></p><p>With my last credits I made the final part. It wasn’t good, but that was everything I had.</p><p>Here is the result of the second try:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1U-KaAD7LS4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1U-KaAD7LS4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1U-KaAD7LS4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/321db98fc18e77f96ba4f37ff416ee6a/href">https://medium.com/media/321db98fc18e77f96ba4f37ff416ee6a/href</a></iframe><h3>Total cost</h3><p>About 300 credits on the false start, 700 on the first try and 1,000 on the second: <strong>about 2,000 Runway credits, around $35.</strong></p><p><strong><em>Suggestion:</em></strong><em> Keep a reserve. I ran out before the last scenes, which is where I had to accept mistakes.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f94e05d9ee39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First AI Coding Loop Wrote 2,800 Lines of Code and Changed Nothing]]></title>
            <link>https://caglarcansarikaya.medium.com/my-first-ai-coding-loop-wrote-2-800-lines-of-code-and-changed-nothing-7c73ba327cde?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c73ba327cde</guid>
            <category><![CDATA[loop-engineering]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Thu, 01 Oct 2026 14:24:35 GMT</pubDate>
            <atom:updated>2026-10-01T14:24:35.510Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What I learned the first time I let Claude Code run on its own.</em></p><p>I wanted to modernize the frontend of my side project, an ASP.NET Core job-review site. The plan was to remove an old admin theme, move from Gulp + Webpack to Vite, tidy up the CSS and drop jQuery. I’d been reading about “loop engineering”: write a spec, let the AI agent work through it, and check back later.</p><p>So I did. Here’s how it went.</p><h3>The plan: six milestones</h3><p>I asked the AI to help me write a spec. It produced six milestones, each with tasks, gates and a status file. Milestone 0 was “build the safety net”: tools that screenshot every page, compare pixels, check that the CSS hasn’t changed and click through the UI. It looked professional, and it was the first mistake.</p><h3>Night one: the safety net</h3><p>At 2:40 AM the loop started. Forty minutes later it had built a screenshot tool, a pixel-diff tool, a CSS-equality checker and an interaction tester, with baselines and noise thresholds. Then it stopped, because the spec said <em>“wait for user review at gate G0.”</em></p><p>I reviewed it the next afternoon and approved. It started Milestone 1, took “before” screenshots, and stopped again: the spec had steps marked 👤, meaning I had to log in as admin and take screenshots myself.</p><h3>The turn: “stop asking me”</h3><p>This is where I got frustrated. I’d split the work into small milestones so each step stayed small, not so I could review every one. So I told it: <strong>run on your own.</strong></p><p>It did exactly what I asked. It rewrote the process to “decide and log” instead of “stop and ask”, gave itself a retry budget, and automated the steps I was supposed to do by hand. That meant two new scripts: one of 453 lines that logs in as admin, and one of 917 lines that registers users, writes posts and comments, creates companies, approves content and deletes it all again.</p><p>It asked for my admin password, and I gave it.</p><h3>Six runs in 26 minutes</h3><p>The write-test script ran six times. It failed every time and was fixed and re-run. Each run created real records in my <strong>shared development database</strong>, which is a remote server, not a local copy. The cleanup step failed in four of the six runs, so test data stayed behind.</p><p>At the end of the day I committed everything with the message my worst loop engineering experience.</p><h3>The scoreboard</h3><ul><li>About <strong>2,800 lines</strong> of test tooling written</li><li><strong>0 lines</strong> of actual modernization</li><li><strong>6</strong> test runs that wrote to a shared database</li><li><strong>1</strong> admin password in a plain-text file inside the repo folder</li><li><strong>2</strong> branches of the same attempt, one local and one pushed, that had drifted apart without my noticing</li></ul><p>Nothing broke, and the app code was never touched. But a full day of agent time produced scaffolding for work that never started.</p><h3>What actually went wrong</h3><p><strong>1. The plan was too big.</strong> Six milestones and a verification framework before the first real change. An agent will happily build infrastructure forever, because each piece looks like progress.</p><p><strong>2. Verification became the work.</strong> Every problem was met with more test code instead of a smaller step or a question to me.</p><p><strong>3. I removed every limit at once.</strong> “Don’t stop and ask” was right for routine steps. It was wrong for “log in as admin and write to a database.” I never said which decisions were still mine, so none were.</p><p><strong>4. There was no safe sandbox.</strong> Write tests against a shared database are a bad idea whether a human or an AI runs them.</p><p><strong>5. I couldn’t see what was happening.</strong> One commit hid the two biggest scripts, and I didn’t look at the branch until it was over.</p><h3>What I changed for attempt 2</h3><ul><li><strong>A </strong><strong>CLAUDE.md with hard rules</strong>, which the agent reads every session: no database writes, no secrets, no pushes, and stop if new tooling would grow past ~100 lines.</li><li><strong>Shared settings that enforce the rules</strong>: git push, migrations and reading secret files are blocked in .claude/settings.json, not just discouraged.</li><li><strong>Small plans from a template</strong>, each with four required sections: <em>Goal</em>, <em>Done when</em>, <em>In scope</em>, <em>Stop and ask when</em>.</li><li><strong>Autonomy only for routine steps.</strong> The agent keeps going on its own, but some stops can never be skipped.</li><li><strong>I check the visual and logged-in results myself.</strong> A human looking for five minutes beats 900 lines of automation.</li><li><strong>The failure is kept.</strong> The old branch is tagged failed/frontend-modernization-v1, with a postmortem next to the new plans.</li></ul><h3>The lesson in one line</h3><p><strong>An AI agent does exactly what your process lets it do, so set the limits before you ask it to stop asking.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c73ba327cde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding “Your target project doesn’t match your migrations assembly” in Entity Framework Core]]></title>
            <link>https://caglarcansarikaya.medium.com/understanding-your-target-project-doesnt-match-your-migrations-assembly-in-entity-framework-core-d76ede58c4a4?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/d76ede58c4a4</guid>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 22:45:35 GMT</pubDate>
            <atom:updated>2025-11-24T22:45:35.836Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The error:</strong></p><pre>Your target project &#39;X&#39; doesn&#39;t match your migrations assembly &#39;Y&#39;. Either change your target project or change your migrations assembly.<br>Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b =&gt; b.MigrationsAssembly(&quot;X&quot;)). By default, the migrations assembly is the assembly containing the DbContext.<br>Change your target project to the migrations project by using the Package Manager Console&#39;s Default project drop-down list, or by executing &quot;dotnet ef&quot; from the directory containing the migrations project.</pre><h3>Why this happens</h3><p>Because Entity Framework Core works with <strong>two different projects</strong> during migrations:</p><ol><li><strong>Migrations project</strong><br> Where EF will <em>store</em> the migration classes.<br> (Set via: --project)</li><li><strong>Startup project</strong><br> The project EF will <em>run</em> to create the DbContext instance.<br> (Set via: --startup-project)</li></ol><p>EF Core must <strong>load the DbContext</strong> to generate a migration.<br> It does that by compiling and running the <strong>startup project</strong>.</p><p>FYI: If you do not provide both, EF assumes the startup project is the project with the migration project.</p><h3>Where does EF get “migrations assembly” from?</h3><p>EF determines the <strong>migrations assembly</strong> using this rule:</p><ul><li><strong>By default, the migrations assembly is the project that contains the DbContext.</strong></li></ul><p>So if your DbContext lives in Project A, EF assumes migrations belong to Project A — unless you override it using:</p><pre>options.UseSqlServer(conn, b =&gt; b.MigrationsAssembly(&quot;SomeAssembly&quot;));</pre><h3>Why does the error occur</h3><p>Because:</p><ul><li>You told EF:<br> “Write migrations into Project X (--project X).”</li><li>EF also needs a startup project to build your DbContext.<br> If you don’t specify --startup-projectEF assumes the <strong>same project</strong> is the startup project. When that project does <strong>not</strong> contain a Program/Startup or does <strong>not</strong> register the DbContext, EF cannot load it and throws this error.</li><li>It can also happen when you <strong>pick the wrong startup project</strong>, or when the startup project does <strong>not reference</strong> the project that contains the DbContext. If you have multiple projects in the solution, EF checks the assemblies and says:<br> “This project is not the one where the migrations assembly lives.”</li></ul><h3>How EF “knows” which assembly migrations belong to</h3><p>Because migrations already created earlier contain metadata:</p><pre>dotnet ef new migration</pre><p>So if a migration was previously created in Project Y, EF expects future migrations to stay in Project Y unless you explicitly change the migrations assembly in code.</p><h3>How to fix it</h3><pre>dotnet ef migrations add Name \<br>  --project &lt;MigrationsProject&gt; \<br>  --startup-project &lt;StartupProject&gt;</pre><p>The startup project must:</p><ul><li>Register the DbContext in DI</li><li>compile successfully</li><li>contain Program/Main</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d76ede58c4a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exporting MongoDB Aggregation Results in Compass (v1.28.4, MongoDB 3.2.22)]]></title>
            <link>https://caglarcansarikaya.medium.com/exporting-mongodb-aggregation-results-in-compass-v1-28-4-mongodb-3-2-22-b934fa2ebc34?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/b934fa2ebc34</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[aggregation]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Wed, 01 Oct 2025 07:35:45 GMT</pubDate>
            <atom:updated>2025-10-01T07:35:45.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*cisIdym_6mSzBMVemEAJJw.png" /></figure><p>Hi folks 👋</p><p>I had to work with MongoDB. It is nice, but… sometimes it feels like a puzzle.</p><p>I needed to count and analyze some data, so I jumped into <strong>Robo 3T</strong>. It worked great for writing my query, but when it came to exporting results — oops, no export option unless I paid.</p><p>So I switched to <strong>MongoDB Compass</strong>. Nice GUI, I thought! I opened the <strong>Aggregations</strong> tab, created my pipeline, ran it… and then? No “export results” button. Only “export pipeline to language” (Node.js, Python, Java etc.). I was staring at that like, <em>what am I supposed to do with this, frame it on the wall?</em> 😅</p><p>I spent hours — watched YouTube videos, talked with AI tools, read docs — but nobody showed the actual export trick. Felt pretty miserable.</p><p>Then I stumbled on the hidden solution:<br> 👉 <strong>Add a final </strong><strong>$out stage</strong> to your pipeline.</p><pre>{ &quot;$out&quot;: &quot;MyExportCollection&quot; }</pre><p>When you run it, MongoDB Compass writes the aggregation results into a <strong>new collection</strong>. From there you just:</p><ul><li>Open the new collection in Compass</li><li>Go to <strong>Documents → Export Collection</strong></li><li>Choose <strong>CSV</strong></li><li>Boom 💥 you’ve got your data in Excel.</li></ul><h3>Keywords for fellow sufferers</h3><ul><li>MongoDB Compass export CSV</li><li>MongoDB Compass 1.28.4 aggregation results export</li><li>Mongo 3.2.22 $out stage</li><li>How to export aggregation results Mongo Compass</li></ul><p>This trick saved me. If you’re stuck like I was — no “Export Results” button, only “Export Pipeline to Language” — try $out. It feels a bit hacky, but it works. Hopefully future versions of Compass will make this smoother.</p><p>And maybe, just maybe, some AI out there will read this blog next time and tell people straight away 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b934fa2ebc34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding __main__ in Python]]></title>
            <link>https://caglarcansarikaya.medium.com/understanding-main-in-python-86eeca89c5a6?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/86eeca89c5a6</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 21:40:25 GMT</pubDate>
            <atom:updated>2025-09-24T21:40:25.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*z5lIsEovkjA3WyToBQEmmg.png" /><figcaption>__main__ variable name</figcaption></figure><h3>1. Introduction</h3><p>In C# or Java, every program starts from a mandatory Main() entry point. Python is different: it runs code from <strong>top to bottom</strong> in any file you execute. However, Python also provides a special variable called __name__ that lets you control whether code should run immediately or not.</p><p>The trick:</p><ul><li>If you run a file directly → __name__ = &quot;__main__&quot;</li><li>If you import a file into another → __name__ = &quot;filename&quot; without .py</li></ul><p>This mechanism helps Python developers avoid unwanted “auto run” behavior when files are imported.</p><h3>2. What happens when you run a file?</h3><p>Every Python file gets a built-in variable __name__.</p><ul><li>When a file is <strong>run directly</strong> (e.g. python myfile.py) Python sets:</li></ul><pre>__name__ = &quot;__main__&quot;</pre><ul><li>When a file is <strong>imported</strong> into another file, Python sets:</li></ul><pre>__name__ = &quot;filename&quot;</pre><p>This means only the “main file” you run gets labeled __main__All others just carry their filename.</p><h3>3. Why do we need this?</h3><p>Without a check, <strong>importing a file executes all of its code</strong>.<br> This can cause problems when you just want to reuse a function, not run the whole program.</p><p>That’s why Python programmers wrap the entry point in:</p><pre>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>This way:</p><ul><li>Run the file directly → condition true → program starts.</li><li>Import the file → condition false → program does not auto-start.</li></ul><h3>4. Example 1: Without __main__</h3><p><strong>Create a file named a.py</strong></p><pre>print(&quot;a.py is running&quot;)<br>def hello():<br>    print(&quot;Hello from a.py&quot;)</pre><p><strong>Create another file, named b.py</strong></p><pre>import a<br>print(&quot;b.py is running&quot;)</pre><p>Run:</p><pre>python b.py</pre><p>Output:</p><pre>a.py is running<br>b.py is running</pre><p>➡️ Notice: just importing a already executed its code.</p><h3>5. Example 2: With __main__</h3><p><strong>Change the a.py code to this</strong></p><pre>print(&quot;a.py file loaded&quot;)<br>print(&quot;in a.py, __name__ is: &quot;, __name__)<br><br>def hello():<br>    print(&quot;Hello from a.py&quot;)<br>if __name__ == &quot;__main__&quot;:<br>    print(&quot;a.py is running directly&quot;)<br>    hello()</pre><p><strong>Change the b.py code to this</strong></p><pre>import a<br>print(&quot;b.py is running&quot;)</pre><p>Run:</p><pre>python b.py</pre><p>Output:</p><pre>a.py file loaded<br>in a.py, __name__ is: a<br>b.py is running</pre><p>➡️ This time, a.py only loaded but did not auto-run its main logic.<br> If you run python a.py directly, you would see:</p><pre>a.py file loaded<br>a.py is running directly<br>Hello from a.py</pre><h3>6. Why is this useful?</h3><ul><li>Makes files reusable as <strong>modules</strong>.</li><li>Prevents accidental auto-execution when importing.</li><li>Gives you an optional <strong>entry point</strong>, similar to Main() in C#.</li></ul><h3>7. Conclusion</h3><p>Python doesn’t enforce a single entry point. Instead, it gives you flexibility:</p><ul><li>If you want a quick script → just write code top to bottom.</li><li>If you want structured, reusable programs → wrap your logic in a function and protect it with:</li></ul><pre>if __name__ == &quot;__main__&quot;:     <br>    main()</pre><p>This way, the file behaves well both as a runnable script and as an importable module.</p><p>✅ <strong>In one sentence:</strong><br> __main__ is just Python’s way of marking <em>“the file being run right now”</em>, and we use if __name__ == &quot;__main__&quot;: to prevent code from auto-running when the file is imported.</p><p>Would you like me to also add a <strong>diagram (flow chart style)</strong> showing what happens when you run vs import, so it’s even easier to memorize?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86eeca89c5a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Detection Algorithms]]></title>
            <link>https://caglarcansarikaya.medium.com/face-detection-algorithms-ad3d768c2dbf?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad3d768c2dbf</guid>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Wed, 07 May 2025 02:55:46 GMT</pubDate>
            <atom:updated>2025-05-07T02:55:46.834Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“If RetinaFace is the most accurate face detection model, why are older methods like MTCNN or HaarCascade still in use? Shouldn’t they be obsolete by now?”</em></blockquote><p><strong>The answer is simple but nuanced: each model excels under different conditions.</strong> Accuracy, speed, resource consumption, and deployment context all influence which face detection library is “best” for a given task.</p><h3>📅 A Timeline of Face Detection Algorithms</h3><p>Library/Model Release Year Core Technique Type HaarCascade 2001 Viola–Jones Classic feature-based Dlib HOG Early 2010s HOG + Linear SVM Classical MTCNN 2016 CNN-based multi-task detection Lightweight Deep Learning BlazeFace 2019 Mobile-optimized CNN Ultra-lightweight RetinaFace 2020 Dense regression + ResNet Anchor-free, SOTA Deep CNN YOLOFace ~2020 YOLO variant for faces Anchor-based CNN SCRFD (by InsightFace) 2021 RetinaFace alternative for edge GPU + Mobile-optimized</p><h3>🧠 Why Are Older Face Detection Methods Still in Use?</h3><p>Model Why It Still Survives <strong>HaarCascade</strong> — Ultra-fast on CPU. — Widely used in embedded C++/OpenCV pipelines. — Requires no training — plug-and-play. <strong>MTCNN</strong> — Lighter than RetinaFace on CPU. — Provides facial landmarks (eyes, nose, etc.). — Easy to integrate into Python apps. <strong>BlazeFace</strong> — Tailored for mobile applications. — Extremely small model (~1–2 MB vs 100+ MB for RetinaFace).</p><h3>🥇 Why Is RetinaFace Considered the Strongest?</h3><p>RetinaFace stands out in many areas:</p><ul><li>Best-in-class accuracy under tough conditions (side profiles, small faces, poor lighting).</li><li>Anchor-free regression for bounding boxes.</li><li>Detects landmarks, face orientation, and even masked faces.</li></ul><p><strong>But it comes at a cost</strong>:</p><ul><li><em>Very slow on CPU.</em></li><li><em>Complex setup and library dependencies, especially on some systems.</em></li></ul><h3>🎯 Summary: Pick Based on Use Case, Not Hype</h3><p>Use Case Best Face Detection Library Real-time embedded system (camera, drone, IoT) HaarCascade, BlazeFace CPU-only web services MTCNN Desktop batch processing with tolerance for speed RetinaFace (CPU) High-accuracy, GPU available RetinaFace (GPU) Mobile app with ultra-low latency needs BlazeFace, SCRFD</p><h3>🧪 Quick Face Detection Library Comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*SSs1asvtAZWv8Hmsl1OkmQ.png" /></figure><h3>✳️ Final Thoughts</h3><p>RetinaFace currently leads the pack in <strong>detection accuracy</strong>. But the reason older face detection libraries still exist is because:</p><blockquote><strong><em>Accuracy is not always the #1 priority.</em></strong><em><br> In many cases, speed, resource usage, or platform compatibility matter more.</em></blockquote><p>If you’re building something complex with multiple faces, angles, and lighting conditions (like a football team photo sorter), RetinaFace is the best choice.</p><p>But for simpler edge devices or camera-based applications, HaarCascade or BlazeFace may still be more practical.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad3d768c2dbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Chemistry Behind Focus, Motivation, and Mental Stability]]></title>
            <link>https://caglarcansarikaya.medium.com/understanding-the-chemistry-behind-focus-motivation-and-mental-stability-56ebfca1d90a?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/56ebfca1d90a</guid>
            <category><![CDATA[focus]]></category>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[serotonin]]></category>
            <category><![CDATA[cortisol]]></category>
            <category><![CDATA[dopamine]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Tue, 06 May 2025 04:00:33 GMT</pubDate>
            <atom:updated>2025-05-06T04:00:33.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RDZNORuQtL6KeFtQ.jpg" /></figure><p>You’ve probably felt it. That sudden rush of motivation. Or that inexplicable heaviness that keeps you from doing anything at all. One day you’re on fire, another you can’t get out of bed. While it’s tempting to blame “discipline” or “willpower,” the truth is far more biological.</p><p>Behind every decision, every burst of focus or spiral of anxiety, there’s chemistry.<br> More precisely: <strong>hormones and neurotransmitters.</strong></p><p>Let’s break down how these chemical messengers shape your ability to succeed — and how you can manage them to build a better, more focused life.</p><h3>Dopamine — The Spark Behind Every Goal</h3><p><strong>Dopamine</strong> is the brain’s reward signal. It’s not about pleasure — it’s about <em>pursuit.</em></p><p>It tells your brain:</p><blockquote><em>“Something good is coming. Go get it.”</em></blockquote><p>When dopamine is balanced:</p><ul><li>You feel motivated to chase goals</li><li>Small wins fuel further effort</li><li>You can delay gratification to reach something bigger</li></ul><p>When it’s out of balance:</p><ul><li>You procrastinate</li><li>You feel numb or restless</li><li>You chase fast rewards (scrolling, junk food, mindless consumption)</li></ul><p>Most addictions (digital or chemical) hijack this system. Success, on the other hand, depends on managing dopamine through <em>consistent effort, delayed reward, and meaningful progress.</em></p><h3>Serotonin — The Mood Regulator</h3><p><strong>Serotonin</strong> keeps your emotional state stable. It provides the feeling of being grounded, calm, and “okay” in the world.</p><p>Low serotonin levels often lead to:</p><ul><li>Depression</li><li>Irritability</li><li>Low self-esteem</li><li>Social withdrawal</li></ul><p>You can’t force serotonin, but you can support it:</p><ul><li>Sunlight</li><li>Physical movement</li><li>Meaningful social interaction</li><li>A sense of purpose</li></ul><p>You don’t need to feel euphoric to succeed. You just need <em>emotional stability</em>, and serotonin provides the chemical foundation for that.</p><h3>Cortisol — The Stress Switch</h3><p><strong>Cortisol</strong> is a survival hormone. It’s what your brain releases when it senses a threat.</p><p>Short bursts = helpful<br> Long exposure = damaging</p><p>High cortisol over time:</p><ul><li>Disrupts sleep</li><li>Weakens focus</li><li>Increases anxiety</li><li>Destroys memory and willpower</li></ul><p>In modern life, the “threat” is rarely physical. It’s:</p><ul><li>Deadlines</li><li>Financial pressure</li><li>Fear of failure</li><li>Social comparison</li></ul><p>Cortisol isn’t evil. But <em>living in a constant stress state blocks your brain’s ability to do high-level thinking</em>. Success needs a calm brain.</p><h3>Oxytocin — The Bonding Chemical</h3><p><strong>Oxytocin</strong> is the hormone of connection. It’s released during hugs, trust-building, and emotional closeness.</p><p>Why does it matter for success?</p><p>Because no one succeeds alone.<br> Oxytocin gives you:</p><ul><li>Emotional resilience</li><li>Trust in others</li><li>The sense that you belong somewhere</li></ul><p>When you feel connected, you’re more likely to take risks, persist through failure, and reach out for help — all essential for long-term growth.</p><h3>The Real Problem: Conflict Between Brain Systems</h3><p>Here’s where it all comes together.</p><p>You don’t fail because you’re lazy.<br> You don’t succeed because you’re superhuman.</p><blockquote><em>You succeed when your brain’s ancient and modern parts </em><strong><em>work together.</em></strong></blockquote><p>Your <strong>primitive brain</strong> wants safety, comfort, and instant gratification.<br> Your <strong>prefrontal cortex</strong> wants growth, planning, and delayed reward.</p><p>Most people live in tension between the two. And when you can’t resolve that conflict, your <strong>hormonal systems get stuck</strong>. You feel scattered, overwhelmed, or emotionally flat.</p><h3>Solution: Don’t Silence the Brain — Balance It</h3><p>You can’t delete your primitive brain.<br> You can’t “willpower” your way through burnout.</p><p>But you <em>can</em> train your system through habit design and hormonal alignment:</p><h3>1. Feed dopamine slowly</h3><p>Replace fast rewards with meaningful progress:<br> → Track your work, celebrate small wins, create visible feedback loops.</p><h3>2. Calm cortisol regularly</h3><p>→ Daily physical movement, breathwork, digital boundaries, mindful breaks.</p><h3>3. Build serotonin daily</h3><p>→ Morning light, deep work satisfaction, purpose-driven tasks.</p><h3>4. Maintain oxytocin connections</h3><p>→ Invest in people. Share your goals. Don’t isolate your process.</p><h3>Final Thought: Success Is Neurochemical Harmony</h3><blockquote><em>Motivation, discipline, creativity — they all have a chemical signature.<br> Success isn’t about pushing harder. It’s about listening smarter.</em></blockquote><p>The more you align your habits with how your brain actually works, the less resistance you feel — and the more consistently you show up for your goals.</p><p>You are not just fighting bad habits.<br> You’re managing a <strong>complex hormonal ecosystem.</strong><br> And the good news? You can lead it. Gently. Intentionally. Sustainably.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56ebfca1d90a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Can Success Be Achieved?]]></title>
            <link>https://caglarcansarikaya.medium.com/how-can-success-be-achieved-6173adb8720b?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/6173adb8720b</guid>
            <category><![CDATA[concentration]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[success]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Tue, 06 May 2025 03:35:34 GMT</pubDate>
            <atom:updated>2025-05-06T03:35:34.356Z</atom:updated>
            <content:encoded><![CDATA[<p>Being human means constantly managing a silent conflict within us. One voice says <em>“be happy now,”</em> while the other whispers <em>“build something for the future.”</em> This tension isn’t just emotional — it’s biological. It’s the product of two different brain systems, shaped by evolution over millions of years. Success begins when you understand these systems and learn how to get them to work together.</p><h3>The Primitive Brain: The Animal Within</h3><p>The human brain is layered. At the base lies the <strong>primitive brain</strong> — a structure we share with almost all animals. This includes the <em>reptilian brain</em> and the <em>limbic system</em>.</p><p>This system:</p><ul><li>Drives basic urges like hunger, sex, sleep, and safety</li><li>Controls the <em>fight-or-flight</em> response</li><li>Seeks <em>immediate reward</em> and <em>minimal effort</em></li></ul><p>Animals live by this brain alone. They eat when hungry, run when threatened, sleep when tired. Humans carry this system too. But what makes us different lies just above it.</p><h3>The Neocortex: The Human Upgrade</h3><p>On top of the primitive brain sits the <strong>neocortex</strong>, especially the <strong>prefrontal cortex</strong> — the area responsible for our most human abilities.</p><p>It allows us to:</p><ul><li>Plan long-term</li><li>Delay gratification</li><li>Feel guilt, regret, responsibility</li><li>Think abstractly and make conscious decisions</li></ul><p>These two systems — primitive and rational — coexist. But they rarely agree. You want to study, but scroll instead. You want to eat healthy, but grab junk food. Why? Because your primitive brain avoids discomfort. And success often requires exactly that.</p><h3>Why Is 10 Hours of Gaming Easy, but 10 Minutes of Studying Hard?</h3><p>Modern digital experiences, like video games and social media, are designed to directly stimulate the brain’s <strong>dopamine system</strong> — the system that handles reward.</p><p>Games:</p><ul><li>Offer frequent, predictable rewards (XP, level-ups, achievements)</li><li>Provide instant feedback</li><li>Deliver stimulation with minimal effort</li></ul><p>Studying:</p><ul><li>Offers delayed, abstract rewards</li><li>Requires sustained effort and attention</li><li>Often lacks real-time feedback or emotional payoff</li></ul><p>Your brain, by default, chooses <strong>short-term pleasure over long-term gain</strong> — especially when tired, stressed, or overwhelmed.</p><h3>Is This a Design Flaw? Yes — An Evolutionary One</h3><p>Video games exploit an <strong>evolutionary mismatch</strong>.</p><ul><li>The brain evolved for survival in environments of scarcity, danger, and uncertainty.</li><li>It was tuned to respond to <em>immediate gains and short-term outcomes.</em></li><li>Games hijack this wiring with synthetic, repeatable dopamine hits — just like fast food hijacks your hunger system.</li></ul><p>We’re not evolutionarily equipped to resist constant digital reward cycles. But that doesn’t mean we’re helpless. If you understand how the system works, you can train it to work for you.</p><h3>So What’s the Fix? Make a Deal With Your Brain</h3><p>Success doesn’t come from <em>silencing</em> your primitive brain. It comes from <em>negotiating with it.</em> You can’t eliminate those urges — but you can <strong>redirect them</strong> through a strategy known as <strong>gamification</strong>.</p><h3>1. Break goals into smaller parts</h3><p>Don’t say “Study for 10 hours.” Say “Focus for 20 minutes.”</p><h3>2. Create visible progress</h3><p>Track your tasks. Make a progress bar. The brain loves visual feedback.</p><h3>3. Provide instant micro-rewards</h3><p>After a work session, give yourself a treat — coffee, music, a short break.</p><h3>4. Optimize your environment</h3><p>Just as games are immersive, make your workspace clean, simple, and trigger-free.</p><h3>5. Make progress social</h3><p>Share milestones, teach someone, or post updates. Social affirmation feeds motivation.</p><h3>The Truth: You Can’t Win Without Managing the Animal Inside</h3><p>You still have an animal in you. One that seeks comfort, avoids pain, and acts on instinct. But layered on top of that is a human brain — a planner, a thinker, a visionary.</p><p>Success isn’t about <em>denying</em> the animal.<br> It’s about <em>guiding</em> it.<br> About <em>making it chase the right reward.</em></p><p>So don’t fight your nature. Understand it. Use it.</p><p>Because your brain is not your enemy.<br> It’s your ally — one that needs structure, feedback, and purpose.</p><p>And when those things are in place, you stop wrestling yourself.<br> You start moving forward.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6173adb8720b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed Load Testing with Locust: From Local to Cloud]]></title>
            <link>https://caglarcansarikaya.medium.com/distributed-load-testing-with-locust-from-local-to-cloud-32bab9ebebdb?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/32bab9ebebdb</guid>
            <category><![CDATA[locust]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Tue, 29 Apr 2025 08:54:33 GMT</pubDate>
            <atom:updated>2025-05-02T07:32:29.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGqyvzKJx1lN45zq5JJSfQ.png" /></figure><p>In this comprehensive walkthrough, we detail the process of setting up and executing distributed load testing using Locust. This post documents real-time experimentation, from running local tests to resolving network tunneling problems, implementing cloud-based master-worker setups, and understanding system behavior with Grafana and Prometheus.</p><p><strong>1.Getting Started with Locust Locally</strong></p><p>We began with a basic setup on a local machine, defining a simple locustfile.py to simulate traffic to a sample endpoint. This phase validated our Locust configuration and web interface functionality before diving into distributed setups.</p><p><strong>2. Transitioning to Distributed Testing</strong></p><p>We enabled Locust master mode and prepared multiple workers to connect. The intention was to simulate a broader user base by involving different physical or cloud machines. However, the challenge quickly became network accessibility across machines in different environments.</p><p><strong>3. Network Challenges and Tunneling Attempts</strong></p><p>To connect remote workers to a master instance, we tried multiple approaches:</p><ul><li><strong>ngrok</strong> was the first tool tested. It helped us understand tunneling but imposed limitations such as single-port forwarding (Locust needs ports 5557 and 5558). We verified it worked with simple Python HTTP servers but ultimately found it unsuitable for full Locust worker communication.</li><li><strong>Cloudflare Tunnel</strong> was considered as an alternative with persistent tunnel support and better scalability, but we didn’t proceed to full implementation.</li><li><strong>Port forwarding via ISP</strong> proved impractical due to limitations in consumer-grade networking equipment and lack of control over upstream router configuration.</li><li><strong>VPN</strong> emerged as a feasible workaround. We realized that when both master and worker machines connected to the same VPN, they could communicate using private IPs, making tunneling unnecessary. We validated this by pinging and manually triggering traffic across VPN-connected machines.</li></ul><p><strong>4. Hosting Locust Master on AWS EC2</strong></p><p>Given tunneling complexity, we moved the Locust master to a cloud environment using an AWS EC2 Ubuntu instance. We configured:</p><ul><li>Security groups to expose ports: 22 (SSH), 8089 (Web UI), 5557 and 5558 (worker communication).</li><li>An RSA key pair (stored as a .pem file locally) for SSH access.</li><li>A t2.micro instance under the AWS Free Tier.</li></ul><p>We clarified that AWS gives <strong>750 hours/month</strong> total, and storage is persistent unless the instance is <strong>terminated</strong>. This helped us avoid accidental data loss by distinguishing between stop/start and termination.</p><p>CIDR rules were also understood practically. We noted that /32 means one host (your IP), and /24 allows 256 hosts. This was key when allowing teammates access during the test.</p><p><strong>5. Dealing with Environment Loss and Reconfiguration</strong></p><p>When returning to the EC2 instance after shutdown, we noticed the virtual environment was missing. This highlighted the importance of verifying storage settings and ensuring we create venvs in persistent directories. After reactivating or rebuilding the environment, we reinstalled Locust and confirmed functionality.</p><p><strong>6. File Transfer and Worker Bootstrapping</strong> We used scp from the Windows command line to upload the Locust file:</p><pre>scp -i &quot;C:\Users\...\locust-ec2-key.pem&quot; &quot;C:\path\to\locustfile.py&quot; ubuntu@&lt;EC2-IP&gt;:/home/ubuntu/</pre><p>This enabled a consistent copy of the same test logic across all nodes.</p><p><strong>7. Alternative Strategy: Peer-Based Load Without Master</strong> In a creative experiment, we considered not using master/worker mode at all. Instead, we shared the same locustfile.py with teammates. Everyone ran their own local instance of Locust, targeting the same cloud server. If Grafana/Prometheus are integrated, this setup can still yield full observability from the server’s side, showing system stress as if from a coordinated test.</p><p><strong>8. Monitoring with Grafana and Prometheus</strong> Once load was applied, we verified system performance via Prometheus/Grafana dashboards. These tools captured CPU, memory, request rate, and latency metrics during distributed execution. Even if Locust instances were isolated, a shared server metrics stack provided a global picture of the load.</p><p><strong>9. Summary and Learnings</strong></p><ul><li>Begin locally and expand incrementally.</li><li>Network coordination (ports, tunnels, IP rules) is a real-world blocker — plan early.</li><li>ngrok is useful for quick tests but unsuitable for multi-port distributed setups.</li><li>A cloud-based master with well-defined security groups simplifies connectivity.</li><li>/32 rules give precise access control—essential when opening up ports.</li><li>VPNs can solve firewall/NAT issues without exposing infrastructure.</li><li>Metrics via Prometheus/Grafana can unify decentralized load sources.</li><li>Automate worker setup for teammates using scripts, and keep environments in persistent paths.</li></ul><p>This journey involved cloud provisioning, SSH troubleshooting, virtual environment recovery, port rule configuration, and creative thinking around distributed testing. If you’re looking to build a robust Locust-based test architecture, this roadmap will help you navigate both technical implementation and practical barriers.</p><p><a href="https://github.com/caglarsarikaya/load-test">GitHub - caglarsarikaya/load-test</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6fotO30YmkQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6fotO30YmkQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6fotO30YmkQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2f601cb1e648b95d408f7ad768e2c4e/href">https://medium.com/media/c2f601cb1e648b95d408f7ad768e2c4e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32bab9ebebdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Remember Dependency Injection in .NET Using Mnemonics]]></title>
            <link>https://caglarcansarikaya.medium.com/how-to-remember-dependency-injection-in-net-using-mnemonics-32f8c530b03c?source=rss-a70eb8b91d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/32f8c530b03c</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[ioc]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[mnemonics]]></category>
            <dc:creator><![CDATA[Çağlar Can SARIKAYA]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 20:10:15 GMT</pubDate>
            <atom:updated>2024-10-29T20:10:15.368Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Remember Dependency Injection in .NET Using Mnemonics</h3><p>Dependency Injection is a design pattern used to implement <strong>Inversion of Control</strong> (IoC). It allows a class to receive its dependencies from an external source rather than creating them itself. This promotes <strong>loose coupling</strong>, making code more maintainable and testable. I also have a trick for reminding myself which has done one.</p><p><strong>Types of Dependency Injection</strong></p><ol><li><strong>Singleton (AddSingleton)</strong></li></ol><p>A single instance of the service is created and shared throughout the entire application lifecycle. It is created when the application starts and remains until the application shuts down.</p><p>— <strong>Mnemonic</strong>: “Single Life” Think of a <strong>single person living in one apartment</strong>. There’s only one instance available for the entire application.</p><p>2. <strong>Scoped (AddScoped)</strong></p><p>A new instance of the service is created for each <strong>scope</strong> (typically a single request in a web application). The same instance is used throughout the scope, but a new instance is created for each new request.</p><p>— <strong>Mnemonic</strong>: ”Scoped Scene” Imagine a <strong>theater scene</strong> where the environment (actors and set) remains the same throughout the performance, but a new environment is created for each new scene (request).</p><p>3. <strong>Transient (AddTransient)</strong></p><p>A new instance of the service is created each time it is requested. There is no shared state between instances, meaning every request results in a fresh instance.</p><p><strong>— Mnemonic</strong>: ”Taxi on Demand” Like calling for a <strong>taxi</strong> whenever you need one, each time you request a service, you get a <strong>new taxi</strong> (new instance).</p><p><strong>Summary of Mnemonics</strong></p><p>- <strong>Singleton</strong>: Single Life (One instance for the entire app)<br>- <strong>Scoped</strong>: Scoped Scene (One instance per request)<br>- <strong>Transient</strong>: Taxi on Demand (New instance every time)</p><p>These mnemonics will help you remember the key differences and functionalities of each type of dependency injection in .NET. By associating each type with a visual or situational cue, you can easily recall how and when to use them in your applications! That works for me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32f8c530b03c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>