1

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?

  • Utilities should really be called Common or something similar, but that's where the enum belongs. – Robert Harvey Oct 18 '13 at 2:30
  • @RobertHarvey - Even though it's related to the data, and everything else in Utilties (so far) is entirely project independent? I guess by renaming it to Common it would seem less odd... – Bobson Oct 18 '13 at 13:18
  • Then make another library that is common to Data and put it there. You already know the answer to this; do what makes sense. – Robert Harvey Oct 18 '13 at 15:11
  • @RobertHarvey - Yeah, you're right. Still, good to get validation for it. Want to make that an answer and I'll accept? – Bobson Oct 18 '13 at 15:44
0

In general, you want to put code in libraries that are common to the other libraries in which they will be used, and name them accordingly. So in your case, since the enum is common only to the RemoteData and LocalData libraries, and specific to this particular project, I would make a new library called [ProjectName]Data and put it there.

  • Might end up being a small library, but it is what it is. Thanks. – Bobson Oct 18 '13 at 16:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.