Pergunta de entrevista da empresa NeoSOFT

She ask a variety of question on MVVM, Struct vs Class, Serialization and deserialization, URLSession vs URLSessionTask, FlatMap vs Compact Map, . TE-2 questions- protocol based question, how to make protocol optional, some coding questions like based on struct like filter an array of struct based on some values, project based question.

Respostas da entrevista

Sigiloso

29 de out. de 2024

MVVM, architecture having 3 components Model, view and View model, Model- handles all data related things, data is stored in model View- responsible for UI View Model- acts as a intermediary b/w model and view when we are interacting with View , then Model response to these change, update the model and viewModel listens to this changes nd then view is updated with the updated data, All logic related things and all code i.e different from Controller will be written in viewModel, Easy reusable,testable Struct vs Class- struct values types, immutable, does not support inheritance, struct gives default init but not having denit,m/m management is efficient,== equality operator to match the contents of all properties Class reference types, mutable,support inheritance, having init and deinit, m/m management is done using ARC, === operator to match the reference point for both instance FlatMap vs Compact Map- both are higher order functions used to transforms collection flatmap used to transform 2d array into single array or flatten the array of array into an array. Does not remove nil values Compact map- used to transform element of collection by applying the provided closure and by removing nil values.

Sigiloso

29 de out. de 2024

Serialization and deserialization are the process that we need to used wheneevr we have to switch between different data formats We are having Codable protocol i.e combination of encodable and decodable provides decoding and encoding data. Above mentioned serializing and deserializing are the two process that helps to serailize and deserialize data, We get data from the betwork in API in json format to read some data or to store it in file and to show it on UI we have to convert yhat JSON data into swift Object. for that we have to to deserializable means we need to use JSONDecoder to decode the JSON data back to swift Object, Whenever we need to send some data to the network for that we need to convert swift object or data structure into JSON format i.e serialization process where we need to use JSONEncoder to encode the swift object into JSON.