Joseph Jung


How much code should we be striving to generate?

Redux would be impossibly annoying without IntelliJ snippets

“Boy, if I was a javascript engineer, I wouldn’t write code, I’d just write generators for code all day…”

said a devops guy… My job-preservation hackles rose - “This guy has no clue how hard it is to write FE code apparently!”, I thought-screamed. But then I took a step back and wondered, how much code COULD i be generating? This stuck in my mind for months afterwards…

So I decided to research just how much code could I generate instead of write?

Here’s what I came up with (and made!):

Code generation types: (according to me)

  1. Snippet generators
  2. Sub-project generators
  3. Full-project generators

Snippet generators

Snippet generators, which are found in almost every IDE, are ways to insert small chunks of code. Here are some that I use at work:

Snippets are EXTREMELY useful, especially if you learn how to make and utilize them quickly. They really speed up your development time.

Sub-project generators

The next category is sub-project generators, which is a step up from snippets in that they usually take large configurations and can generate standalone sections of code to be used in an existing project.

Example I found: — A JQuery form builder

There aren’t a lot of standalone “sub-project” generators because most are baked into the next category…

Full-project Generators

These take on the responsibility of generating an ENTIRE project for you. — which will actually generate an entire project, then give you component generators often, such as controllers for angular etc. — a cute way to convert a JSON object into a full native app.

These are GREAT for “getting started”… but anything else starts to feel inhibiting (like JSONette).

My attempt to generate code: A “sub-project Selenium generator”

After doing all this research, I came to the conclusion: Only attempt code generation if it’s very very repetitive or you need help getting started.

So in February, I was re-writing my Selenium code AGAIN after a bunch of new features landed on our startups dashboard. I realized that this stuff was repetitive… click on element, check it exists, blah blah…

I wrote a chrome extension tool called Snaptest which outputs a Selenium test folder. The folder is then added to your existing test configuration/setup, and can be maintained and run in the tool much more easily.

After doing this type of code generation, I saved hours and hours of time. So the one stupid phrase: “Boy, if I was a javascript engineer, I wouldn’t write code, I’d just write generators for code all day…” actually really helped!

More by Joseph Jung

Topics of interest

More Related Stories