A FactoryFactoryFactory in Production

5,324 reads

@ stevenheidel Steven Heidel I develop software and develop people. https://stevenheidel.com

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.

reactions

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?

reactions

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.

reactions

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

reactions

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.

reactions

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

reactions

class EventFactoryFactoryFactory

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

reactions

// 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?

reactions

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.

reactions

Share this story @ stevenheidel Steven Heidel Read my stories I develop software and develop people. https://stevenheidel.com

Tags