Proper library for enums

Posted by Bobson on Programmers See other posts from Programmers or by Bobson
Published on 2013-10-17T22:22:50Z Indexed on 2013/10/18 4:11 UTC
Read the original article Hit count: 211

I'm trying to refactor some code such that the display is separate from the implementation, and I'm not sure where to put the existing enums.

My project is currently structured as follows:

  • Utilities
  • RemoteData (Depends on: Utilities)
  • LocalData (Depends on: RemoteData, Utilities)
  • RemoteWeb (Depends on: RemoteData, Utilities)
  • LocalWeb (Depends on: RemoteData, LocalData, Utilities)

I'm now trying to add "ViewLibrary (Depends on: Utilities)" to this list, and then adding it as a new dependency to both RemoteWeb and LocalWeb. It will contain a set of interfaces which the other two projects will implement, use to populate the view, and then consume the result.

There's an enum which is currently used in all the projects except Utilities. It thus lives in the RemoteData project, because everything else depends on it. But this new ViewLibrary won't depend on either data project. So how will it know about this enum?

Some options I see:

  • Create a new project just for shared enum values.
  • Add it to Utilities, even though it is related to data.
  • Define it a second time in ViewLibrary, and require both RemoteWeb and LocalWeb to convert the one type into the other when they access the shared views.
  • Add a dependency on RemoteData to the ViewLibrary, even though it's supposed to be independent of data-source.

Are there any better options? Is this structure flawed to begin with?

© Programmers or respective owner

Related posts about refactoring

Related posts about object-oriented-design