Skip to main content
Post Made Community Wiki by maple_shaft
Source Link
Maybe_Factor
  • 1.4k
  • 11
  • 12

why generate source code?

I've encountered two use cases for generated (at build time, and never checked in) code:

  1. Automatically generate boilerplate code such as getters/setters, toString, equals, and hashCode from a language built to specify such things (e.g. project lombok for Java)
  2. Automatically generate DTO type classes from some interface spec (REST, SOAP, whatever) to then be used in the main code. This is similar to your language bridge issue, but ends up being cleaner and simpler, with better type handling than trying to implement the same thing without generated classes.