<?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 Anderson Niko on Medium]]></title>
        <description><![CDATA[Stories by Anderson Niko on Medium]]></description>
        <link>https://medium.com/@andersonnikko1?source=rss-b06505167c88------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o4Q3w1yOF1LVVw2n-yUsbg.png</url>
            <title>Stories by Anderson Niko on Medium</title>
            <link>https://medium.com/@andersonnikko1?source=rss-b06505167c88------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:42:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andersonnikko1/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[ { Swift Code } — DIP— Dependency Inversion Principle]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-dip-dependency-inversion-principle-8828d5b8fd84?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/8828d5b8fd84</guid>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Fri, 04 Dec 2026 04:37:32 GMT</pubDate>
            <atom:updated>2026-12-04T04:37:32.375Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HwUOZiD_uCgln5eKeXh7A.png" /></figure><p>The Dependency Inversion Principle (DIP) is the fifth of the five SOLID principles of object-oriented design.</p><p>It states:</p><p><strong>High-level modules should not depend on low-level modules. Both should depend on abstractions.</strong></p><p>Abstractions should not depend on details. Details should depend on abstractions.</p><p>The principle encourages us to reduce direct dependencies between components by introducing abstractions, making software more flexible, maintainable, and testable.</p><p>In Swift, DIP is commonly implemented using protocols and dependency injection.</p><p><strong>Core Concepts</strong></p><ul><li><strong>Abstractions:</strong> Define contracts using protocols instead of depending directly on concrete types.</li><li><strong>Dependency Injection:</strong> Provide dependencies from outside rather than creating them internally.</li><li><strong>Loose Coupling:</strong> Reduce direct dependencies between high-level and low-level components.</li><li><strong>Flexibility:</strong> Allow different implementations to be used through the same abstraction.</li></ul><p>💡 <strong>DIP is about depending on what a component needs, not on a specific implementation of that functionality.</strong></p><h3>The Problem — Violating DIP</h3><p>Imagine a notification service that sends messages using a specific email service.</p><pre>struct EmailService {<br>    func send(message: String) {<br>        print(&quot;Sending email: \\(message)&quot;)<br>    }<br>}<br><br>struct NotificationService {<br>    private let emailService = EmailService()<br><br>    func notify(message: String) {<br>        emailService.send(message: message)<br>    }<br>}</pre><p>Here, NotificationService directly creates and depends on EmailService.</p><p>This creates several problems:</p><ul><li>Tight coupling between components.</li><li>Difficulties replacing the email implementation.</li><li>Limited flexibility when adding new notification methods.</li><li>More complicated unit testing.</li><li>Changes to the concrete implementation can affect dependent components.</li></ul><p>The problem is that the high-level NotificationService depends directly on a low-level implementation.</p><h3>The Solution — Applying DIP</h3><p>Instead of depending on a concrete implementation, introduce a protocol that defines the required behavior.</p><pre>protocol MessageSender {<br>    func send(message: String)<br>}</pre><p>Now, different implementations can conform to the same protocol.</p><pre>struct EmailService: MessageSender {<br>    func send(message: String) {<br>        print(&quot;Sending email: \\(message)&quot;)<br>    }<br>}<br><br>struct SMSService: MessageSender {<br>    func send(message: String) {<br>        print(&quot;Sending SMS: \\(message)&quot;)<br>    }<br>}</pre><p>The high-level module now depends on the abstraction rather than a specific service.</p><pre>struct NotificationService {<br>    private let sender: any MessageSender<br><br>    init(sender: any MessageSender) {<br>        self.sender = sender<br>    }<br><br>    func notify(message: String) {<br>        sender.send(message: message)<br>    }<br>}</pre><h3>Dependency Injection in Action</h3><p>We can inject different implementations without changing NotificationService.</p><pre>let emailNotification = NotificationService(<br>    sender: EmailService()<br>)<br><br>emailNotification.notify(message: &quot;Welcome!&quot;)<br><br>let smsNotification = NotificationService(<br>    sender: SMSService()<br>)<br><br>smsNotification.notify(message: &quot;Welcome!&quot;)</pre><p>Both implementations work through the same protocol.</p><p>The NotificationService does not need to know whether the message is sent through email or SMS.</p><h3>Benefits of DIP</h3><ul><li><strong>Loose Coupling:</strong> Components depend on abstractions rather than concrete implementations.</li><li><strong>Flexibility:</strong> Implementations can be replaced without modifying dependent components.</li><li><strong>Testability:</strong> Dependencies can be replaced with mock or test implementations.</li><li><strong>Maintainability:</strong> Changes to implementation details have less impact on high-level modules.</li><li><strong>Extensibility:</strong> New implementations can be introduced without changing existing business logic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJF7MAGsaiROLy3WkcLcyQ.png" /></figure><h3>DIP in Real-World iOS Development</h3><ul><li><strong>Networking:</strong> Depend on an API service protocol instead of a specific networking implementation.</li><li><strong>Data Persistence:</strong> Depend on a repository protocol rather than directly using Core Data or SwiftData.</li><li><strong>Authentication:</strong> Depend on an authentication protocol instead of a specific authentication provider.</li><li><strong>Analytics:</strong> Depend on an analytics tracking protocol rather than a specific analytics SDK.</li><li><strong>Notifications:</strong> Depend on a notification service abstraction rather than a specific notification provider.</li></ul><h3>Common Mistakes</h3><ul><li><strong>Direct Dependencies:</strong> Creating concrete dependencies inside high-level components.</li><li><strong>Confusing DIP with Dependency Injection:</strong> Dependency Injection is a technique that helps implement DIP; they are not the same thing.</li><li><strong>Unnecessary Abstractions:</strong> Creating protocols when there is no meaningful need for interchangeable implementations.</li><li><strong>Ignoring Dependency Direction:</strong> Allowing high-level business logic to depend directly on implementation details.</li></ul><h3>Interview Questions</h3><p><strong>Q: What is the Dependency Inversion Principle?</strong></p><p>A: High-level modules should not depend on low-level modules. Both should depend on abstractions.</p><p><strong>Q: How does Swift support DIP?</strong></p><p>A: Swift protocols provide abstractions, while dependency injection allows concrete implementations to be supplied from outside.</p><p><strong>Q: Is DIP the same as Dependency Injection?</strong></p><p>A: No. DIP is a design principle, while Dependency Injection is a technique for providing dependencies to a component.</p><p><strong>Q: How does DIP improve testability?</strong></p><p>A: Dependencies can be replaced with mock or test implementations, allowing components to be tested independently.</p><p><strong>Q: What is the difference between DIP and ISP?</strong></p><p>A: DIP focuses on dependency direction and abstractions. ISP focuses on ensuring clients do not depend on functionality they do not need.</p><h3>Core Idea</h3><p><strong>Depend on abstractions, not concrete implementations.</strong></p><p>Design components around protocols and inject their dependencies to achieve loosely coupled, flexible, and testable code.</p><p>🐇 SOLID — A practical introduction:</p><p><a href="https://nikolaiborisov.github.io/#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 Programming Principles Quiz:</p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><p>#Swift #SwiftProgramming #SOLID #DependencyInversionPrinciple #DependencyInjection #ProtocolOrientedProgramming #iOSDevelopment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8828d5b8fd84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — ISP — Interface Segregation Principle]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-isp-interface-segregation-principle-52423d62edcb?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/52423d62edcb</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 02:37:38 GMT</pubDate>
            <atom:updated>2026-12-03T02:37:38.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-sW5AUux1R5CaMHkucCyQ.png" /></figure><p>The <strong>Interface Segregation Principle (ISP)</strong> is the fourth of the five SOLID principles of object-oriented design.</p><blockquote><em>Clients should not be forced to depend on interfaces they do not use.</em></blockquote><p>The principle encourages us to design small, focused interfaces instead of large interfaces that combine unrelated responsibilities.</p><p>In Swift, ISP is particularly relevant to protocol-oriented programming, where protocols define the capabilities and contracts of different types.</p><ul><li><strong>Focused interfaces:</strong> Each protocol represents a specific responsibility or capability.</li><li><strong>Minimal dependencies:</strong> Clients depend only on the functionality they actually need.</li><li><strong>Protocol composition:</strong> Multiple focused protocols can be combined when additional functionality is required.</li></ul><p>💡 ISP is not about making every protocol as small as possible. It is about ensuring that clients are not forced to depend on unnecessary functionality.</p><h3>The problem — violating ISP</h3><p>Imagine a document management system that supports printing, scanning, and faxing documents.</p><pre>protocol OfficeDevice {<br>    func printDocument()<br>    func scanDocument()<br>    func faxDocument()<br>}<br><br>struct MultifunctionPrinter: OfficeDevice {<br>    func printDocument() {<br>        print(&quot;Printing document&quot;)<br>    }<br><br>    func scanDocument() {<br>        print(&quot;Scanning document&quot;)<br>    }<br><br>    func faxDocument() {<br>        print(&quot;Faxing document&quot;)<br>    }<br>}<br><br>struct BasicPrinter: OfficeDevice {<br>    func printDocument() {<br>        print(&quot;Printing document&quot;)<br>    }<br><br>    func scanDocument() {<br>        fatalError(&quot;Scanning is not supported&quot;)<br>    }<br><br>    func faxDocument() {<br>        fatalError(&quot;Faxing is not supported&quot;)<br>    }<br>}</pre><p>The MultifunctionPrinter supports all three operations. However, BasicPrinter only supports printing.</p><p>Because both types conform to the same protocol, BasicPrinter is forced to implement methods it does not need or support.</p><pre>let printer = BasicPrinter()<br><br>printer.printDocument()<br>// Printing document<br><br>printer.scanDocument()<br>// Runtime crash</pre><p>This creates several potential problems:</p><ul><li>Unnecessary dependencies.</li><li>Unsupported operations.</li><li>Empty or meaningless implementations.</li><li>Potential runtime failures.</li><li>Increased coupling.</li><li>Reduced maintainability and flexibility.</li></ul><p>The problem is that the OfficeDevice protocol combines multiple independent capabilities into a single interface.</p><h3>The solution — applying ISP</h3><p>Instead of defining one large protocol, we separate the functionality into smaller, focused protocols.</p><p>Each type can then conform only to the protocols representing its actual capabilities.</p><h3>Swift example — try it in a Playground</h3><pre>protocol Printable {<br>    func printDocument()<br>}<br><br>protocol Scannable {<br>    func scanDocument()<br>}<br><br>protocol Faxable {<br>    func faxDocument()<br>}<br><br>struct BasicPrinter: Printable {<br>    func printDocument() {<br>        print(&quot;Printing document&quot;)<br>    }<br>}<br><br>struct MultifunctionPrinter:<br>    Printable, Scannable, Faxable {<br><br>    func printDocument() {<br>        print(&quot;Printing document&quot;)<br>    }<br><br>    func scanDocument() {<br>        print(&quot;Scanning document&quot;)<br>    }<br><br>    func faxDocument() {<br>        print(&quot;Faxing document&quot;)<br>    }<br>}</pre><p>Now, BasicPrinter implements only the functionality it supports.</p><p>The MultifunctionPrinter combines multiple protocols to provide additional capabilities.</p><pre>let printer = BasicPrinter()<br><br>printer.printDocument()<br>// Printing document<br><br>let multifunction = MultifunctionPrinter()<br><br>multifunction.printDocument()<br>// Printing document<br><br>multifunction.scanDocument()<br>// Scanning document<br><br>multifunction.faxDocument()<br>// Faxing document</pre><p>Attempting to call scanDocument() on BasicPrinter now results in a compile-time error rather than a runtime crash.</p><h3>Client-specific dependencies</h3><p>A client responsible for printing documents should depend only on the printing capability.</p><pre>struct PrintService {<br>    func execute(device: any Printable) {<br>        device.printDocument()<br>    }<br>}<br><br>let service = PrintService()<br><br>service.execute(device: BasicPrinter())<br>service.execute(device: MultifunctionPrinter())</pre><p>PrintService does not need to know whether the device supports scanning or faxing.</p><p>It depends only on the functionality it actually uses.</p><h3>Extending functionality</h3><p>Suppose we introduce a dedicated scanner.</p><pre>struct DocumentScanner: Scannable {<br>    func scanDocument() {<br>        print(&quot;Scanning document&quot;)<br>    }<br>}<br><br>struct ScanService {<br>    func execute(device: any Scannable) {<br>        device.scanDocument()<br>    }<br>}<br><br>let service = ScanService()<br><br>service.execute(device: DocumentScanner())<br>service.execute(device: MultifunctionPrinter())</pre><p>The new type does not need to implement printing or faxing operations.</p><p>Existing protocols and implementations remain unchanged.</p><h3>Protocol composition</h3><p>Swift allows us to combine multiple protocols when a client requires several capabilities.</p><pre>typealias PrintAndScan = Printable &amp; Scannable<br><br>struct DocumentService {<br>    func execute(device: any PrintAndScan) {<br>        device.scanDocument()<br>        device.printDocument()<br>    }<br>}<br><br>let service = DocumentService()<br><br>service.execute(device: MultifunctionPrinter())</pre><p>The DocumentService depends on printing and scanning capabilities without introducing an unnecessary dependency on faxing.</p><p>This is one of the advantages of protocol-oriented programming in Swift.</p><h3>Visual representation</h3><p><strong>Violating ISP:</strong> One large interface forces every implementation to support all operations.</p><p><strong>Applying ISP:</strong> Smaller, focused interfaces allow each implementation to depend only on the capabilities it needs.</p><h3>Benefits of ISP</h3><ul><li><strong>Loose coupling:</strong> Clients depend only on the functionality they need.</li><li><strong>Flexibility:</strong> Types can combine different capabilities.</li><li><strong>Maintainability:</strong> Changes to one protocol have less impact on unrelated components.</li><li><strong>Testability:</strong> Smaller protocols simplify mock implementations.</li><li><strong>Reusability:</strong> Focused protocols can be reused across different types.</li><li><strong>Reliability:</strong> Unsupported operations can be eliminated from the interface.</li><li><strong>Readability:</strong> Each protocol communicates a clear purpose.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OcdNpJahjWlQNF07uWBZbA.png" /></figure><h3>How to apply it</h3><ol><li>Identify the functionality each client actually needs.</li><li>Separate unrelated responsibilities into focused protocols.</li><li>Allow types to conform only to relevant protocols.</li><li>Use protocol composition when multiple capabilities are required.</li><li>Avoid empty implementations and unsupported required methods.</li><li>Keep dependencies focused on client requirements.</li><li>Avoid unnecessary protocol fragmentation.</li></ol><h3>Common mistakes</h3><p><strong>Large protocols</strong></p><p>Avoid protocols that combine unrelated responsibilities, forcing conforming types to implement unnecessary methods.</p><p><strong>Empty implementations</strong></p><p>If a type repeatedly implements methods with empty bodies, the protocol may be too broad.</p><p><strong>Unsupported operations</strong></p><p>Using fatalError() for required but unsupported operations may indicate an ISP violation.</p><p><strong>Excessive protocol segregation</strong></p><p>Not every method requires a separate protocol. Related operations can belong to the same cohesive interface.</p><p><strong>Ignoring client requirements</strong></p><p>Protocols should be designed around the needs of their clients, not simply around all the functionality available in an implementation.</p><h3>ISP in real-world iOS development</h3><p><strong>Networking</strong></p><p>Separate request execution, file uploading and file downloading into focused protocols when clients need these capabilities independently.</p><p><strong>Data persistence</strong></p><p>Separate reading, writing and deleting operations. A read-only component should not depend on write or delete functionality.</p><p><strong>Authentication</strong></p><p>Separate signing in, signing out and account management when these operations serve different clients.</p><p><strong>Analytics</strong></p><p>Separate event tracking, user identification and analytics configuration.</p><p><strong>Notifications</strong></p><p>Separate notification authorization, scheduling and cancellation.</p><p><strong>SwiftUI</strong></p><p>A view model that only displays data should depend on a reading protocol rather than a complete repository interface that also supports creating, updating and deleting data.</p><p>Component</p><p>Focused interfaces</p><p>Networking</p><p>Requesting, Uploading, Downloading</p><p>Data persistence</p><p>Readable, Writable, Deletable</p><p>Authentication</p><p>SignIn, SignOut, AccountManaging</p><p>Analytics</p><p>EventTracking, UserIdentifying</p><p>Notifications</p><p>Authorizing, Scheduling, Cancelling</p><p>Media</p><p>Playable, Recordable</p><h3>Interview case</h3><p><strong>Q: A class conforms to a protocol but leaves several required methods empty because it does not need them. Which SOLID principle might be violated?</strong></p><p>A: The Interface Segregation Principle. The protocol may be too broad and force implementations to depend on unnecessary functionality.</p><p><strong>Q: Does ISP mean every protocol should contain only one method?</strong></p><p>A: No. A protocol can contain multiple methods as long as they represent a cohesive responsibility and are relevant to its clients.</p><p><strong>Q: How does Swift support ISP?</strong></p><p>A: Swift supports ISP through protocols, protocol composition and selective protocol conformance.</p><p><strong>Q: What is the difference between SRP and ISP?</strong></p><p>A: SRP focuses on a single responsibility and reason to change. ISP focuses on ensuring that clients depend only on the functionality they need.</p><p><strong>Q: What is the difference between LSP and ISP?</strong></p><p>A: LSP ensures that implementations respect their behavioral contracts and can be used interchangeably. ISP ensures that clients are not forced to depend on unnecessary interfaces.</p><h3>Core idea</h3><p><strong>Small interfaces. Focused capabilities. Minimal dependencies.</strong></p><p>Design protocols around the needs of their clients rather than the complete functionality of their implementations.</p><p>🐇 SOLID — A practical introduction:</p><p><a href="https://nikolaiborisov.github.io/?utm_source=chatgpt.com#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 Programming Principles Quiz:</p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008?utm_source=chatgpt.com">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52423d62edcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — LSP — Liskov Substitution Principle]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-lsp-liskov-substitution-principle-eb14a3382cd1?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb14a3382cd1</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Wed, 02 Dec 2026 03:43:44 GMT</pubDate>
            <atom:updated>2026-12-02T03:43:44.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mvp0vlMJAmz4_QdVWCjndQ.png" /></figure><p>The <strong>Liskov Substitution Principle (LSP)</strong> is the third of the five SOLID principles of object-oriented design.</p><blockquote><em>Objects of a subtype should be replaceable with objects of their base type without affecting the correctness of the program.</em></blockquote><p>The principle encourages us to design types that can be used interchangeably without breaking the expected behavior of the system.</p><p>In Swift, LSP applies to both class inheritance and protocol-based abstractions.</p><ul><li><strong>Substitutability:</strong> Different implementations of an abstraction should be interchangeable.</li><li><strong>Behavioral consistency:</strong> Each implementation should respect the expected behavior of its contract.</li><li><strong>Predictability:</strong> The caller should not need to know which concrete implementation it is working with.</li></ul><p>💡 LSP is not simply about matching method signatures. It is about respecting the behavioral contract behind those methods.</p><h3>The problem — violating LSP</h3><p>Imagine a payment system that supports different payment methods. Every payment method is expected to process a payment.</p><pre>protocol PaymentMethod {<br>    func pay(amount: Int)<br>}<br><br>struct CreditCard: PaymentMethod {<br>    func pay(amount: Int) {<br>        print(&quot;Paid \(amount) using a credit card&quot;)<br>    }<br>}<br><br>struct GiftCard: PaymentMethod {<br>    func pay(amount: Int) {<br>        fatalError(&quot;Payment is not supported&quot;)<br>    }<br>}<br><br>struct Checkout {<br>    func complete(<br>        amount: Int,<br>        payment: any PaymentMethod<br>    ) {<br>        payment.pay(amount: amount)<br>    }<br>}<br><br>let checkout = Checkout()<br><br>checkout.complete(amount: 100, payment: CreditCard())<br>// Paid 100 using a credit card<br><br>checkout.complete(amount: 100, payment: GiftCard())<br>// Runtime crash</pre><p>Although both CreditCard and GiftCard conform to the PaymentMethod protocol, they cannot be used interchangeably.</p><p>The GiftCard implementation violates the expected behavior of the protocol by crashing instead of processing the payment.</p><p>This creates several potential problems:</p><ul><li>Unexpected runtime failures.</li><li>Broken behavioral contracts.</li><li>Additional type checks and special conditions.</li><li>Unpredictable behavior.</li><li>Reduced reliability and maintainability.</li></ul><h3>The solution — applying LSP</h3><p>Instead of allowing implementations that cannot fulfill the contract, we ensure that every payment method supports the expected payment operation.</p><p>We also improve the contract to account for legitimate payment failures.</p><h3>Swift example — try it in a Playground</h3><pre>enum PaymentError: Error {<br>    case insufficientBalance<br>    case invalidAmount<br>}<br><br>protocol PaymentMethod {<br>    func pay(amount: Int) throws<br>}<br><br>struct CreditCard: PaymentMethod {<br>    func pay(amount: Int) throws {<br>        guard amount &gt; 0 else {<br>            throw PaymentError.invalidAmount<br>        }<br><br>        print(&quot;Paid \(amount) using a credit card&quot;)<br>    }<br>}<br><br>struct GiftCard: PaymentMethod {<br>    let balance: Int<br><br>    func pay(amount: Int) throws {<br>        guard amount &gt; 0 else {<br>            throw PaymentError.invalidAmount<br>        }<br><br>        guard amount &lt;= balance else {<br>            throw PaymentError.insufficientBalance<br>        }<br><br>        print(&quot;Paid \(amount) using a gift card&quot;)<br>    }<br>}<br><br>struct Checkout {<br>    func complete(<br>        amount: Int,<br>        payment: any PaymentMethod<br>    ) {<br>        do {<br>            try payment.pay(amount: amount)<br>        } catch {<br>            print(&quot;Payment failed: \(error)&quot;)<br>        }<br>    }<br>}<br><br>let checkout = Checkout()<br><br>checkout.complete(<br>    amount: 100,<br>    payment: CreditCard()<br>)<br>// Paid 100 using a credit card<br><br>checkout.complete(<br>    amount: 100,<br>    payment: GiftCard(balance: 150)<br>)<br>// Paid 100 using a gift card<br><br>checkout.complete(<br>    amount: 100,<br>    payment: GiftCard(balance: 50)<br>)<br>// Payment failed: insufficientBalance</pre><p>Both implementations now respect the same behavioral contract: process a valid payment or report a failure through the defined error-handling mechanism.</p><p>The Checkout type does not need to know which payment method it receives.</p><p>A failed payment does not violate LSP when failure is part of the expected contract.</p><p>For simplicity, this example simulates payment processing rather than performing real transactions or updating account balances.</p><h3>Extending functionality</h3><p>Suppose we introduce two additional payment methods:</p><pre>struct ApplePay: PaymentMethod {<br>    func pay(amount: Int) throws {<br>        guard amount &gt; 0 else {<br>            throw PaymentError.invalidAmount<br>        }<br><br>        print(&quot;Paid \(amount) using Apple Pay&quot;)<br>    }<br>}<br><br>struct PayPal: PaymentMethod {<br>    func pay(amount: Int) throws {<br>        guard amount &gt; 0 else {<br>            throw PaymentError.invalidAmount<br>        }<br><br>        print(&quot;Paid \(amount) using PayPal&quot;)<br>    }<br>}<br><br>checkout.complete(amount: 100, payment: ApplePay())<br>// Paid 100 using Apple Pay<br><br>checkout.complete(amount: 100, payment: PayPal())<br>// Paid 100 using PayPal</pre><p>Every payment method can be substituted for another without breaking the checkout logic.</p><p>Each implementation provides its own payment behavior while respecting the same contract.</p><h3>Visual representation</h3><p><strong>Violating LSP:</strong></p><p>Checkout → PaymentMethod</p><ul><li>CreditCard → Payment processed</li><li>GiftCard → Runtime crash</li></ul><p><strong>Applying LSP:</strong></p><p>Checkout → PaymentMethod</p><ul><li>CreditCard → Payment result</li><li>GiftCard → Payment result</li><li>ApplePay → Payment result</li><li>PayPal → Payment result</li></ul><p>All implementations respect the same behavioral contract.</p><h3>Benefits of LSP</h3><ul><li><strong>Substitutability:</strong> Replace implementations without breaking existing functionality.</li><li><strong>Predictability:</strong> Maintain consistent behavior across implementations.</li><li><strong>Reliability:</strong> Reduce unexpected failures caused by incompatible implementations.</li><li><strong>Testability:</strong> Test different implementations against a common contract.</li><li><strong>Polymorphism:</strong> Work with different concrete types through a shared abstraction.</li><li><strong>Maintainability:</strong> Reduce unnecessary type checks and special-case logic.</li><li><strong>Reusability:</strong> Reuse components with interchangeable implementations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UoewYfDhoP9Thp_VTYi_iA.png" /></figure><h3>How to apply it</h3><ol><li>Define a clear behavioral contract for the abstraction.</li><li>Ensure every implementation respects that contract.</li><li>Avoid introducing unexpected restrictions on valid inputs.</li><li>Preserve the guarantees and invariants defined by the abstraction.</li><li>Handle failures through the expected error-handling mechanism.</li><li>Avoid concrete type checks in the caller when the abstraction should be sufficient.</li><li>Test implementations against the same behavioral expectations.</li></ol><h3>Common mistakes</h3><p><strong>Confusing conformance with substitutability</strong></p><p>A type can conform to a protocol and still violate LSP. Matching method signatures does not guarantee correct behavior.</p><p><strong>Unsupported operations</strong></p><p>Avoid implementations that use fatalError() or silently ignore required operations because they cannot fulfill the expected contract.</p><p><strong>Strengthening preconditions</strong></p><p>An implementation should not introduce additional requirements that contradict the abstraction’s accepted inputs.</p><p><strong>Weakening postconditions</strong></p><p>An implementation should not provide fewer guarantees than those promised by the abstraction.</p><p><strong>Incorrect inheritance</strong></p><p>Do not create inheritance relationships solely to reuse code when the subtype cannot behave consistently with its base type.</p><p><strong>Excessive type checking</strong></p><p>If callers repeatedly need to check concrete types to handle unexpected differences in behavior, the abstraction may violate LSP.</p><h3>LSP in real-world iOS development</h3><p><strong>Networking</strong></p><p>Production and mock API clients should respect the same request, response, and error-handling contracts.</p><p><strong>Data persistence</strong></p><p>Core Data, SwiftData, and in-memory repository implementations should preserve the behavior promised by their shared abstraction.</p><p><strong>Authentication</strong></p><p>Different authentication providers should follow a consistent authentication contract and report success or failure through the expected mechanism.</p><p><strong>Analytics</strong></p><p>Different analytics providers should respect the event-tracking contract without introducing unexpected behavior.</p><p><strong>Dependency injection</strong></p><p>Production services and test doubles should be interchangeable without violating the expectations of the components that depend on them.</p><p><strong>SwiftUI</strong></p><p>Different implementations of a service used by an observable model should preserve the expected behavior without requiring changes to the view or its state management logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_y9qfqTs7t-4nsT2wNmO1Q.png" /></figure><h3>Interview case</h3><p><strong>Q: A type conforms to a protocol but crashes when one of its required methods is called. Which SOLID principle might be violated?</strong></p><p><strong>A:</strong> The Liskov Substitution Principle. If the operation is expected to be supported, the implementation violates the behavioral contract and cannot safely substitute other implementations.</p><p><strong>Q: Does LSP apply only to class inheritance?</strong></p><p><strong>A:</strong> No. In Swift, LSP also applies to protocol-based abstractions. Structs and classes conforming to the same protocol should respect its behavioral contract.</p><p><strong>Q: Does LSP require every implementation to produce identical results?</strong></p><p><strong>A:</strong> No. Implementations can produce different results and use different internal logic as long as they preserve the guarantees defined by the abstraction.</p><p><strong>Q: Does throwing an error violate LSP?</strong></p><p><strong>A:</strong> Not necessarily. If failure is part of the abstraction’s contract, throwing an appropriate error is valid behavior.</p><p><strong>Q: What is the difference between OCP and LSP?</strong></p><p><strong>A:</strong> OCP focuses on extending functionality without repeatedly modifying existing business logic. LSP ensures that those additional implementations can be used interchangeably without breaking expected behavior.</p><h3>Core idea</h3><p><strong>Same abstraction. Consistent contract. Interchangeable implementations.</strong></p><p>Design types that respect their behavioral contracts and can replace one another without breaking the correctness of the system.</p><p>🐇 <strong>SOLID — A practical introduction:</strong></p><p><a href="https://nikolaiborisov.github.io/#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 <strong>Programming Principles Quiz:</strong></p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb14a3382cd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — OCP — Open/Closed Principle]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-ocp-open-closed-principle-51fadbf0937b?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/51fadbf0937b</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 03:40:27 GMT</pubDate>
            <atom:updated>2026-12-01T03:47:52.987Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oH11Vt0sqLyaieWDk9EL2w.png" /></figure><p>The <strong>Open/Closed Principle (OCP)</strong> is the second of the five SOLID principles of object-oriented design.</p><blockquote><em>Software entities should be open for extension but closed for modification.</em></blockquote><p>The principle encourages us to design software components so that new functionality can be introduced without repeatedly modifying existing, stable implementations.</p><p>In Swift, OCP can be achieved through protocol-oriented programming, composition, generics, and class inheritance.</p><ul><li><strong>Open for extension:</strong> New behavior can be introduced through additional implementations.</li><li><strong>Closed for modification:</strong> Existing business logic does not need to change whenever a new variation is introduced.</li></ul><p>💡 OCP does not mean that existing code should never be modified. It means designing stable boundaries that accommodate new behavior while minimizing unnecessary changes.</p><h3>The problem — violating OCP</h3><p>Imagine a checkout system that calculates shipping costs based on the selected delivery method.</p><pre>enum ShippingMethod {<br>    case standard<br>    case pickup<br>}<br><br>struct Checkout {<br>    func total(items: Int, shipping: ShippingMethod) -&gt; Int {<br>        switch shipping {<br>        case .standard:<br>            return items + 5<br>        case .pickup:<br>            return items<br>        }<br>    }<br>}</pre><p>Every time a new shipping method is introduced, such as express or international delivery, we need to update the enum and modify the checkout logic.</p><p>This creates several potential problems:</p><ul><li>Tight coupling between checkout and shipping implementations.</li><li>Repeated modifications to existing business logic.</li><li>Increased risk of introducing regressions.</li><li>Reduced extensibility and maintainability.</li></ul><h3>The solution — applying OCP</h3><p>Instead of making Checkout responsible for calculating every shipping cost, we introduce a protocol that defines a common contract for shipping implementations.</p><h3>Swift example — try it in a Playground</h3><pre>protocol ShippingCost {<br>    func cost() -&gt; Int<br>}<br><br>struct StandardShipping: ShippingCost {<br>    func cost() -&gt; Int { 5 }<br>}<br><br>struct Pickup: ShippingCost {<br>    func cost() -&gt; Int { 0 }<br>}<br><br>struct Checkout {<br>    func total(items: Int, shipping: any ShippingCost) -&gt; Int {<br>        items + shipping.cost()<br>    }<br>}<br><br>let checkout = Checkout()<br><br>print(checkout.total(items: 20, shipping: StandardShipping()))<br>// 25<br><br>print(checkout.total(items: 20, shipping: Pickup()))<br>// 20</pre><p>The Checkout type depends on the ShippingCost abstraction rather than concrete shipping implementations.</p><h3>Extending functionality</h3><p>Suppose we introduce two additional shipping methods:</p><pre>struct ExpressShipping: ShippingCost {<br>    func cost() -&gt; Int { 10 }<br>}<br><br>struct InternationalShipping: ShippingCost {<br>    func cost() -&gt; Int { 25 }<br>}<br><br>print(checkout.total(items: 20, shipping: ExpressShipping()))<br>// 30<br><br>print(checkout.total(items: 20, shipping: InternationalShipping()))<br>// 45</pre><p>We have extended the system without modifying the existing Checkout implementation.</p><p>Each shipping option encapsulates its own pricing behavior, while checkout remains responsible for calculating the total.</p><h3>Visual representation</h3><h3>Benefits of OCP</h3><ul><li><strong>Extensibility:</strong> Introduce new functionality without repeatedly changing existing business logic.</li><li><strong>Maintainability:</strong> Keep components focused on their responsibilities.</li><li><strong>Loose coupling:</strong> Depend on abstractions rather than concrete implementations.</li><li><strong>Testability:</strong> Test individual implementations independently.</li><li><strong>Reduced regression risk:</strong> Minimize changes to existing, tested functionality.</li><li><strong>Reusability:</strong> Reuse existing components with different implementations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mp8pOB2G2fEvD3ZgQVYo1g.png" /></figure><h3>How to apply it</h3><ol><li>Identify behavior that frequently changes or requires extension.</li><li>Define a stable abstraction using a protocol or another suitable mechanism.</li><li>Encapsulate varying behavior in separate implementations.</li><li>Make the caller depend on the abstraction.</li><li>Introduce new implementations without modifying stable business logic.</li><li>Test both existing and newly introduced behavior.</li></ol><h3>Common mistakes</h3><p><strong>Premature abstraction</strong></p><p>Do not introduce protocols and additional types for every possible future requirement. Abstract behavior when there is a genuine need for variation.</p><p><strong>Avoiding all modifications</strong></p><p>OCP does not prohibit modifying existing code. Bug fixes, refactoring, and changing business requirements may still require modifications.</p><p><strong>Overengineering simple logic</strong></p><p>A small switch statement over a fixed set of enum cases can be clearer and more maintainable than multiple implementations.</p><p><strong>Unnecessary inheritance</strong></p><p>Inheritance is not required to achieve OCP. Swift supports extensibility through protocol conformance, composition, and generics.</p><h3>OCP in real-world iOS development</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TXzPZaF7ukADVzqwOj0hlA.png" /></figure><h3>Interview case</h3><p><strong>Q: Every new delivery method forces modifications to the checkout logic. Which SOLID principle could help?</strong></p><p><strong>A:</strong> The Open/Closed Principle. Introduce a shipping-cost protocol and encapsulate each delivery method in a separate implementation. Checkout depends on the protocol rather than specific delivery methods, allowing new shipping options to be introduced without modifying its existing logic.</p><p><strong>Q: Does OCP mean existing code should never be modified?</strong></p><p><strong>A:</strong> No. OCP encourages designing stable components that accommodate anticipated variations through extension. Existing code can still be modified to fix bugs, improve architecture, or accommodate changing requirements.</p><p><strong>Q: Is inheritance necessary to implement OCP?</strong></p><p><strong>A:</strong> No. Both structs and classes can conform to protocols, enabling extensibility and polymorphism without class inheritance.</p><h3>Core idea</h3><p><strong>Open for extension. Closed for unnecessary modification.</strong></p><p>Design stable abstractions, encapsulate varying behavior, and introduce new functionality without repeatedly modifying existing business logic.</p><p>🐇 <strong>SOLID — A practical introduction:</strong></p><p><a href="https://nikolaiborisov.github.io/?utm_source=chatgpt.com#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 <strong>Programming Principles Quiz:</strong></p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008?utm_source=chatgpt.com">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51fadbf0937b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — SRP — Single Responsibility Principle]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-srp-single-responsibility-principle-badcd014acde?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/badcd014acde</guid>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Mon, 30 Nov 2026 04:03:20 GMT</pubDate>
            <atom:updated>2026-12-01T03:47:15.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1i_yJfFpLQy3_nyNuPcwkg.png" /></figure><p>The <strong>Single Responsibility Principle (SRP)</strong> is the first of the five SOLID principles. It states that a software module should have only one reason to change.</p><p>Imagine a profile screen that validates user information, saves user preferences, and formats profile data for display. Changes to validation rules, storage mechanisms, or presentation requirements could all affect the same component.</p><p>SRP helps us separate these responsibilities into focused, independent components, making code easier to understand, maintain, and test.</p><p>A responsibility is not necessarily a single method or operation. It is a cohesive set of behaviors that change for the same reason.</p><p>💡 <strong>One responsibility does not mean one method. It means one reason to change.</strong></p><h3>Swift example — try it in a Playground</h3><p><strong>Before applying SRP</strong></p><p>The UserManager handles three different responsibilities: validation, persistence, and presentation.</p><pre>import Foundation<br><br>struct User {<br>    let name: String<br>    let email: String<br>}<br><br>struct UserManager {<br>    func validate(_ user: User) -&gt; Bool {<br>        !user.name.isEmpty &amp;&amp; user.email.contains(&quot;@&quot;)<br>    }<br><br>    func save(_ user: User) {<br>        UserDefaults.standard.set(user.name, forKey: &quot;name&quot;)<br>        UserDefaults.standard.set(user.email, forKey: &quot;email&quot;)<br>    }<br><br>    func displayName(_ user: User) -&gt; String {<br>        &quot;Welcome, \(user.name)!&quot;<br>    }<br>}</pre><p>The UserManager has three independent reasons to change:</p><ul><li>Validation rules change.</li><li>The storage mechanism changes.</li><li>Presentation requirements change.</li><li><strong>After applying SRP</strong></li></ul><p>Each responsibility belongs to a separate type.</p><pre>import Foundation<br><br>struct User {<br>    let name: String<br>    let email: String<br>}<br><br>// Responsibility: user validation.<br>struct UserValidator {<br>    func validate(_ user: User) -&gt; Bool {<br>        !user.name.isEmpty &amp;&amp; user.email.contains(&quot;@&quot;)<br>    }<br>}<br><br>// Responsibility: user persistence.<br>struct UserStorage {<br>    func save(_ user: User) {<br>        UserDefaults.standard.set(user.name, forKey: &quot;name&quot;)<br>        UserDefaults.standard.set(user.email, forKey: &quot;email&quot;)<br>    }<br>}<br><br>// Responsibility: user presentation.<br>struct UserFormatter {<br>    func displayName(_ user: User) -&gt; String {<br>        &quot;Welcome, \(user.name)!&quot;<br>    }<br>}<br><br>let user = User(<br>    name: &quot;Alex&quot;,<br>    email: &quot;alex@example.com&quot;<br>)<br><br>let validator = UserValidator()<br>let storage = UserStorage()<br>let formatter = UserFormatter()<br><br>if validator.validate(user) {<br>    storage.save(user)<br>    print(formatter.displayName(user))<br>}<br><br>// Welcome, Alex!</pre><p>The validation and persistence implementations are intentionally simplified for this educational example.</p><h3>How SRP changes the architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1h6iWh27e0om-aUH5NOlWQ.png" /></figure><h3>How to use it</h3><ul><li>Identify independent reasons why a component might change.</li><li>Group related data and behavior into focused types.</li><li>Separate business logic, persistence, networking, and presentation when they have independent responsibilities.</li><li>Keep related functionality together instead of creating unnecessary abstractions.</li><li>Introduce new boundaries when they solve a real problem.</li></ul><h3>How SRP improves code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKQoxXNiev-xOaZmwnkrgw.png" /></figure><p>Each component can evolve independently, reducing the risk of introducing unrelated bugs.</p><h3>Additional concepts demonstrated</h3><p><strong>Separation of concerns</strong></p><p>Validation, persistence, and presentation are separated into independent components.</p><pre>struct UserValidator { ... }<br><br>struct UserStorage { ... }<br><br>struct UserFormatter { ... }</pre><p><strong>High cohesion</strong></p><p>Each type contains functionality related to its responsibility.</p><pre>struct UserValidator {<br>    func validateName(_ name: String) -&gt; Bool {<br>        !name.isEmpty<br>    }<br><br>    func validateEmail(_ email: String) -&gt; Bool {<br>        email.contains(&quot;@&quot;)<br>    }<br><br>    func validate(_ user: User) -&gt; Bool {<br>        validateName(user.name) &amp;&amp;<br>        validateEmail(user.email)<br>    }<br>}</pre><p>Multiple methods can belong to the same responsibility without violating SRP.</p><p><strong>Loose coupling</strong></p><p>The validator, storage, and formatter do not depend directly on each other.</p><pre>let validator = UserValidator()<br>let storage = UserStorage()<br>let formatter = UserFormatter()</pre><p><strong>Composition over inheritance</strong></p><p>A higher-level component can coordinate focused types instead of implementing all their responsibilities itself.</p><pre>struct UserRegistration {<br>    let validator: UserValidator<br>    let storage: UserStorage<br><br>    func register(_ user: User) -&gt; Bool {<br>        guard validator.validate(user) else {<br>            return false<br>        }<br><br>        storage.save(user)<br>        return true<br>    }<br>}</pre><p>The responsibility of UserRegistration is to coordinate the registration process.</p><p><strong>Testability</strong></p><p>Validation can be tested independently without accessing storage or presentation logic.</p><pre>let validator = UserValidator()<br><br>let validUser = User(<br>    name: &quot;Alex&quot;,<br>    email: &quot;alex@example.com&quot;<br>)<br><br>let invalidUser = User(<br>    name: &quot;&quot;,<br>    email: &quot;invalid&quot;<br>)<br><br>assert(validator.validate(validUser))<br>assert(!validator.validate(invalidUser))</pre><p>💡 <strong>SRP does not require protocols, inheritance, or dependency injection.</strong> It is about defining clear responsibilities and boundaries between components.</p><h3>Common mistakes</h3><ul><li>Assuming that one responsibility means one method per type.</li><li>Splitting components into unnecessarily small types.</li><li>Measuring responsibilities by the number of lines of code.</li><li>Creating generic Manager, Helper, or Utility types that accumulate unrelated functionality.</li><li>Introducing protocols and abstractions without a practical reason.</li><li>Confusing responsibility with the number of operations a component performs.</li></ul><h3>Interview case</h3><p><strong>Q: Can a struct or class have multiple methods and still follow the Single Responsibility Principle?</strong></p><p>A: Yes. SRP is not about the number of methods but about the reasons for change. A UserValidator can contain multiple validation methods because they all belong to the same responsibility. However, adding persistence or presentation logic would introduce independent reasons to change.</p><h3>Core idea</h3><p><strong>Group what changes together. Separate what changes for different reasons.</strong></p><p>🐇 <strong>SOLID — A practical introduction:</strong></p><p><a href="https://nikolaiborisov.github.io/?utm_source=chatgpt.com#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 <strong>Programming Principles Quiz:</strong></p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008?utm_source=chatgpt.com">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=badcd014acde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — Programming principles in iOS — SOLID]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-programming-principles-in-ios-solid-2f8741b43284?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f8741b43284</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 04:36:07 GMT</pubDate>
            <atom:updated>2026-11-27T04:36:07.483Z</atom:updated>
            <content:encoded><![CDATA[<p>Programming principles are guidelines for making code easier to understand, change, and test. Imagine a profile screen that loads a user, saves preferences, and builds its own UI. One small change can disturb several unrelated jobs.</p><p>SOLID gives us five questions for improving those boundaries: does each component have a clear responsibility, can behavior grow safely, do replacements keep their promises, are interfaces focused, and do important rules depend on suitable abstractions? SOLID stands for Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.</p><p>An abstraction is a contract that describes what a collaborator can do without exposing how it does it; a Swift protocol is one way to express it.</p><p>Start with working code, notice a real source of change, and improve one boundary at a time. These ideas apply to Swift structs and protocols as well as classes.</p><p><strong>Swift example — try it in a Playground</strong></p><pre>// I — Interface Segregation Principle (ISP)<br>// A small, focused protocol with only the required functionality.<br>protocol GreetingProviding {<br>    func greeting() -&gt; String<br>}<br><br>// S — Single Responsibility Principle (SRP)<br>// Each provider is responsible for generating a greeting.<br>struct FriendlyGreeting: GreetingProviding {<br>    func greeting() -&gt; String {<br>        &quot;Hello, Swift!&quot;<br>    }<br>}<br><br>// O — Open/Closed Principle (OCP)<br>// Add new functionality without modifying existing types.<br>struct FormalGreeting: GreetingProviding {<br>    func greeting() -&gt; String {<br>        &quot;Good morning!&quot;<br>    }<br>}<br><br>// D — Dependency Inversion Principle (DIP)<br>// Depend on an abstraction, not a concrete implementation.<br>struct WelcomeMessage {<br>    let provider: any GreetingProviding<br><br>    func text() -&gt; String {<br>        provider.greeting()<br>    }<br>}<br><br>// L — Liskov Substitution Principle (LSP)<br>// Providers can be substituted without breaking expected behavior.<br>let friendly = WelcomeMessage(provider: FriendlyGreeting())<br>let formal = WelcomeMessage(provider: FormalGreeting())<br><br>print(friendly.text()) // Hello, Swift!<br>print(formal.text())   // Good morning!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RgTjkiDesysNIgNTOHnKPA.png" /></figure><h3>How to use it</h3><ul><li>First identify a change: for example, a different greeting provider for a test.</li><li>SRP: group one responsibility. OCP: add behavior through a stable boundary. LSP: keep the promised behavior.</li><li>ISP: expose only needed capabilities. DIP: let policy use a contract instead of a concrete implementation.</li></ul><h3>How all five principles work together</h3><p>Principle &amp; Implementation</p><p><strong>S — Single Responsibility</strong></p><p>Each type has a focused responsibility.</p><p><strong>O — Open/Closed</strong></p><p>New greeting providers can be added without modifying WelcomeMessage.</p><p><strong>L — Liskov Substitution</strong></p><p>Greeting providers are interchangeable as long as they respect the protocol’s behavioral contract.</p><p><strong>I — Interface Segregation</strong></p><p>GreetingProviding exposes only the functionality the consumer needs.</p><p><strong>D — Dependency Inversion</strong></p><p>WelcomeMessage depends on a protocol rather than a concrete provider.</p><h3>Additional concepts demonstrated</h3><ul><li><strong>Dependency Injection (DI)</strong></li></ul><pre>let friendly = WelcomeMessage(<br>    provider: FriendlyGreeting()<br>)</pre><ul><li><strong>Protocol-Oriented Programming (POP)</strong></li></ul><pre>protocol GreetingProviding {<br>    func greeting() -&gt; String<br>}<br><br>struct FriendlyGreeting: GreetingProviding {<br>    func greeting() -&gt; String {<br>        &quot;Hello, Swift!&quot;<br>    }<br>}</pre><ul><li><strong>Composition over inheritance</strong></li></ul><pre>struct WelcomeMessage {<br>    let provider: any GreetingProviding<br><br>    func text() -&gt; String {<br>        provider.greeting()<br>    }<br>}</pre><ul><li><strong>Loose coupling</strong></li></ul><pre>let provider: any GreetingProviding</pre><ul><li><strong>Polymorphism</strong></li></ul><pre>let friendly = WelcomeMessage(provider: FriendlyGreeting())<br>let formal = WelcomeMessage(provider: FormalGreeting())<br><br>print(friendly.text()) // Hello, Swift!<br>print(formal.text())   // Good morning!</pre><ul><li><strong>Separation of concerns</strong></li></ul><pre>protocol GreetingProviding { ... }<br><br>struct FriendlyGreeting: GreetingProviding { ... }<br><br>struct FormalGreeting: GreetingProviding { ... }<br><br>struct WelcomeMessage { ... }</pre><ul><li><strong>Testability</strong></li></ul><pre>struct MockGreeting: GreetingProviding {<br>    func greeting() -&gt; String {<br>        &quot;Test greeting&quot;<br>    }<br>}<br><br>let message = WelcomeMessage(provider: MockGreeting())<br><br>assert(message.text() == &quot;Test greeting&quot;)</pre><p>💡 <strong>SOLID is not limited to classes or object-oriented programming.</strong> All five principles can also be applied using Swift structs, protocols and composition.</p><h3>Common mistakes</h3><ul><li>Do not add a protocol for every struct automatically.</li><li>SOLID does not replace readable names, tests, or product requirements.</li></ul><p><strong>Interview case</strong></p><p><strong>Q: Would you apply all five principles to a tiny greeting function?</strong></p><p>A: No. A simple function may be enough. I introduce a boundary when it helps with a real change or test. In this example a provider is useful when greetings actually vary.</p><p><strong>Core idea</strong></p><p><strong>Use SOLID to reduce the cost of change, one useful boundary at a time.</strong></p><p>🐇 <strong>SOLID — A practical introduction:</strong></p><p><a href="https://nikolaiborisov.github.io/#programming-principles">https://nikolaiborisov.github.io/#programming-principles</a></p><p>🧠 Programming Principles Quiz:</p><p><a href="https://apps.apple.com/th/app/isolid-learn-programming/id6752113008">https://apps.apple.com/th/app/isolid-learn-programming/id6752113008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f8741b43284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Swift Bites #001 | ARC in Swift]]></title>
            <link>https://medium.com/@andersonnikko1/swift-bites-001-arc-in-swift-ce99d68b8e6f?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce99d68b8e6f</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 04:08:48 GMT</pubDate>
            <atom:updated>2026-11-26T04:08:48.642Z</atom:updated>
            <content:encoded><![CDATA[<p>ARC (Automatic Reference Counting) is Swift’s automatic memory management mechanism for reference types.</p><p>ARC tracks strong references to class instances and deallocates an instance when no strong references remain.</p><p>💡 When an object is no longer strongly referenced, Swift automatically releases its memory.</p><p>Compile time vs. runtime</p><ul><li>Compile time: The compiler inserts and optimizes retain and release operations.</li><li>Runtime: Reference counting takes place, and instances are deallocated when their strong reference count reaches zero.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kLqNu6-bSqA4DcnHAVXCbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anHRpfJ_EJgK0n_N714h5A.png" /></figure><p>🎓 Explore iSOLID Swift Quiz: <a href="https://lnkd.in/dQtNGYm6">https://lnkd.in/dQtNGYm6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce99d68b8e6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — Build your portfolio website before you start building your iOS App]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-build-your-portfolio-website-before-you-start-building-your-ios-app-3e27e7a12336?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e27e7a12336</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[portfolio-website]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 02:03:27 GMT</pubDate>
            <atom:updated>2026-11-27T04:21:13.607Z</atom:updated>
            <content:encoded><![CDATA[<p>A portfolio website is the perfect beginner project because it gives you visible progress fast. You are not only reading theory. You are building a real page with your name, your story, your projects, and your contacts.</p><h3>Do Not Drown In Theory</h3><ul><li>Theory matters, but beginners often get stuck trying to understand everything before building anything.</li><li>A visible project gives your brain feedback: this text moved, this color changed, this button works.</li><li>That feedback builds confidence because progress becomes something you can see, not only something you hope is happening.</li></ul><h3>Why A Portfolio Works</h3><ul><li>It is small enough to finish, but real enough to teach layout, structure, styling, interaction, Git, and deployment.</li><li>It becomes useful immediately: you can send it to mentors, recruiters, classmates, or clients.</li><li>Every improvement has meaning because the website represents you.</li></ul><h3>Good Beginner Mindset</h3><ul><li>Build version 1 first. Keep it simple, clean, and honest.</li><li>Do not wait for the perfect design. Start with a readable page and improve it step by step.</li><li>When you learn a new tag, property, or command, use it inside your own website the same day.</li></ul><p><strong>Tiny goal for day one</strong></p><pre>1. Create index.html<br>2. Add your name and role<br>3. Add one short bio paragraph<br>4. Open it in the browser<br>5. Change one color and one font size</pre><p><strong>Portfolio mindset</strong></p><p><strong>Learning becomes easier when every topic has a visible result.</strong></p><p>HTML, CSS, and JavaScript are the three core pieces of a web page. A useful beginner model: HTML is the structure, CSS is the visual design, and JavaScript is the behavior.</p><h3>HTML</h3><ul><li>HTML means HyperText Markup Language.</li><li>It describes what exists on the page: headings, paragraphs, images, links, buttons, sections, lists, and forms.</li><li>HTML should be meaningful. A contact area should be a section, a main title should be an h1, and navigation should live inside nav.</li></ul><h3>CSS</h3><ul><li>CSS means Cascading Style Sheets.</li><li>It controls how the page looks: colors, spacing, fonts, layout, borders, shadows, responsiveness, and dark mode.</li><li>Good CSS makes the same HTML feel clear, polished, and usable on phones and desktops.</li></ul><h3>JavaScript</h3><ul><li>JavaScript adds behavior: opening menus, switching themes, filtering projects, validating forms, copying text, and changing content without reloading the page.</li><li>For this portfolio, JavaScript can power light/dark mode, language switching, and small interactions.</li><li>Use JavaScript after the HTML already makes sense. Behavior should support the content, not hide it.</li></ul><p><strong>The three pieces together</strong></p><pre>&lt;h1&gt;Niko Anderson&lt;/h1&gt;<br>&lt;p&gt;iOS Developer building useful apps with Swift.&lt;/p&gt;<br>&lt;button id=&quot;themeButton&quot;&gt;Switch theme&lt;/button&gt;</pre><p><strong>CSS changes the look</strong></p><pre>body {<br>  font-family: Arial, sans-serif;<br>  background: #0f172a;<br>  color: #f8fafc;<br>}</pre><p><strong>JavaScript adds action</strong></p><pre>document.querySelector(&quot;#themeButton&quot;).addEventListener(&quot;click&quot;, () =&gt; {<br>  document.body.classList.toggle(&quot;light&quot;);<br>});</pre><p><strong>Portfolio mindset</strong></p><p><strong>HTML says what it is. CSS says how it looks. JavaScript says what happens.</strong></p><p>HTML is the skeleton of your portfolio. The goal is not to memorize every tag. The goal is to choose meaningful tags so your page is readable for people, browsers, search engines, and accessibility tools.</p><h3>Core Tags</h3><ul><li>html wraps the whole page.</li><li>head contains metadata, title, fonts, and CSS links.</li><li>body contains visible content.</li><li>header, main, section, and footer create page landmarks.</li><li>div is a generic box. Use it when no more meaningful tag fits.</li><li>br creates a line break, but normal spacing should usually be done with CSS.</li><li>ul, ol, and li create lists. Use them for skills, steps, education items, and project features.</li></ul><h3>Portfolio Sections</h3><ul><li>Hero: your name, role, short value line, and primary links.</li><li>Bio/About: who you are, what you build, what you care about.</li><li>Projects: cards with title, description, tech stack, links, and screenshots.</li><li>Skills, education, contact: quick proof and clear next action.</li></ul><h3>Useful Attributes</h3><ul><li>id gives one unique name to an element, useful for navigation and JavaScript.</li><li>class groups elements for styling.</li><li>href sets a link destination.</li><li>src sets an image path.</li><li>alt explains an image for accessibility and when images fail to load.</li></ul><p><strong>Portfolio page structure</strong></p><pre>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br><br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Niko Anderson | Portfolio&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;css/styles.css&quot;&gt;<br><br>  &lt;/head&gt;<br>  &lt;body&gt;<br><br>    &lt;header class=&quot;site-header&quot;&gt;<br>      &lt;nav&gt;<br>        &lt;a href=&quot;#about&quot;&gt;About&lt;/a&gt;<br>        &lt;a href=&quot;#projects&quot;&gt;Projects&lt;/a&gt;<br>        &lt;a href=&quot;#contact&quot;&gt;Contact&lt;/a&gt;<br>      &lt;/nav&gt;<br>    &lt;/header&gt;<br><br>    &lt;main&gt;<br>      &lt;section class=&quot;hero&quot; id=&quot;home&quot;&gt;<br>        &lt;p class=&quot;eyebrow&quot;&gt;iOS Developer&lt;/p&gt;<br>        &lt;h1&gt;Niko Anderson&lt;/h1&gt;<br>        &lt;p&gt;I build clean, useful mobile apps and simple web tools.&lt;/p&gt;<br>        &lt;a href=&quot;#projects&quot;&gt;View projects&lt;/a&gt;<br>      &lt;/section&gt;<br><br>      &lt;section id=&quot;about&quot;&gt;<br>        &lt;h2&gt;About&lt;/h2&gt;<br>        &lt;p&gt;I enjoy turning ideas into readable interfaces.&lt;/p&gt;<br>      &lt;/section&gt;<br><br>    &lt;/main&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Lists and project cards</strong></p><pre>&lt;section id=&quot;skills&quot;&gt;<br>  &lt;h2&gt;Skills&lt;/h2&gt;<br>  &lt;ul&gt;<br>    &lt;li&gt;HTML&lt;/li&gt;<br>    &lt;li&gt;CSS&lt;/li&gt;<br>    &lt;li&gt;JavaScript&lt;/li&gt;<br>  &lt;/ul&gt;<br>&lt;/section&gt;<br><br>&lt;article class=&quot;project-card&quot;&gt;<br>  &lt;img src=&quot;img/portfolio-preview.png&quot; alt=&quot;Portfolio website preview&quot;&gt;<br>  &lt;h3&gt;Portfolio Website&lt;/h3&gt;<br>  &lt;p&gt;A personal website with dark mode and language switch.&lt;/p&gt;<br>  &lt;a href=&quot;https://username.github.io&quot;&gt;Live demo&lt;/a&gt;<br>&lt;/article&gt;</pre><p><strong>Portfolio mindset</strong></p><p><strong>Good HTML is not fancy. Good HTML is clear.</strong></p><p>CSS turns a plain document into a designed interface. For a portfolio, CSS controls the first impression: spacing, rhythm, readability, responsive layout, dark mode, and the feeling that the page was built with care.</p><h3>Core Ideas</h3><ul><li>Selectors choose what to style: body, .hero, #contact, or .project-card h3.</li><li>The box model explains spacing: content, padding, border, and margin.</li><li>Flexbox is excellent for rows, navigation, buttons, and small groups.</li><li>Grid is excellent for project cards, skill groups, and page layouts.</li></ul><h3>Portfolio Styling</h3><ul><li>Use a small color system with variables so dark and light mode are easy.</li><li>Use consistent spacing values instead of random margins everywhere.</li><li>Set readable line height and avoid giant paragraphs stretching across the screen.</li><li>Make cards, buttons, and links visually consistent.</li></ul><h3>Responsive Habits</h3><ul><li>Start with a layout that works on mobile.</li><li>Use max-width so content does not become too wide on desktop.</li><li>Use grid-template-columns: repeat(auto-fit, minmax(...)) for flexible cards.</li><li>Test at small phone width, tablet width, and desktop width.</li></ul><p><strong>Clean base styles</strong></p><pre>:root {<br>  --bg: #0f172a;<br>  --surface: #111827;<br>  --text: #f8fafc;<br>  --muted: #94a3b8;<br>  --accent: #38bdf8;<br>  --line: rgba(148, 163, 184, 0.24);<br>}<br><br>* {<br>  box-sizing: border-box;<br>}<br><br>body {<br>  margin: 0;<br>  font-family: Inter, Arial, sans-serif;<br>  background: var(--bg);<br>  color: var(--text);<br>  line-height: 1.6;<br>}</pre><p><strong>Hero and project grid</strong></p><pre>.container {<br>  width: min(1120px, calc(100% - 32px));<br>  margin: 0 auto;<br>}<br><br>.hero {<br>  min-height: 80vh;<br>  display: grid;<br>  align-content: center;<br>  gap: 20px;<br>}<br><br>.project-grid {<br>  display: grid;<br>  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));<br>  gap: 16px;<br>}<br><br>.project-card {<br>  padding: 20px;<br>  border: 1px solid var(--line);<br>  border-radius: 8px;<br>  background: var(--surface);<br>}</pre><p><strong>Light mode</strong></p><pre>body.light {<br>  --bg: #f8fafc;<br>  --surface: #ffffff;<br>  --text: #0f172a;<br>  --muted: #475569;<br>  --accent: #0369a1;<br>  --line: rgba(15, 23, 42, 0.16);<br>}</pre><p><strong>Portfolio mindset</strong></p><p><strong>CSS is not decoration only. It is how you make information easy to scan.</strong></p><p>JavaScript should make your portfolio feel alive without making it confusing. Start with small useful interactions: theme switch, language switch, active navigation, copy email, and form feedback.</p><h3>Core Concepts</h3><ul><li>Variables store values: const themeButton = ....</li><li>Functions package behavior so you can reuse it.</li><li>Events run code when something happens, like a click.</li><li>classList lets JavaScript add or remove CSS classes.</li><li>localStorage saves small preferences like dark or light mode.</li></ul><h3>Portfolio Interactions</h3><ul><li>Light/dark mode: toggle a class on body and remember the preference.</li><li>Language switch: update visible text from a dictionary.</li><li>Copy email: copy your email address to the clipboard.</li><li>Project filter: show only iOS, web, or all projects.</li></ul><h3>Good Habits</h3><ul><li>Select elements once near the top of the file.</li><li>Use clear names like themeButton, languageButtons, and projectCards.</li><li>Check that an element exists before using it if the script may run on multiple pages.</li><li>Keep JavaScript focused. Do not use it to create simple static text that belongs in HTML.</li></ul><p><strong>Theme switch with saved preference</strong></p><pre>const themeButton = document.querySelector(&quot;#themeButton&quot;);<br>const savedTheme = localStorage.getItem(&quot;theme&quot;);<br><br>if (savedTheme === &quot;light&quot;) {<br>  document.body.classList.add(&quot;light&quot;);<br>}<br><br>themeButton.addEventListener(&quot;click&quot;, () =&gt; {<br>  document.body.classList.toggle(&quot;light&quot;);<br>  const nextTheme = document.body.classList.contains(&quot;light&quot;) ? &quot;light&quot; : &quot;dark&quot;;<br>  localStorage.setItem(&quot;theme&quot;, nextTheme);<br>});</pre><p><strong>Copy email button</strong></p><pre>const copyEmailButton = document.querySelector(&quot;#copyEmail&quot;);<br><br>copyEmailButton.addEventListener(&quot;click&quot;, async () =&gt; {<br>  await navigator.clipboard.writeText(&quot;you@example.com&quot;);<br>  copyEmailButton.textContent = &quot;Copied&quot;;<br><br>  setTimeout(() =&gt; {<br>    copyEmailButton.textContent = &quot;Copy email&quot;;<br>  }, 1600);<br>});</pre><p><strong>Portfolio mindset</strong></p><p><strong>Use JavaScript to support the user, not to show off.</strong></p><p>A clean project is easier to understand, debug, and improve. Separate your HTML, CSS, JavaScript, and images so every file has a clear job.</p><h3>Folder Structure</h3><ul><li>index.html is the main page.</li><li>css/styles.css stores visual styles.</li><li>js/script.js stores behavior.</li><li>img/ stores photos, screenshots, icons, and project previews.</li><li>README.md explains the project goal and how to run it.</li></ul><h3>Senior Habits For Beginners</h3><ul><li>Use meaningful section names and class names.</li><li>Write small CSS systems: variables, containers, sections, buttons, cards.</li><li>Keep repeated UI consistent.</li><li>Make the website work without JavaScript first, then add enhancements.</li><li>Commit after meaningful steps so your progress is safe.</li></ul><h3>What Version 1 Should Include</h3><ul><li>Hero with your name and role.</li><li>About or bio section.</li><li>Projects section with at least one project.</li><li>Skills and education.</li><li>Contact links.</li><li>Light/dark mode and language switch if you want extra practice.</li></ul><p><strong>Recommended structure</strong></p><pre>portfolio-website/<br>  index.html<br>  README.md<br>  css/<br>    styles.css<br>  js/<br>    script.js<br>  img/<br>    profile.jpg<br>    project-portfolio.png</pre><p><strong>Connect files</strong></p><pre>&lt;head&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;css/styles.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;!-- page content --&gt;<br>  &lt;script src=&quot;js/script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;</pre><p><strong>Portfolio mindset</strong></p><p><strong>A small clean website teaches more than a big messy one.</strong></p><p>Deployment means making your website live on the internet. GitHub Pages is beginner-friendly because it can publish a static HTML, CSS, and JavaScript website directly from your repository.</p><h3>Before You Start</h3><ul><li>Create a GitHub account.</li><li>Install Git on your machine.</li><li>Create a folder for your portfolio.</li><li>Open Terminal in that folder.</li><li>Run pwd to confirm where you are before Git commands.</li></ul><h3>Important Commands</h3><ul><li>pwd shows the current folder.</li><li>ls lists files.</li><li>cd folder-name moves into a folder.</li><li>git status shows changed files and branch state.</li><li>git add . stages changes.</li><li>git commit -m &quot;message&quot; saves a checkpoint.</li><li>git push uploads commits to GitHub.</li></ul><h3>GitHub Pages Domain</h3><ul><li>For a personal site, name the repo username.github.io, replacing username with your GitHub username.</li><li>GitHub will publish it at <a href="https://username.github.io./">https://username.github.io.</a></li><li>If you use another repo name, the URL usually becomes <a href="https://username.github.io/repo-name/">https://username.github.io/repo-name/.</a></li></ul><p><strong>Create local project</strong></p><pre>mkdir portfolio-website<br>cd portfolio-website<br>touch index.html<br>mkdir css js img<br>touch css/styles.css js/script.js README.md</pre><p><strong>Start Git and make first commit</strong></p><pre>git init<br>git status<br>git add .<br>git commit -m &quot;Create portfolio website structure&quot;<br>git branch -M main</pre><p><strong>Connect to GitHub and push</strong></p><pre>git remote add origin https://github.com/username/username.github.io.git<br>git push -u origin main</pre><p><strong>Daily update flow</strong></p><pre>git status<br>git add .<br>git commit -m &quot;Improve hero section&quot;<br>git push</pre><p><strong>Portfolio mindset</strong></p><p><strong>At the end, your website should not only exist on your computer. It should be live and shareable.</strong></p><p>A portfolio should work for real people on real devices. Responsive design makes it usable on phones and desktops. Accessibility makes it usable for more people and creates better HTML habits.</p><h3>Responsive Checklist</h3><ul><li>Use the viewport meta tag.</li><li>Avoid fixed widths like width: 1200px for main content.</li><li>Use max-width and flexible grids.</li><li>Test navigation, cards, and buttons on narrow screens.</li><li>Make sure text does not overlap or become too small.</li></ul><h3>Accessibility Basics</h3><ul><li>Use one clear h1 for the page.</li><li>Keep heading order logical: h2 for sections, h3 for cards.</li><li>Write useful alt text for meaningful images.</li><li>Use buttons for actions and links for navigation.</li><li>Make color contrast readable in light and dark mode.</li></ul><h3>Portfolio Details</h3><ul><li>Project screenshots need descriptive alt text.</li><li>Contact links should clearly say where they go.</li><li>Buttons like theme switch and language switch should have understandable labels.</li><li>Keyboard users should be able to tab through the page.</li></ul><p><strong>Responsive grid</strong></p><pre>.skills-grid {<br>  display: grid;<br>  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));<br>  gap: 12px;<br>}</pre><p><strong>Accessible image and button</strong></p><pre>&lt;img src=&quot;img/project-app.png&quot; alt=&quot;Dashboard screen from my habit tracking app&quot;&gt;<br>&lt;button type=&quot;button&quot; id=&quot;themeButton&quot; aria-label=&quot;Switch color theme&quot;&gt;<br>  Theme<br>&lt;/button&gt;</pre><p><strong>Portfolio mindset</strong></p><p><strong>Responsive and accessible is not advanced polish. It is part of building a real website.</strong></p><p>A portfolio is not only a code exercise. It is also a communication tool. The page should help someone quickly understand who you are, what you can build, and why your work is worth exploring.</p><h3>Hero Copy</h3><ul><li>Say your name clearly.</li><li>Say what you do in one direct line.</li><li>Add one useful detail: platform, stack, niche, or type of product.</li><li>Give the visitor a clear next action like viewing projects or contacting you.</li></ul><h3>Project Cards</h3><ul><li>Use project names that are easy to understand.</li><li>Explain the problem, not only the technology.</li><li>List the stack, but do not let the stack replace the story.</li><li>Add links to live demo, GitHub, or screenshots when available.</li></ul><h3>Trust Signals</h3><ul><li>Add education, certificates, work experience, or learning progress honestly.</li><li>Keep links updated.</li><li>Remove empty sections until you have content.</li><li>Proofread the page. Small text mistakes can make a polished layout feel unfinished.</li></ul><p><strong>Before and after project description</strong></p><pre>Weak:<br>Website with HTML CSS JS.</pre><pre>Stronger:<br>A personal portfolio website with responsive layout, dark mode,<br>language switch, project cards, and GitHub Pages deployment.</pre><p><strong>Project card content</strong></p><pre>&lt;article class=&quot;project-card&quot;&gt;<br>  &lt;h3&gt;Portfolio Website&lt;/h3&gt;<br>  &lt;p&gt;A responsive personal site with theme switch and GitHub Pages deployment.&lt;/p&gt;<br>  &lt;ul&gt;<br>    &lt;li&gt;HTML&lt;/li&gt;<br>    &lt;li&gt;CSS Grid&lt;/li&gt;<br>    &lt;li&gt;JavaScript&lt;/li&gt;<br>  &lt;/ul&gt;<br>  &lt;a href=&quot;https://username.github.io&quot;&gt;Live demo&lt;/a&gt;<br>&lt;/article&gt;</pre><p><strong>Portfolio mindset</strong></p><p><strong>Your portfolio should show skill and explain the thinking behind the skill.</strong></p><p>Before you call the project finished, walk through the website like a visitor and like a developer. You want it to look good, work correctly, and be easy to update later.</p><h3>Content Checklist</h3><ul><li>Hero has your name, role, and clear action.</li><li>About section sounds human and specific.</li><li>Projects have descriptions, stack, and links.</li><li>Skills and education are easy to scan.</li><li>Contact links work.</li></ul><h3>Technical Checklist</h3><ul><li>HTML has correct structure.</li><li>CSS is organized with variables and reusable classes.</li><li>JavaScript has no console errors.</li><li>Dark/light mode works.</li><li>Language switch works if included.</li><li>Images load from the img folder.</li><li>The page works on mobile and desktop.</li></ul><h3>Shipping Checklist</h3><ul><li>Run git status before final commit.</li><li>Commit the finished version.</li><li>Push to GitHub.</li><li>Open your GitHub Pages URL.</li><li>Test the live website, not only the local file.</li><li>Add the live URL to your GitHub profile and LinkedIn.</li></ul><p><strong>Final terminal flow</strong></p><pre>git status<br>git add .<br>git commit -m &quot;Finish first portfolio website&quot;<br>git push</pre><p><strong>README starter</strong></p><pre># Portfolio Website</pre><pre>My personal portfolio website built with HTML, CSS, and JavaScript.</pre><pre>## Features<br>- Responsive layout<br>- Dark and light mode<br>- Project cards<br>- Contact links</pre><pre>## Live Website<br>https://username.github.io</pre><p><strong>Portfolio mindset</strong></p><p><strong>Finish version 1, share it, then improve it with real feedback.</strong></p><p>🛠️ Portfolio Builder “<a href="https://github.com/NikolaiBorisov/SolidFolio">SolidFolio</a>”:</p><p><a href="https://github.com/NikolaiBorisov/SolidFolio">https://github.com/NikolaiBorisov/SolidFolio</a></p><p>🧠 Portfolio Quiz:</p><p><a href="https://nikolaiborisov.github.io/#portfolio-website-quiz">https://nikolaiborisov.github.io/#portfolio-website-quiz</a></p><p>🐇 Complete Portfolio Guide:</p><p><a href="https://nikolaiborisov.github.io/#portfolio-website">https://nikolaiborisov.github.io/#portfolio-website</a></p><p>🪪 Real Working Portfolio with GitHub Pages and an .io Domain:</p><p><a href="https://nikolaiborisov.github.io/">https://nikolaiborisov.github.io/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e27e7a12336" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } — Personal tool stack]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-personal-tool-stack-492fc7bd2577?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/492fc7bd2577</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Wed, 25 Nov 2026 04:06:22 GMT</pubDate>
            <atom:updated>2026-11-25T04:06:22.610Z</atom:updated>
            <content:encoded><![CDATA[<p>A personal tool stack is the set of tools you use consistently to plan, design, build, debug, document, and ship. The goal is not to collect tools. The goal is to create a workflow you trust.</p><h3>Starter Stack</h3><ul><li>Xcode for building the app.</li><li>Simulator and real devices for testing.</li><li>Terminal for precise commands.</li><li>Git and GitHub for history, collaboration, and review.</li><li>Figma for designs.</li><li>Postman for API testing.</li><li>SF Symbols for native icons.</li><li>Notes, Notion, or README files for documentation.</li></ul><h3>When To Add More</h3><ul><li>Add Charles when network debugging becomes serious.</li><li>Add Git clients like SourceTree or Fork when you want visual history and diffs.</li><li>Add AI tools and agents when you can clearly describe tasks and review the output.</li></ul><h3>Tips &amp; Hacks</h3><ul><li>Start simple and become good with a small set of tools.</li><li>Remove tools you do not use. Too many tools can slow you down.</li><li>Write down your personal workflow so you can repeat it on every new project.</li></ul><p><strong>Tool mindset</strong></p><p><strong>The best tool stack is the one you actually use well.</strong></p><p><strong>How Tools Work Together</strong></p><p>Real iOS development is not one tool at a time. The tools connect into a flow: understand the task, inspect the design, create a branch, build the feature, test it, debug it, review it, document it, and ship it.</p><h3>Typical Flow</h3><ul><li>Read the task and Figma design so you know what to build.</li><li>Use Git to create a branch. A branch keeps your work separate from stable code.</li><li>Build in Xcode and run in Simulator while checking layout and app states.</li><li>Use Postman to understand API behavior and Charles when you need to inspect real app traffic.</li><li>Open a Pull Request on GitHub, review changes, fix feedback, and document what shipped.</li></ul><h3>Beginner Goal</h3><ul><li>Do not learn tools in isolation forever.</li><li>Use tools while building real screens and small apps.</li><li>After each task, explain which tool helped you solve which problem.</li><li>Your portfolio becomes stronger when you can explain both the code and the workflow.</li></ul><h3>Tips &amp; Hacks</h3><ul><li>For every feature, keep a tiny checklist: design checked, branch created, UI built, states tested, API checked, README updated.</li><li>When stuck, name the category of the problem first: design, code, API, Git, build, signing, or release.</li><li>A calm workflow beats random tool switching.</li></ul><p><strong>Tool mindset</strong></p><p><strong>Tools become powerful when they connect into a calm, repeatable development workflow.</strong></p><p>🧠 Quiz: <a href="https://nikolaiborisov.github.io/#ios-dev-toolbox-quiz">https://nikolaiborisov.github.io/#ios-dev-toolbox-quiz</a></p><p>🐇 <a href="https://nikolaiborisov.github.io/#ios-dev-toolbox">https://nikolaiborisov.github.io/#ios-dev-toolbox</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=492fc7bd2577" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ { Swift Code } —Debugging & Documentation, QA Checks, Release Checks]]></title>
            <link>https://medium.com/@andersonnikko1/swift-code-debugging-documentation-qa-checks-release-checks-c04ba8df9001?source=rss-b06505167c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/c04ba8df9001</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Anderson Niko]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 02:22:35 GMT</pubDate>
            <atom:updated>2026-11-24T02:22:35.505Z</atom:updated>
            <content:encoded><![CDATA[<p>Debugging is the process of finding the real cause of a problem, not just changing code until the symptom disappears. Documentation records how the project works so future you and teammates do not have to rediscover everything.</p><h3>Debugging Tools</h3><ul><li>Breakpoint: pauses code at a specific line so you can inspect values.</li><li>Console logs: printed messages that help you follow what happened.</li><li>LLDB: Xcode&#39;s debugger command system for inspecting and controlling a paused app.</li><li>Instruments: Apple’s performance tool for memory, time, leaks, and other profiling.</li></ul><h3>Debugging Process</h3><ul><li>Reproduce the bug with clear steps.</li><li>Find the smallest screen, input, or state that causes it.</li><li>Read the stack trace. It shows where the app crashed or failed.</li><li>Fix the cause, then test the original scenario again.</li></ul><h3>Documentation</h3><ul><li>README should explain what the app does, how to run it, and important setup steps.</li><li>Architecture notes explain why files are organized a certain way.</li><li>Comments should explain non-obvious decisions, not repeat what the code already says.</li></ul><p><strong>Tool mindset</strong></p><p><strong>Debugging finds the truth. Documentation preserves it.</strong></p><p>A release or QA checklist helps you avoid simple mistakes before you share a build, upload to TestFlight, or submit to the App Store. Beginners often think release is one button. In real projects, release is a repeatable process.</p><h3>QA Checks</h3><ul><li>Build and run on all supported device types.</li><li>Check onboarding, login, logout, main flows, forms, empty states, loading states, errors, and offline behavior.</li><li>Verify dark mode, light mode, accessibility labels, app icon, display name, and version/build numbers.</li></ul><h3>Release Checks</h3><ul><li>Archive successfully in Xcode. Archive means creating a release-ready build package.</li><li>Increase build number for uploaded builds so App Store Connect can distinguish them.</li><li>Prepare screenshots, metadata, privacy notes, release notes, and test account details if needed.</li></ul><h3>Tips &amp; Hacks</h3><ul><li>Keep a reusable release checklist in the repository.</li><li>Do not test only the happy path. Errors and empty states are where many beginner apps feel unfinished.</li><li>After fixing a release bug, retest the affected flow from the beginning.</li></ul><p><strong>Tool mindset</strong></p><p><strong>Shipping is a process. Checklists make that process repeatable.</strong></p><p>AI tools can explain errors, draft code, suggest refactors, write tests, summarize documentation, and help you explore unfamiliar APIs. Coding agents can work across multiple files when the task is clear.</p><h3>Good Uses</h3><ul><li>Ask AI to explain a compiler error in beginner language.</li><li>Ask for 2–3 implementation approaches before choosing one.</li><li>Generate README drafts, test cases, UI copy, or refactor suggestions.</li><li>Ask an agent to update related files when you already know the desired behavior.</li></ul><h3>Prompting Tips</h3><ul><li>Give context: what app, what screen, what error, what you tried.</li><li>Give constraints: SwiftUI or UIKit, minimum iOS version, no new dependencies, keep current style.</li><li>Ask for explanations, not just code, when you are learning.</li></ul><h3>Developer Responsibility</h3><ul><li>Review generated code carefully.</li><li>Do not paste secrets, private keys, customer data, or private company code unless the tool is approved for that data.</li><li>Run the app and tests. AI can be confident and still be wrong.</li></ul><p><strong>Tool mindset</strong></p><p><strong>AI is strongest when you give it context, constraints, and your own judgment.</strong></p><p>🐇 <a href="https://nikolaiborisov.github.io/#ios-dev-toolbox">https://nikolaiborisov.github.io/#ios-dev-toolbox</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c04ba8df9001" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>