Skip to main content
added 30 characters in body
Source Link
tonyl7126
  • 297
  • 4
  • 14

What are a few ways constants and enums are dealt with when creating an API Client? I'm writing a client in python for our API and I've hit a sticking point with this. We use a lot of mappings to numbers (to save space) and I was wondering what the best technique is. I can hard code them into the client, but if a new enum/constant gets added, the consumer would have to update his version of the client. I also thought about grabbing the maps/enums when the client is first initialized and cached until there is an update. Are these typical approaches, or is there a more effective way to do this?

Edit: This is a REST API but I'm making a python client (so platform specific I suppose) for it to make it easier to work with. For a little more detail, when I say enums, I just mean using a constant (like an integer) to represent a certain choice a consumer has for a certain attribute. So lets say someone using the API is saving what type of video game system they have. 1 = xbox, 2 = playstation, 3= wii, etc... Do I hardcode those into the python client for the consumer to use? Do I grab them from the server when the client is initialized and then cache them client side?

What are a few ways constants and enums are dealt with when creating an API Client? I'm writing a client in python for our API and I've hit a sticking point with this. We use a lot of mappings to numbers (to save space) and I was wondering what the best technique is. I can hard code them into the client, but if a new enum/constant gets added, the consumer would have to update his version of the client. I also thought about grabbing the maps/enums when the client is first initialized and cached until there is an update. Are these typical approaches, or is there a more effective way to do this?

What are a few ways constants and enums are dealt with when creating an API Client? I'm writing a client in python for our API and I've hit a sticking point with this. We use a lot of mappings to numbers (to save space) and I was wondering what the best technique is. I can hard code them into the client, but if a new enum/constant gets added, the consumer would have to update his version of the client. I also thought about grabbing the maps/enums when the client is first initialized and cached until there is an update. Are these typical approaches, or is there a more effective way to do this?

Edit: This is a REST API but I'm making a python client (so platform specific I suppose) for it to make it easier to work with. For a little more detail, when I say enums, I just mean using a constant (like an integer) to represent a certain choice a consumer has for a certain attribute. So lets say someone using the API is saving what type of video game system they have. 1 = xbox, 2 = playstation, 3= wii, etc... Do I hardcode those into the python client for the consumer to use? Do I grab them from the server when the client is initialized and then cache them client side?

Source Link
tonyl7126
  • 297
  • 4
  • 14

constants/enums in API

What are a few ways constants and enums are dealt with when creating an API Client? I'm writing a client in python for our API and I've hit a sticking point with this. We use a lot of mappings to numbers (to save space) and I was wondering what the best technique is. I can hard code them into the client, but if a new enum/constant gets added, the consumer would have to update his version of the client. I also thought about grabbing the maps/enums when the client is first initialized and cached until there is an update. Are these typical approaches, or is there a more effective way to do this?