Singletons can be a source of tight coupling and testing difficulties.
Improvement:
Provide a way to inject dependencies or consider using protocols to allow for easier testing and decoupling.
protocol CrashHandling {
func setUpCrashHandler()
func processCrashReport()
var sendCrashReportToServer: (([String: String]) -> Void)? { get set }
}
class Crashlytic: CrashHandling {
// Implementation
}
Singletons can be a source of tight coupling and testing difficulties.
Improvement:
Provide a way to inject dependencies or consider using protocols to allow for easier testing and decoupling.