<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IoC | 1byteone - Java Backend / AI Application Developer</title><link>https://1byteone.github.io/en/tags/ioc/</link><atom:link href="https://1byteone.github.io/en/tags/ioc/index.xml" rel="self" type="application/rss+xml"/><description>IoC</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Fri, 21 Aug 2026 00:00:00 +0000</lastBuildDate><image><url>https://1byteone.github.io/media/icon_hu_1c0e9cb08cfb822a.png</url><title>IoC</title><link>https://1byteone.github.io/en/tags/ioc/</link></image><item><title>Spring Boot IoC &amp; Dependency Injection</title><link>https://1byteone.github.io/en/blog/spring-boot-ioc-dependency-injection/</link><pubDate>Fri, 21 Aug 2026 00:00:00 +0000</pubDate><guid>https://1byteone.github.io/en/blog/spring-boot-ioc-dependency-injection/</guid><description>&lt;p&gt;&lt;em&gt;Whiteboard note: the goal is not to memorize boxes, but to connect each arrow to a request, a contract, and an operational signal.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="start-with-a-real-scenario"&gt;Start with a real scenario&lt;/h2&gt;
&lt;p&gt;Use this situation as the mental model: &lt;strong&gt;The same payment use case runs with a sandbox gateway in tests and a real gateway in production.&lt;/strong&gt;. A useful backend diagram answers four questions: where does input enter, who owns state, which boundary can fail, and how do we know the system is healthy? The flow is &lt;strong&gt;Container owns construction; application owns behavior&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="deconstructing-the-architecture"&gt;Deconstructing the architecture&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Contract&lt;/strong&gt;: define input, output, and error shape before adding implementation detail.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mechanism&lt;/strong&gt;: Scan / Register → BeanDefinition; Instantiate → constructor injection. This is the part that determines latency, throughput, and testability.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;State and resources&lt;/strong&gt;: Populate → dependencies are resolved; Initialize → @PostConstruct / proxy. Explain creation, ownership, cleanup, and recovery.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Failure path&lt;/strong&gt;: Ready → request can use the Bean; combine it with &lt;strong&gt;Destroy → cleanup resources&lt;/strong&gt; when choosing a fallback, retry, or rollback.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="a-small-implementation-boundary"&gt;A small implementation boundary&lt;/h2&gt;
&lt;p&gt;The following sketch is intentionally small. It shows where a production implementation should place validation and ownership rather than pretending that a happy path is enough.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;request → bounded resource → validated boundary → observable result
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Keep external systems behind an adapter, repository, client, or gateway. The domain layer should depend on a stable contract so tests can use fakes and incidents can be isolated to one boundary.&lt;/p&gt;
&lt;h2 id="engineering-decisions-for-the-scenario"&gt;Engineering decisions for the scenario&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Protect dependencies first.&lt;/strong&gt; Pools, queues, semaphores, caches, and worker counts need explicit limits. An unbounded queue only hides overload.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preserve correctness.&lt;/strong&gt; Use an idempotency key, transaction boundary, lock, version check, or schema validation where retries or concurrency can duplicate work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimize with evidence.&lt;/strong&gt; Use traces, slow-query data, GC pauses, queue depth, or p99 latency before choosing a cache, index, batch size, or concurrency setting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Make recovery testable.&lt;/strong&gt; Timeout, retry, rate limit, circuit breaking, rollback, and alerting should be exercised in a drill.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="common-mistakes"&gt;Common mistakes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Drawing only the happy path while omitting timeout, empty data, rejection, rollback, or replica lag.&lt;/li&gt;
&lt;li&gt;Treating framework defaults as business contracts and discovering their limits after an upgrade.&lt;/li&gt;
&lt;li&gt;Scaling machines before measuring pool exhaustion, lock contention, slow SQL, allocation, or event-loop blocking.&lt;/li&gt;
&lt;li&gt;Treating logs as the only observability tool; metrics, traces, sampling, and redaction are also required.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="production-checklist"&gt;Production checklist&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Input, output, and error responses have explicit schemas&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Dependencies have timeout, retry budgets, rate limits, and fallback behavior&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Pools and queues expose capacity, waiting, and rejected-work metrics&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Important state has idempotency, transaction, or recovery semantics&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Logs, metrics, and traces share a request or correlation ID&lt;/li&gt;
&lt;li&gt;&lt;input disabled="" type="checkbox"&gt; Regression tests, load tests, and failure drills use production-like data&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="summary"&gt;Summary&lt;/h2&gt;
&lt;p&gt;You understand this whiteboard when you can start from one request, explain every arrow&amp;rsquo;s contract, state how each risk is handled, and name the signal that would tell you to change the design.&lt;/p&gt;</description></item></channel></rss>