bin2cpp icon indicating copy to clipboard operation
bin2cpp copied to clipboard

Context redesign

Open end2endzone opened this issue 2 years ago • 0 comments

The application is storing all command line arguments to an ARGUMENTS structure. Then almost all field of this structure must be passed to IGenerator.

A Context should be created which contains all the configuration fields for generating code from an input file. The Context shall contains almost the same fields as the ARGUMENTS structure.

This would provide the following benefits:

  1. This Context shall be given to the IGenerator class for generating stuff. This would simplify the duplication of fields.
  2. The ARGUMENTS structure may sync with a Context which is filled in parallel.
  3. Creating "getters" directly in the Context class for each specified usage and generated fields. This would increase cohesion and reduce the coupling with the IGenerator interface. The generator interface would be more focused on generating code for a given context. The ARGUMENTS fields are mostly independent of the generator which is why an independent class would be preferable (instead of having all these fields in the BaseGenerator class).
  4. A Context shall be created for each files identified with the --dir option. The current implementation duplicated the ARGUMENTS structure which may be hard to understand or follow in the code.
  5. It would also simplify unit testing. For example with default values and values that are automatically calculated.
  6. Future changes will have a lower impact on the code. The changes will be targeted to the Context or the IGenerator interface. Not always both.

end2endzone avatar Oct 19 '21 23:10 end2endzone