Platforms as an array

Need help with your application? Ask here.
Post Reply
mike1977
Posts: 5
Joined: Tue Dec 11, 2018 6:15 am

Platforms as an array

Post by mike1977 » Tue Jan 15, 2019 8:17 am

Hi,

Is it possible to get the list of platforms as an array instead of object list ?

Something like this

Code: Select all

"platforms": [
      {
        "id": 1,
        "name": "PC",
        "alias": "pc",
        "icon": "pc-1336524756.png",
        "console": "1.png"
      },
      {
        "id": 2,
        "name": "Nintendo GameCube",
        "alias": "nintendo-gamecube",
        "icon": "nintendo-gamecube-1336524714.png",
        "console": "2.png"
      }...
Regards,
Mike

User avatar
Zer0xFF
Posts: 240
Joined: Fri Apr 20, 2018 9:18 am

Re: Platforms as an array

Post by Zer0xFF » Tue Jan 15, 2019 11:43 am

Hi Mike,

can you explain to me why you'd want that? and what difference would that make?

to explain my rationale for the choice, I believe it's easier to access the platform if you know it's id (which is the object key), and it wouldn't make much difference to anyone if they just wanted to iterate through them, and just ignore the key. however, now thinking about it, this might be used by some devs to avoid caching the list, which is what we recommend you do.
Regards
Zer0xFF

mike1977
Posts: 5
Joined: Tue Dec 11, 2018 6:15 am

Re: Platforms as an array

Post by mike1977 » Tue Jan 15, 2019 12:58 pm

The point is indeed to cache the platforms. If you search a game by his name, you get the platform Id so for every game, you have to send a request to get the platform name. So as long as I do not have a miss in the database, I don't need to refresh the list.

The library I use is able to generate a gson parser based on the pojo. But in this case, I will have to create one member variable for each platform. But the library is able to parser an array.

Beside that, you have to change your model every time you add a new platform

And last but not least, it will be aligned with the ByGameName method.
Last edited by mike1977 on Tue Jan 15, 2019 1:03 pm, edited 1 time in total.

User avatar
Zer0xFF
Posts: 240
Joined: Fri Apr 20, 2018 9:18 am

Re: Platforms as an array

Post by Zer0xFF » Tue Jan 15, 2019 7:23 pm

The point is indeed to cache the platforms. If you search a game by his name, you get the platform Id so for every game, you have to send a request to get the platform name. So as long as I do not have a miss in the database, I don't need to refresh the list.
you obviously shouldn't be caching the the results as is, loading them into some sort of database is the best option.
then you can query the database based on ID, or name without any issues at all.
The library I use is able to generate a gson parser based on the pojo. But in this case, I will have to create one member variable for each platform. But the library is able to parser an array.

Beside that, you have to change your model every time you add a new platform
I dont have much knowledge with pojo, but if im reading this correct, this could simply be solved, by parsing the data, loop through the objects, convert them to array, the do whatever you need to do with that.

now with all that said, I do kind feel it's somewhat pointless having it the way we currently have it, since my ideal approach would be, to cache into some sort of database before trying to use it, and the keys are only there to make it easier to use it, but if it's in a database those keys are absolutely redundant in this case. (I am however, feel under the weather, so ill avoid making any decisions now, but once i do, ill post an update here).

now as for the `ByGame*` endpoint, i think there might be the need for a much bigger discussion about it moving forward.
And last but not least, it will be aligned with the ByGameName method.
I presume you meant `ByPlatformName`, I have noticed the inconstancy, unfortunately that escaped me during launch.
Regards
Zer0xFF

mike1977
Posts: 5
Joined: Tue Dec 11, 2018 6:15 am

Re: Platforms as an array

Post by mike1977 » Tue Jan 15, 2019 7:32 pm

When I say caching, the point was loading the data into a database.

No no, I really meant ByGameName you got the games as a list not as an object containing objects.

And also having the key there is kinda useless as, correct me if I'm wrong, there is a request to get a platform by it's I'd.

And yes, I can parse the response, but you know, I'm a lazy dev...

Post Reply