я имею этот код:Refactor переключателя заявление с цикломатической сложностью верхнего чем 10
for notif in EnvironmentManager.notif {
if let type = notif.type {
switch type {
case .SitterAvailable:
self.manageNotif(notif, title: "Une sitter disponible", storyboardName: "searchGuard", vcName: "searchGuardNCSID")
case .OccasionalAdjustmentReminder:
self.manageNotif(notif, title: "Rappel", storyboardName: "searchGuard", vcName: "searchGuardNCSID")
case .GuardRequest:
self.manageNotif(notif, title: "Nouvelle garde urgente", storyboardName: "EmergencyGuardSitter", vcName: "EmergencyGuardSitterNavigationControllerSID")
case .NewReservationRequest:
self.manageNotif(notif, title: "Nouvelle garde", storyboardName: "GuardWebSitter", vcName: "WebGuardSitterNavigationControllerSID")
case .NewMessage:
self.manageNotif(notif, title: "Nouveau message", storyboardName: "MessageListSitter", vcName: "messageSitterViewNavigationControllerSID")
case .SoonReservationStartReminder:
self.manageNotif(notif, title: "Rappel", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .ReservationAccepted:
self.manageNotif(notif, title: "Garde acceptée", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .ReservationRefused:
self.manageNotif(notif, title: "Garde refusée", storyboardName: "GuardListSitter", vcName: "guardListSitterNavigationControllerSID")
case .NewMessageParent:
self.manageNotif(notif, title: "Nouveau Message", storyboardName: "MessageParent", vcName: "messageParentViewNavigationControllerSID")
}
}
}
я хочу знать, как оптимизировать, что для борьбы цикломатической сложности это, так без массива строки или что-то вроде что
в настоящее время сложность равна 11
спасибо за помощь
SOLID и шаблоны проектирования были бы друзьями. –