This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CatViewModel.swift | |
// | |
// Created by Daniyal Yousuf on 07/01/2023. | |
// | |
import Foundation | |
import Combine | |
struct CatsModel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
enum NetworkServiceErrors: Error { | |
case invalidURL | |
case decodingError(String) | |
case genericError(String) | |
case invalidResponseCode(Int) | |
var errorDescription: String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let count = 20 | |
class Logger { | |
var logDic = [String: Any]() | |
static var shared = Logger() | |
private init() {} | |
func writeToLog(key: String, value: String) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
final class SignupPresenter: SignupPresenterProtocol { | |
private var cancellable: Set<AnyCancellable> = Set<AnyCancellable>() | |
private var formModelValidator: SignupModelValidatorProtocol | |
private var signupWebService: SignupWebServiceProtocol | |
private weak var signupViewDelegate: SignupViewDelegateProtocol? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct SignupFormModel { | |
let firstName: String | |
let email: String | |
} | |
protocol ValidatorProtocol { | |
func validate(withName name: String) -> Bool | |
func validate(withEmail email: String) -> Bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol APIHandlerProtocol { | |
func fetchData(url: URL, | |
completion: @escaping(Result<Data, | |
DemoError>) -> Void) | |
} | |
protocol ResponseHandlerProtocol { | |
func parseData<T:Codable>(type: T.Type, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Birds { | |
var breed: String | |
init(breed: String) { | |
self.breed = breed | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol CakePaymentDelegate { | |
func payForCake(amount: Double) | |
} | |
class VelvetCakePayment: CakePaymentDelegate { | |
func payForCake(amount: Double) { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
///In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor. | |
/// | |
protocol TelevisionCompanyDelegate { | |
func manufactureTV() | |
} | |
final class Sony: TelevisionCompanyDelegate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
///Facade Class that hides implementation and provide interface to control implementation of all dependencies | |
/* | |
The facade pattern (also spelled façade) is a software-design pattern commonly used in object-oriented programming. Analogous to a facade in architecture, a facade is an object that serves as a front-facing interface masking more complex underlying or structural code. A facade can: | |
improve the readability and usability of a software library by masking interaction with more complex components behind a single (and often simplified) API | |
provide a context-specific interface to more generic functionality (complete with context-specific input validation) | |
serve as a launching point for a broader refactor of monolithic or tightly-coupled systems in favor of more loosely-coupled code | |
Developers often use the facade design pattern when a system is very complex or difficult to understand because the system has many interdependent classes or because its source code is unavailable. This |