import UIKit
// View
class LoginViewController: UIViewController {
var presenter: LoginPresenter!
@IBAction func loginButtonTapped() {
presenter.login(usernameTextField.text, passwordTextField.text)
}
func displayLoginResult(success: Bool) {
// Update UI
}
}
// Presenter
class LoginPresenter {
func login(_ username: String?, _ password: String?) {
// Logic to check credentials
// Update view based on result
}
}
import UIKit
// View
class LoginViewController: UIViewController {
var presenter: LoginPresenter!
@IBAction func loginButtonTapped() {
let result = presenter.validateCredentials(usernameTextField.text, passwordTextField.text)
// Handle basic UI logic here, like enabling/disabling buttons
displayLoginResult(result)
}
func displayLoginResult(_ result: Bool) {
// Update UI
}
}
// Presenter
class LoginPresenter {
func validateCredentials(_ username: String?, _ password: String?) -> Bool {
// Logic to check credentials
}
}
Q1:: 테스터블한 코드 작성을 지향하는가?
Q2:: 모델을 간단하게 처리하고 싶은가?
Q3:: 간단한 프레젠테이션 로직과 복잡한 프레젠테이션 로직을 구분하기 어려운가?