Meta-framework / Constants file?

2019-04-15 22:58发布

I'm currently breaking down an application into several frameworks, three in total. I believe frameworks are the best solution for this as I can have several units of code independent of each other along with all accompanying code, such as unit tests, without "polluting" the main project.

Now, my problem is, I want to make these frameworks as independent as possible, but they all require certain constants to be made available to them - the same constants on all frameworks. Those constants will also need to be available on the main application. So, what is the best place to define those constants?

I could define them on a single framework, declare that the main framework and make all others depend on it. Or I could define them on a header file and make all constants and the main application depend on it.

What is your suggestion?

1条回答
Luminary・发光体
2楼-- · 2019-04-15 23:38

This question comes up in any package or library system, all the way back to Fortran in the '60s. The best solution is to have a base package/library that everything else depends on. Then make each separate framework only depend on that base, not on each other. Then make the application depend on all of the libraries, so you get a "diamond" dependency graph:

// application
// data rules presentation
// base

查看更多
登录 后发表回答