<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Architecture on Abhishek Shukla</title><link>https://abhishekshukla.dev/tags/architecture/</link><description>Recent content in Architecture on Abhishek Shukla</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 30 Jun 2026 10:38:19 +0530</lastBuildDate><atom:link href="https://abhishekshukla.dev/tags/architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding SOLID Principles in Swift: Violations, Fixes, and Real-World Examples</title><link>https://abhishekshukla.dev/blog/solid-priciples/</link><pubDate>Mon, 22 Jun 2026 14:52:03 +0530</pubDate><guid>https://abhishekshukla.dev/blog/solid-priciples/</guid><description>&lt;p&gt;The &lt;strong&gt;SOLID&lt;/strong&gt; principles are five fundamental design guidelines in object-oriented programming intended to make software designs more understandable, flexible, and maintainable. These principles help developers avoid code smells, refactor easily, and build robust architectures.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s break down each principle with a real-world scenario, showing how it is commonly violated and how to properly fix it using Swift.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-single-responsibility-principle-srp"&gt;1. Single Responsibility Principle (SRP)&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; A class should have one, and only one, reason to change. Meaning it should only have one job or responsibility.&lt;/p&gt;</description></item><item><title>The Singleton Design Pattern in Swift: Why, How, and When NOT to Use It</title><link>https://abhishekshukla.dev/blog/singleton-design-pattern/</link><pubDate>Tue, 23 Jun 2026 05:47:17 +0530</pubDate><guid>https://abhishekshukla.dev/blog/singleton-design-pattern/</guid><description>&lt;p&gt;The &lt;strong&gt;Singleton&lt;/strong&gt; is one of the most well-known—and heavily debated—creational design patterns in software engineering. Apple uses it extensively throughout the iOS SDK (&lt;code&gt;UserDefaults.standard&lt;/code&gt;, &lt;code&gt;URLSession.shared&lt;/code&gt;, &lt;code&gt;NotificationCenter.default&lt;/code&gt;), which often leads developers to believe it should be used everywhere.&lt;/p&gt;
&lt;p&gt;However, while Singletons are incredibly easy to create in Swift, they are equally easy to abuse.&lt;/p&gt;
&lt;p&gt;In this post, we will explore what the Singleton pattern is, why and how to implement it, where it makes sense, and most importantly, where you should avoid it.&lt;/p&gt;</description></item><item><title>The Factory Method Pattern in Swift: Decoupling Object Creation</title><link>https://abhishekshukla.dev/blog/factory-method-design-pattern/</link><pubDate>Tue, 23 Jun 2026 08:28:30 +0530</pubDate><guid>https://abhishekshukla.dev/blog/factory-method-design-pattern/</guid><description>&lt;p&gt;As your application grows, the way you create and manage objects becomes just as important as how those objects behave. If your code is littered with complex initialization logic or massive &lt;code&gt;switch&lt;/code&gt; statements deciding which object to create, you are likely creating tightly coupled, fragile code.&lt;/p&gt;
&lt;p&gt;Enter the &lt;strong&gt;Factory Method&lt;/strong&gt; pattern.&lt;/p&gt;
&lt;p&gt;This creational design pattern provides an interface for creating objects, but delegates the exact type of object being created to a dedicated &amp;ldquo;factory.&amp;rdquo; In modern Swift, this pattern is often implemented using protocols and static methods, keeping our business logic incredibly clean.&lt;/p&gt;</description></item><item><title>The Builder Pattern in Modern Swift: Beyond the Gang of Four</title><link>https://abhishekshukla.dev/blog/builder-design-pattern/</link><pubDate>Tue, 23 Jun 2026 12:00:00 +0530</pubDate><guid>https://abhishekshukla.dev/blog/builder-design-pattern/</guid><description>&lt;p&gt;The Builder Pattern is a creational design pattern designed to separate the construction of a complex object from its representation.&lt;/p&gt;
&lt;p&gt;In classic Gang of Four (GoF) object-oriented languages like Java, the Builder is essential for avoiding the &amp;ldquo;telescoping constructor&amp;rdquo; anti-pattern (where you have a dozen different initializers for every combination of parameters).&lt;/p&gt;
&lt;p&gt;However, in modern Swift, the classic Builder pattern is often redundant. Swift’s native features—like named parameters, default values, and structs—solve the telescoping constructor problem out of the box. Therefore, when we use the Builder pattern in Swift today, it usually takes on one of three highly optimized, modern forms.&lt;/p&gt;</description></item><item><title>The Adapter Design Pattern in Swift: Bridging Legacy Code to Modern APIs</title><link>https://abhishekshukla.dev/blog/adapter-design-pattern/</link><pubDate>Wed, 24 Jun 2026 11:20:00 +0530</pubDate><guid>https://abhishekshukla.dev/blog/adapter-design-pattern/</guid><description>&lt;p&gt;In the real world, you cannot always control the code you work with. You will frequently need to integrate legacy systems, older Objective-C frameworks, or external SDKs into your modern Swift application.&lt;/p&gt;
&lt;p&gt;The problem arises when these external systems have interfaces that are completely incompatible with your app&amp;rsquo;s existing architecture. If you force your app to accommodate these legacy interfaces directly—like dealing with &lt;code&gt;NSArray&lt;/code&gt;, untyped dictionaries, and completion handlers—your code quickly becomes a tightly coupled, unsafe mess.&lt;/p&gt;</description></item><item><title>The Decorator Design Pattern in Swift: Enhancing Objects Dynamically</title><link>https://abhishekshukla.dev/blog/decorator-design-pattern/</link><pubDate>Thu, 25 Jun 2026 12:51:58 +0530</pubDate><guid>https://abhishekshukla.dev/blog/decorator-design-pattern/</guid><description>&lt;p&gt;As your application grows, you often need to add new responsibilities to existing objects. The default approach for many developers is subclassing. However, subclassing is static and applies to an entire class. If you need to combine multiple different behaviors, subclassing leads to a massive, unmaintainable &amp;ldquo;subclass explosion.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Decorator&lt;/strong&gt; pattern (also known as a Wrapper) solves this. It is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.&lt;/p&gt;</description></item><item><title>The Facade Design Pattern in Swift: Simplifying Complex Systems</title><link>https://abhishekshukla.dev/blog/facade-design-pattern/</link><pubDate>Fri, 26 Jun 2026 14:30:00 +0530</pubDate><guid>https://abhishekshukla.dev/blog/facade-design-pattern/</guid><description>&lt;p&gt;Modern iOS applications rely on multiple subsystems: networking, local databases, image caching, and third-party SDKs. If your UI or business logic interacts with all of these internal classes directly, your code becomes incredibly dense and difficult to read.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Facade&lt;/strong&gt; design pattern is a structural pattern that provides a simplified, high-level interface to a complex body of code. It hides the underlying complexity of multiple subsystems behind a single, easy-to-use class.&lt;/p&gt;</description></item><item><title>The Observer Design Pattern in Swift: Mastering Reactive Communication</title><link>https://abhishekshukla.dev/blog/observer-design-pattern/</link><pubDate>Sat, 27 Jun 2026 10:00:00 +0530</pubDate><guid>https://abhishekshukla.dev/blog/observer-design-pattern/</guid><description>&lt;p&gt;In modern iOS applications, data is constantly changing. A user logs in, a network request finishes, or a background sync completes. When these events happen, multiple parts of your application—like the UI, analytics trackers, and local databases—need to react immediately.&lt;/p&gt;
&lt;p&gt;If the object responsible for the data explicitly tells every other object to update, your app becomes a tightly coupled, unmaintainable mess.&lt;/p&gt;
&lt;p&gt;This is exactly what the &lt;strong&gt;Observer&lt;/strong&gt; design pattern prevents. It defines a one-to-many subscription mechanism so that when one object changes state, all its dependents are notified automatically, without the objects needing to know about each other.&lt;/p&gt;</description></item><item><title>Understanding Opaque Types in Swift and SwiftUI: The Power of `some`</title><link>https://abhishekshukla.dev/blog/swift-opaque-type/</link><pubDate>Tue, 30 Jun 2026 10:38:19 +0530</pubDate><guid>https://abhishekshukla.dev/blog/swift-opaque-type/</guid><description>&lt;p&gt;If you have ever written a single line of SwiftUI, you have seen this code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-swift" data-lang="swift"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; body: some View {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Text(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello, World!&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That tiny word—&lt;code&gt;some&lt;/code&gt;—represents one of the most powerful and complex features introduced in modern Swift: &lt;strong&gt;Opaque Return Types&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;But what exactly does &lt;code&gt;some&lt;/code&gt; do? Why can&amp;rsquo;t we just return &lt;code&gt;View&lt;/code&gt;? And when should you use opaque types in your own non-UI Swift code? Let&amp;rsquo;s break down the &lt;em&gt;what&lt;/em&gt;, &lt;em&gt;why&lt;/em&gt;, &lt;em&gt;where&lt;/em&gt;, and the common violations.&lt;/p&gt;</description></item></channel></rss>