How to set default values in Swift compiler-generated initializers
Explains how to set default property values in Swift structs while retaining the compiler-generated initializer, using private(set) for immutability.
Gio Lodi is a software developer and author writing about Test-Driven Development, Swift, automation, and developer productivity. He is the author of Test-Driven Development in Swift with SwiftUI and Combine.
191 articles from this blog
Explains how to set default property values in Swift structs while retaining the compiler-generated initializer, using private(set) for immutability.
Applying the 'You Don't Need It Yet' (YDNIY) mindset to Test-Driven Development (TDD) to build software faster and more iteratively.
A tutorial on creating custom XCTest assertions in Swift to write clearer and more maintainable unit tests.
A tutorial on writing unit test assertions for Swift's Result enum, covering both Equatable and non-Equatable scenarios.
A software developer draws parallels between scientific experiments and software development, discussing how unexpected test results and failures can be valuable learning opportunities.
Explains why using descriptive titles for GitHub merge commits improves Git history readability and offers practical advice.
A guide to preventing SwiftUI apps from running their full startup flow during unit tests to avoid side effects and improve test performance.
Three methods to rename files directly within the Vim editor: using the vim-eunuch plugin, NERDTree, or a shell command.
A technical guide on using a terminal command to remove trailing whitespaces from all files in a directory, with context from an Xcode project.
Explains how to use Swift's nested types to create a clear, 1-to-1 relationship between a SwiftUI view and its ViewModel, improving code clarity and refactoring.
Explores two methods for implementing dependency injection in SwiftUI: using @EnvironmentObject and a View Model Factory.
Explores how a pipe wrench lecture by Vannevar Bush teaches the importance of precision in software engineering and domain modeling.
Explains the YDNIY (You Don't Need It Yet) principle for shipping software faster by delaying non-essential features.
Explores how unexpected software behavior, or 'That's funny...' moments, are key opportunities for learning and improving mental models of code.
Analyzes iOS 14's conflicting features: Sleep Mode/Wind Down aid productivity, while widgets pose new distraction risks.
Discusses replacing ambiguous three-state Booleans (true/false/null) with explicit enumerations in programming for clearer, safer code.
A guide to decoupling unit tests from frequently changing values, using Swift examples to separate logic from copy.
Learn how to properly credit co-authors in Git commits using the Co-authored-by trailer, supported by GitHub and GitLab.
A guide on using the Terminal command `spctl` to verify if a macOS application has been notarized by Apple.
A quick guide on using the 'tac' command in the terminal to reverse the order of lines in a file or standard input.