I'm writing a SDK for a NFC device in .NET so I don't have to import the SDK from C++. Right now I'm working on the ISO14443-3 part which is just simple Halt, Request, and Anticollision commands. The communication part between the device and computer is simple enough so I'm not going to post any of that. Just know that it is a serial device and that the command I send to it gets built before I write it to the SerialPort.
We have 2 different NFC devices with completly different SDK's. I plan on making them identical, but when I first started I was main concerned with only one of them and I was basing all my methods off of the SDK that came with the device. Note that this is not a debate about if I should use the SDK or not. When I first started I figured that I would only have 1 method with a simple structure. It looked like this. private void BuildAndSendCommand(MasterRDCommands command, params byte[] data)
MasterRDCommands is a simple enum. I decided that was a bad idea when I started work on the sound and light commands.. it was super hard to read something like
nfc.BuildAndSendCommand(MasterRDCommands.SetLED, RFIDLED.Blue, 0x01, 0x10);
it's like..HUH???
so I made the BuildAndSendCommands private and made methods to make the code more clear.. Now I have the method signature like this..
public void SetLED(RFIDLED led, byte flashes, byte duration)
that sure make it much nicer at the top most level, but the middle man I'm concerned if I should still use a enum. I feel that it would much more clean if I would just put a region at the bottom or top of my code with a few private constants so that things like the RATS command would switch from
public byte[] SendRATS_TypeA()
{
BuildAndSendCommand(MasterRDCommands.RATS);
byte[] RATS = GetResponse(10);
return RATS;
}
to say something like this
private const byte RATScmd = 0x1F;
public byte[] SendRATS_TypeA()
{
BuildAndSendCommand(RATScmd);
byte[] RATS = GetResponse(10);
return RATS;
}
it's not much different, but I don't plan on exposing any of the commands from my Enum to the user since most if not all of the commands require a certain order. Where as the LED example is a good example (to me atleast) of when to use a enum. The user has to choose a very narrow set of LED's.
in the end the user still only sees the few methods that I mark as public and would still never know if I ever deleted the Commands enum or not. What do you think? Keep them or remove them?