Java 8 Functional JDBC – Part 3

Wait One Minute…

Sometimes as I refactor code I look at my changes and think, wait one minute… as I was refactoring my ExtractorFactory, trying to reduce the boilerplate code,  I realized that I could slice away an entire layer of code.

I was working on the redundant exception handling code in the Extractors:

To solve that I introduced a ThrowingBiFunction based on this article:

And started replacing the BiFunctions I’d written:

In doing so it occurred to me … what the heck?! So I instead changed the interface on the ExtractorFactory to:

Then there was no need for predefined Extractors, instead using the factory code could simply read:

Much nicer. Look for the entire project on github.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s