Speed coding – Unit Testing the MVVM in Swift

https://www.youtube.com/watch?v=eKtWY0962Hg 🎯 Difficulty: Intermediate to Advanced In this speed coding session, we write unit tests for a Swift ViewModel built with the MVVM architecture and powered by Combine and @MainActor concurrency. You’ll see how to: ✅ Write precise and meaningful unit tests using XCTest 🔍 Test async @MainActor functions with Combine’s @Published properties 🧪 Mock … Continue reading Speed coding – Unit Testing the MVVM in Swift

SOLID : Single Responsibility Principle (SRP)

What is SRP? The Single Responsibility Principle (SRP) is one of the SOLID principles in software design. It states that a component should have only one reason to change. In other words, a class, struct, or any components, should have a single purpose and should not be modified for multiple reasons. Consider the following Swift struct: struct … Continue reading SOLID : Single Responsibility Principle (SRP)

Simplifying Logic with Swift: From if-else to switch Pattern Matching

When working with conditional logic in Swift, you often encounter scenarios that require checking multiple conditions. Traditionally, developers rely on if-else statements for such tasks. However, Swift’s powerful switch statement with pattern matching offers a cleaner and more elegant way to handle these situations. In this article, we’ll demonstrate how to transition from a verbose if-else structure to a concise switch statement using pattern matching, … Continue reading Simplifying Logic with Swift: From if-else to switch Pattern Matching

Compose Your UseCases to Create New Functionality using Composite Reuse Principle

On the previous article, we already learn about how to create a UseCase. In this article, we are going to learn how we can composes use case and create new one that has different functionality, using Composite Reuse Principle. Let's visit the previous article example. The previous example, we have a LoadTransactionsUseCase protocol to get a general picture … Continue reading Compose Your UseCases to Create New Functionality using Composite Reuse Principle

Get Rid of `nil` Values using Dictionary.compactMapValues { $0 }

What is compactMapValues { $0 } ? compactMapValues {} can be really helps when we are dealing with optional values inside a dictionary. Readability is also important, especially amongs the developers. compactMapValues is one of the great language feature of Swift. "Returns a new dictionary containing only the key-value pairs that have non-nil values as the … Continue reading Get Rid of `nil` Values using Dictionary.compactMapValues { $0 }