Sobes.tech
Middle — Middle+

What architectural model would you use when developing a new application from scratch?

sobes.tech AI

Answer from AI

For a new iOS application from scratch, I would choose the MVVM (Model-View-ViewModel) architecture. It well separates the presentation logic and business logic, making testing and maintaining the code easier. The ViewModel is responsible for preparing data for the View, and the Model handles data operations and business logic.

Example of a simple ViewModel in Swift:

class UserViewModel {
    private let userService: UserService
    var userName: String = ""

    init(userService: UserService) {
        self.userService = userService
    }

    func fetchUser() {
        userService.getUser { [weak self] user in
            self?.userName = user.name
        }
    }
}

This approach simplifies scaling and maintaining the application.

What architectural model would you use when… - sobes.tech