When I'm new to studying, I think I've written all the processing in the view controller.
The view controller created in such a way is ** FatViewController **,
It is called a fat view controller.
The higher the FatViewController, the less readable and maintainable it becomes.
To prevent this, there is a design concept called ** architecture **.
View related processing here, business logic here, etc.
This is a rule that does not reduce the code quality.
It's difficult to follow this from the beginning, so let's first isolate the API communication.
First of all, the processing around communication -Function that throws API (returns response with closure) Throw a request and return the response in closure. -Structure (Codable) for mapping the response The part that conforms to Codable and codes according to the returned Json data -Process API response Processing that actually uses data I will divide it into three parts.
If you can do this first You can take one step on the road to becoming a beginner.
Finally, if you can code according to the architecture called MVVM I'm completely new to the game, but it's difficult from the beginning At the very least, please be aware that you should write separately even around communication.
Recommended Posts