Code generation for the masses

Martin Devillers

Android Developer


Knowingly or not, you already use code generators in every Android project. The most basic one, included by the Android compiler, creates the file referencing all of the application's resources. Chances are that you've also used libraries relying on annotation processors like ButterKnife or Dagger, which generate code during compilation as well. However, the inner workings of these tools can sometimes seem like dark magic. It turns out, writing your own code generator isn't that complicated.

In this talk, I'll go over the "Why" and the "How" of code generation. Looking at existing tools, I'll show what challenges led developers to start building code generators, and how they work. I'll try to give an overview of different tools & techniques to implement your own code generator, and in which cases certain methods should be preferred over others, depending on the scale and the type of task at hand. With a simple example, I'll build a sample code generator to put the theory in practice.

Developing mobile applications since 2014, in Paris and Chicago. Arrived at Dashlane in 2017. Passionate about software design.

droidcon EMEA is produced by:

Mobile Seasons GmbH (droidcon Global HQ)

Messedamm 22

14055, Berlin


.droidcon is a registered Trademark of Mobile Seasons GmbH

  • dc-social
  • Twitter - White Circle
  • Facebook - White Circle