Hi Michal, On Tue, 2019-06-18 at 09:35 +0200, Michał Lowas-Rzechonek wrote: > Hi Inga, > > On 06/17, Inga Stotland wrote: > > This adds #include for json-c/json.h in mesh-db.h and removes this > > include from the other files that don't need to reference json-c. > > While I agree about removal from cfgmod-server, model and node, I > don't > think we should remove the include from storage and move it to mesh- > db. > > I'd rather see #includes follow https://include-what-you-use.org/ > approach, that is: > > (...) for every symbol (type, function variable, or macro) that > you > use in foo.cc, either foo.cc or foo.h should #include a .h file > that > exports the declaration of that symbol. > > Moreover, I think headers should only be included as-needed (mostly > in > .c files), and headers should contain forward declarations of various > types, to make them opaque. > > Such an approach cuts implicit dependencies, making code maintenance > easier: when, for example, someone decides to refactor mesh-db not to > use json_object anymore, they shouldn't need to suddenly deal with > missing declarations in other modules (in this case, storage). > > Moreover, each header should be self-sufficient: in order to use API > exposed by a given header, it should be enough to include that header > only. At the moment, this is not the case. > > A minor side-effect would be faster builds and less rebuilds when > code > is being worked on. > > If you agree, I am more than happy to fix this throughout the mesh/ > codebase. > I don't disagree, this was sort of an "intermediate" patch. I'd prefer to remove the reference to json from storage.c and the rest of the code and localize it in only one file that would deal with json-related processing. So I might just as well go ahead and make mesh-db.h a generic API to allow for different storage formats (even though for now we have only json defined format). Best regards, Inga
Attachment:
smime.p7s
Description: S/MIME cryptographic signature