Code Generation Open House

Brad Wilson
Neighborhoods.com Engineering
3 min readJan 20, 2020

We recently threw our 2nd Neighborhoods.com Engineering Open House!

This is where we invite anyone from the engineering community or whomever is interested (everyone is always welcome) into our space and show off some technical products that we are going to open source.

It was a really great time and I was excited to not only see the number of people that were interested in code generation, but also to have the opportunity to talk to them about how they could leverage the pattern for their own use cases.

Last year we open sourced our distributed task manager, Kōjō. This year we were able to open source three more of our internal products, Buphalo, Prefab, and Bakery.

I’m exceptionally proud of all of our smart and talented engineers that built these tools and continue to make them better every day. If you weren’t able to make it, or if you are discovering Neighborhoods.com Engineering for the first time, here is the talk we gave.

I hope that you find it as cool and useful as we do.

Here are some quick introductions to these products from the technical product owners themselves.

Buphalo

Buphalo is an unopinionated Code Generation tool built in PHP. The idea behind Buphalo is to significantly reduce the overhead costs of using strong Objected Oriented Design Patterns with strict typing so that developers can focus on the business logic that actually matters. After defining the patterns you want to use as Templates, all Buphalo needs is a list of which templates it should use for each primary actor and it handles all the rest. With the added power of Annotation Processors, which allow you to define actor-specific context that can further customize your templates on the fly, you can do a whole lot of work with very little effort. See our README for more information.

Prefab

Prefab is a code generation library used by Neighborhoods engineers to build our HTTP services. It allows you to create highly performant, strictly typed APIs without the tedium of actually writing them. Just define a few characteristics about the shape of your responses and Prefab can give you a working endpoint in minutes. Prefab uses Buphalo under the hood, our generic code generation library developed in house.

For more information on how Prefab works, check out the README or take a look at the Prefab Fitness repository for examples of Prefab in action.

Kōjō

Kōjō is a distributed task manager that provides ways to run jobs on a static schedule or dynamically based on events. Kōjō makes it easy to take a single-threaded piece of code and execute it in a massively parallel fashion with guarantees that crashed jobs will be restarted and retried. This is very useful when using auto-scaling infrastructure where servers are constantly being added and removed.

Bakery

Bakery is a library that uses the PHP 7+ Opcache extension to compile source code and save the binary representation to disk. Bakery removes the overhead of compiling the PHP code at request time and enables new instances to take full advantage of the performance boosts as soon they begin serving traffic.

--

--