0

I have some enums in a concrete API/library that will be publicly used by application projects. My problem here, is that I cannot write an interface to these enums (that I know of). I should have thought of this before starting the project, but I did not. What really complicates this is that some of the methods accept/return the enums as arguments/parameters.

Question

Is there any way to keep my code loosely coupled, while still keeping the enums publicly facing the application?

Would it be acceptable to just put the enums into the interface library (as opposed to the concrete's/implementation's library)?

  • 1
    The enums are already part of the API. What exactly would you be abstracting with an interface? Nothing about the customer-facing API changes if you add a number to the enum. – Robert Harvey Jun 15 '16 at 15:11
  • @RobertHarvey Yes it would, I have an enum containing a bunch of relay-numbers that can be closed/opened. If I add another relay-number to the enum, then that's one more relay the customer can close/open. Do you see what I am asking now? – Snoop Jun 15 '16 at 15:14
  • @RobertHarvey And the thing is, I need to define the customer API objects through an interface because the implementation may change. As an electrical-engineer, in my particular case I am dealing with pieces of equipment – Snoop Jun 15 '16 at 15:16
  • @RobertHarvey But I do see what you are saying, in it's current state.... No, adding a number to the enum would not affect the customer API in any way whatsoever but only because enums cannot be abstracted to an interface (that I know of). – Snoop Jun 15 '16 at 15:20
  • How generic is your API? In my experience, API's that involve instrumentation usually require Key/Value pairs, because you cannot anticipate ahead of time what outputs a sensor or piece of equipment provides ahead of time. You can represent that kind of data with an arbitrary JSON or XML definition, but changing a DTO in C# is a breaking change, or at least one that requires programmer intervention. – Robert Harvey Jun 15 '16 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.