cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Best Practice for using an enumerated type.

jasong
1-Newbie

Best Practice for using an enumerated type.

I'd like to make a Cellular Modem ThingShape that has a property that determines whether the Thing is CDMA modem, or a GPRS modem,
1xRtt , EDGE, or LTE, etc.
Coming from my world in C#, I use enumerations all of the time, so I'd make a ModemType enumeration, with all possibile values.  How do I define this in this system?  Do I simply use an integer property and enforce the value in software?

I was thinking Tags, but that seems like more of a hack than a real solution, because you would still have to enforce the Tag's existence or validity in software somewhere.

Thoughts and ideas?

Jason

3 REPLIES 3
ryanm1
1-Newbie
(To:jasong)

There's at least two ways you could store this information, and you hit both of them. You can store it as a property on the ThingShape. The value can be defaulted and it would be OK to store the STRING value instead of a integer (to translate later) as 'CDMA', 'GPRS', etc. 

Tags are also a valid option. I don't know if your devices can have multiple modem types today - or in the future (e.g. CDMA and LTE). If so, tagging would be beneficially for this case.

Hi Jason Geiger​,

What approach did you finally choose?

Regards

Arunkumar D

Wow this I an old one.

Ultimately we went with just using String properties with lots of validation and a security model that prevents direct writing of the properties so we could enforce correct values. It's not great, I still don't understand why we can't get definable enum type, system enforceable, but, that's just my opinion.

Top Tags