Java 8 Optionals for Null Objects

In my previous post, I mentioned about refactoring techniques including testing interface for null checks. I have recognized that there is an alternative for it while reading Java 8 in Action: Lambdas, streams, and functional-style programming. Optional Class If there is an object that might contain a null value, we can use Optional to wrap the […]

How to deal with nested conditionals (Part 2)

In my previous post, I mentioned about Decomposing Conditional and Consolidate Conditional Expression for nested conditionals. The problem was not only the nested conditions but also duplicated code fragments and lots of null object controls.  In this post, we will cover Consolidate Duplicate Conditional Fragments and Testing Interface to tackle the above mentioned problems. Consolidate Duplicate Conditional Fragments […]

How to deal with nested conditionals (Part 1)

In my current project, there are 1000s of lines of code (LOC), some of which date back to 10 years ago. An important part of my day-to-day job is try to understand and debug functions just like the following example (Listing 1). I omitted the boolean expressions and the code in branches but it is still […]