开发者

Interface / Logic design technique in c

I have an interface which will allow external subsystems to use my system.

Do C programs usually use interfaces?

I have a core logic module which I want to use to handle the core of the system, this would mean that the interface would send the data to the core and the core will pass the data along possibly returning data too.

Is this a good way of doing things? It feels like there is an extra l开发者_高级运维ayer of data passing which is possibly not needed. On the other hand, I wouldnt want the interface to be directly connected to the lower system.

Is this extra layer of data handling a good thing or is it redundant?


Do C programs usually use interfaces?

  • Header files represent an interface

Is this a good way of doing things?

  • IMHO yes. In object orientation it is called Facade Pattern and hides the complexity of the underlying components. And provides a simpler API to the client.

Is this extra layer of data handling a good thing or is it redundant?

  • If things aren't trivial it is worth the effort to implement the extra layer.


It may make sense to copy data from external subsystems to your system. One situation I can think of is when the data is transient so must be copied while it is still available. It really depends on how your module will be used.

Once the data is in your system though, it doesn't make sense to copy it further. I wouldn't copy it from your "interface module" to your "core logic module", for example. Copying data will just slow the program down without any benefit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜