开发者

An application design question

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜