modio-sdk-legacy icon indicating copy to clipboard operation
modio-sdk-legacy copied to clipboard

C++ headers have unnecessary includes

Open SupSuper opened this issue 5 years ago • 2 comments

Currently all the #includes for the source code are in the header files, which avoids repetition, but pollutes any users of the SDK with unnecessary dependencies and system headers, since there's no way to access the library API without the headers. Clean headers make it easier to integrate with third-party code and avoid unnecessary conflicts.

  • Given how C++ works, it's better to keep includes as close to the source as possible and avoid them in the header files, even if it causes repetition, since library headers can be included anywhere and pull everything along with them.
  • The source files (.cpp) should carry most of the includes, as they're the ones calling functions. Header files (.h) only need to include other headers for types and defines they reference.
  • The include/ folder should only contain header files with the library's public API (functions and classes exported by the DLL), all the others should stay in the src/ folder. The ModioC.h is a good example, as it defines nothing but the public API.

Tools like https://include-what-you-use.org/ can help automate this process.

SupSuper avatar Aug 20 '19 06:08 SupSuper

Hi can fix this issue .please assign me

anishsingh935 avatar Mar 24 '21 04:03 anishsingh935

Hi,

Feel free do the changes =) Just to let you know, we won't maintain this repository for much longer as we have a version 2 of the SDK that's just about to go out of the door

MarkusRannare avatar Mar 24 '21 06:03 MarkusRannare