Traditional Culture Encyclopedia - Hotel franchise - I want to write a hotel management system program, because there are many modules, and I don't know how to connect them. If there are experts, please give me some advice. Thank you!

I want to write a hotel management system program, because there are many modules, and I don't know how to connect them. If there are experts, please give me some advice. Thank you!

C language is a tool of modular programming. How to organize modules and how to interact between modules should be a big problem. I think the following points are worth noting (please correct me):

1, each source file is an independent module, which should be compiled independently, without connecting any other modules or other source files.

2. Modules interact with each other through functions, constants, variables, structure definitions and macros (which seem to be a kind of constants).

3. Each module should include two parts: import and export. For example, to call another module's function foo (), you need to

externint foo();

This should belong to the import part of the module.

The function provided by the module should be declared as the export part of the module in the corresponding header file.

The export part of the module should be placed in the header file of the module.

4. If only the variables used in the module are defined as static in the module; Otherwise, it is a global variable, declared in the header file and also used as the export part of the module.

5. Macros can be defined in header files and source files. If the macro is only used in the module, it is equivalent to a local constant and can be placed in the source file; If other modules are used, put them in the header file.

I've thought about this problem, too So far, I haven't found any fixed standards to organize these files. Maybe it's just a habit of programmers, as long as you feel organized. However, if you want to develop a large-scale software, as a member of the development team, you should make your own organizational principles obey everyone's principles.