views:

45

answers:

2

Hello!

I'm developing a Windows Mobile 5.0 or above application with .Net Compact Framework 2.0 SP2 and C#.

I have to libraries: one to access SQL Server CE and the other with Custom Controls.

When I retrieve data from SQL Server I use structs to return them. These structs are defined on library one.

My problem is that these data is used with some Custom Controls on library 2. How can I fix?

  1. Referencing library1 on library2. I can do that but library1 is specific to this project and library2 can be used and must be used in another projects that don't use library1.
  2. Creating another library to store this structs?
  3. ??

What do you think?

+1  A: 

Let's simplify:

  • Library1 contains data structs
  • Library2 contains some controls that use some data structs in Library1

There are two options:

a) Extract an interface.

Some controls in Library2 use Library1 directly. You can modify those controls to use an interface and not the Library1 implementation of that interface. Put the interface in Library3. Now you have:

  • Library3 contains interface to data (no references)
  • Library2 contains some controls that use data that conforms to interface from Library3 (references Library3, does not know about Library1)
  • Library1 contains data structs that conforms to interface from Library3 (references Library3, does not know about Library2)
  • Application is the only component that holds references to all 3 libraries and provides controls from Library2 with data structs from Library1.

b) Extract common implementation

Some controls in Library2 use Library1 directly. You can extract those data structs from Library1 into Library3. Now you have a situation similar to above.

Goran
I will choose option b).
VansFannel
A: 

Can you pass the structs as object or a base class or interface that is defined outside of Library1? What do the user controls do with the objects?

My recommendation would be to abstract these objects to a common implementation and store that abstraction in Library2 or Library3, then reference it in Library1.

Kyle Trauberman