Tinkerforge/generators — pull request #37 by NobodysNightmare (2013-03-07 11:36:22+00:00)
Title: Discussion: Have an enum for Device Identifiers

Hi there,

this Pull Request is (at least initially) intended as a discussion point. I have no big feelings that you will eventually merge this.

What is it?
========

A small change, introducing an enum for the device identifiers:
````
public enum DeviceIdentifier
{
BrickletAmbientLight = 21,
BrickletAnalogIn = 219,
// ...SNIP...
BrickServo = 14,
BrickStepper = 15
}

````

This enum is used in the Enumerate-Callback instead of an integer. It should also be used in `GetIdentity`, however this involves more changes to the generators and I would only do this if you think its worth it.

Why?
====
[Thread 1](http://www.tinkerunity.org/forum/index.php/topic,55.msg8917.html#msg8917)
[Thread 2](http://www.tinkerunity.org/forum/index.php/topic,1450.msg9268.html#msg9268)

Second thread is for C, but it also shows the explorability issues associated with that. Having a DeviceIdentifier adds some benefits:
- more type safety (it's C#)
- better explorability
-- using an IDE you get auto-completion for DeviceIdentifiers
--using no IDE you have a clear hint where to look (DeviceIdentifier tells you there is a type you can look up, int tells you nothing)

Why only C#?
==========
In my opinion this should be included in all language-bindings that feature type-safety and where enums are usual. Best example is Java.
However for the discussion one example is enough.

Why not Merge?
============
I think you already realized why you might not want to merge that: Backwards-compatibility.
Merging this request would break current implementations of enumerate-callbacks.

I might have proposed this exact change [earlier](https://github.com/Tinkerforge/generators/issues/28), but back then I did not dive into the code deep enough.

What do you think of this proposal?