I have been reading about DTO (Data transfer object ) since few days. I understood concept that drives it. The concept is to make the domain object decoupled from external APIs or storage objects, by having datasource model. Certainly this will ensure a good separation of concern and make the program somewhat secure from the future change in the data model. But is that the only reason for using it? I see it adds a lot of extra code for something which may happen in future. Has anyone ever used DTOs in there iOS project and have it benefited them? Thanks in advance
Is DTO pattern in iOS really beneficial?
It depends on your app. If you have a complex app with different layers like services and repositories or DAOS implementing this pattern could be positive for you. You can hide your business logic and improve your memory usage not using data you don't need for example, you need to list users with his name, country, and telephone number, and your model classes are User { name : string, address: Address, telephone: Telephone} to list the information I. In the view, you don't need the address object with many parameters, only the country parameter. It is happening the same with the telephone object, you only need the number with no more parameters. The UserDTO was like this UserDTO{ name :String, country: String (Address.country), number:Strong(Telephone. number). With this code, you are hiding important data and saving computational costs.