문제

I have a simple SDI app which works pretty well.

Lately I decided to make use some of functions, exported by a DLL.

All those DLL functions work with a static memory buffer (which the app must define and use in the function calls) .

Fact is, some DLL functions should be called when specific things happen in the View.

I am not sure how I should handle calling of the DLL functions. Should the MainFrame, the Document and the View all have access to them (and hence to the memory buffer) ? Or should they message the app to make the function calls instead ?

도움이 되었습니까?

해결책

Define "correct" :)

First of all, I think you will be better off if you wrap all the calls to the DLL and put them in one place. Then it doesn't really matter which one calls the DLL (interface wise that is). However, it's good practice to let only one part of the system know about the DLL and use that interface. In this case it depends on what the DLL is actually doing, i.e. what kind of abstraction layer it aims to work on. If it's data related to the Document, it's the Document that should take care of the communication. It could even be used by the View, if the DLL is doing View-related stuff. If the DLL is doing application related stuff it should belong to the app.

Just ask yourself the question what the DLL is doing, i.e. what kind of role it has in your design and let that decide.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top