Open minhnimble opened 11 months ago
Choosing between manually parsing JSON and using a third-party library depends on various factors. Here are some considerations:
Advantages of Manual Parsing: Customization: Manual parsing gives you fine-grained control over the parsing process. I can customize it based on specific needs, handling edge cases or special formatting. Control Over Performance: In some scenarios, manual parsing can be more performant, especially if I'm dealing with large or complex JSON structures. I can optimize parsing based on my application's specific requirements. Dependency Management: Manually parsing JSON reduces the number of dependencies in my project. If I'm aiming to keep my project lightweight and minimize external dependencies, manual parsing may be a suitable choice.
Advantages of Using a JSON Parsing Library: Convenience and Productivity Error Handling Maintainability Community Support
For most projects, especially those with straightforward JSON structures, using Codable or a similar library is recommended. It strikes a good balance between simplicity and power. If your project has specific requirements that cannot be easily addressed by Codable or if you have performance considerations, manual parsing might be a suitable choice.
Ultimately, the decision should be based on the specific needs and goals of your project.
Pull Request for this task -> https://github.com/akazadd/NimbleTechTest/pull/32
FYI, just In case you don't know what JSON API format is and why we recommend using it, please feel free to take a look at this for more information.
It is noticeable that you apply the MVVM architecture in your code. At the same time, I do have a few small concerns on the following parts that I would like to hear more from you:
I noticed that you handle some logic code directly in the ViewController instead of just UI parts. For example the logic to check if the mail is valid or not and the login API's success or failure logic in the
LoginViewController
directly. I am not sure why do you mix logic part in the ViewController layer instead of putting them into ViewModel layer? If you have to fix this code, how would you do it? https://github.com/akazadd/NimbleTechTest/blob/e6c67511d586c9707b45295fd5591ffb1b57a474/NimbleTechTest/Login/LoginViewController.swift#L49-L69You are using the native Apple framework for handling networking instead of any 3rd party library. I am curious if you have any experience with any popular library out there. And why do you think using the native Apple framework is a better choice for the application?
For the data layer, I noticed that you use Codable and parse JSON API formatted responses manually instead of using a 3rd-party library to handle this task. Why do you think parsing manually like this would be a better choice? And do you think using a JSON API parser library would add more benefits? https://github.com/akazadd/NimbleTechTest/blob/e6c67511d586c9707b45295fd5591ffb1b57a474/NimbleTechTest/Login/TokenResponseModel.swift#L10-L34