Steven Heidel

@stevenheidel

A FactoryFactoryFactory in Production

After I graduated from college made a promise to myself: I would never take a job where I got paid to write Java code for a living. I had seen the light with the functional programming paradigm and languages like Haskell.

I started working at LinkedIn in 2014 when my primary development language was Scala. Scala is a fantastic language, but LinkedIn had trouble scaling it across the organization. Therefore I had to go back on my promise to myself and I started writing Java for a living. Surely it can’t be that bad, right?

Well, I’ll be the first to admit that Java 8 is a huge improvement over previous versions, and you can actually write some decent code with it. The problem is that Java’s shady past still shows up.

Take a look at this real class I had to work with:

class InboundRequestContextFinderProviderFactory

What does this even mean? Why does the context need to be found, provided, and factory-ed? The implementation of the class itself is 1 line of actual logic surrounded by 22 lines of boilerplate.

Or look at this other class I found (emphasizing again that this is real code currently running on production):

class EventFactoryFactoryFactory

Factory, Factory, Factory! Maybe the comments will provide me some more insight:

// Creates instances of EventFactoryFactory

Of course! I should have figured that out on my own. The question remains though, where is the code that actually does something?

PS. If you are stuck using Java like I was then at least you can get some of the benefits of functional programming:
See my other articles on Practical Functional Programming and the most common pieces of advice I gave while working with other Java developers.

More by Steven Heidel

Topics of interest

More Related Stories