Hi CodeCrew!
After completing the 90-day fondation course, I’m currently working on a demo app and I’m using some API from themoviedatabase that has TONS of optional values.
Example : https://developers.themoviedb.org/3/tv/get-tv-details
I’m constructed a MVVM structure with some Models, a ModelView, and Views but I’m currently wondering where I should put all the “optional management”.
As an example, if I want to load an image from the website, I need three values :
(Those are not the real names, but you’ll get the idea.)
- base_url
- picture_size
3 picture_name
So if I want to load an image, I need to combine those three values, but each of those values could be nil.
Where should I check if those values are nil? I’ve thought of different options.
Option A) I check that everything is not nil every time I load an image in a View. That option seems redundant but maybe it’s how it should be done.
Option B) I create functions in the ModelView like getImage() that will do all the checking each time.
Option C) You need to verify all that in some way right after the api call so you don’t have to worry about nil stuff later?
Option D) Some great solution I didn’t think of.
So there ya go. I need your help and knowledge! Oh and if there’s a great course or module that explains it (maybe I just don’t remember), I’d appreciate to know which one.
Thanks a lot!