-
Notifications
You must be signed in to change notification settings - Fork 2
Role of code generation in OSHI 5 #4
Comments
Here is the experimental generator that I wrote. I worked on a YAML version briefly, but never finished. If we decide to go this route, then the definitions file can be JSON, XML, etc... |
I would love to employ code generation for at least a portion of the code. I'll refrain from specifying JavaPoet vs. any other alternative. This would work extremely well to synchronize configuration objects (update frequency, etc.) and data objects and the API interfaces, so that adding a new feature is as simple as adding a few lines to the markup file, and then pointing it to a "driver" or whatever other source we're identifying as the calculation code -- that part we'd write ourselves without a generator, I presume. |
Exactly. There are quite a few libraries out there, but JavaPoet seems like the best choice because it's actively developed and simple to use. |
I don't know if I'd use JavaPoet (or any other code generator) for most of the project, since even for something as simple as JavaPoet you're just trading POJO implementation costs with Poet implementation costs. However, for the APIs themselves? That might be a huge resource saver. |
I think we're on the same page here that we should generate the API stuff (interfaces, javadocs, POJO data objects and getters/setters, config files). We can consider generating junit tests. The actual platform implementation can have a standard "driver method" that is generated that we would then have to code up ourselves. |
About 5 months ago I wrote a small program with JavaPoet that generates the API according to a set of general definitions.
For example, the following YAML file defines a small
Nic
component:The program produced the API component and the interface for the driver (which I call the
Index
) along with proper JavaDoc on everything. I'm confident that JavaPoet can generate just about any kind of API we come up with, so the question is whether it's a good fit for the project.Advantages to generating the API
Disadvantages to generating the API
I'll update this post with any additional concerns.
The text was updated successfully, but these errors were encountered: