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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Best Practice for using an enumerated type.

jasong
12-Amethyst

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-Visitor
(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.

arunkumar1
12-Amethyst
(To:jasong)

Hi Jason Geiger​,

What approach did you finally choose?

Regards

Arunkumar D

jasong
12-Amethyst
(To:arunkumar1)

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.

Announcements


Top Tags