Eliminate Comments with Lambda Expressions

If you have been converting your code comments into code by creating small functions, I found an interesting alternative that uses lambda expressions. This starts with a post on a forum run by John Somnez. One reader made a comment that your functions should not be too short. John replied that short functions are desirable because you can avoid comments by using small functions. The name of the function essentially takes the place of the comment. I follow this coding practice but I thought that Continue reading →

Reduce Boiler Plate Code with Functional Interfaces

Java High Order Functions After writing an article about Java curried functions, I decided to try another approach. Instead of using lambda expressions defined as high order functions, use function interfaces that implement lambdas to reduce the boiler plate. If you look at the way high order functions are defined and passed in Java 8, it’s not pretty. The expressions contain a lot of text and angled brackets. You also need to understand curried functions and how to call them. That is not hard but Continue reading →

Java Curried Functions

When I coded a solution to Project Euler Problem 11, I used a Java BiFunction() to create a lambda expression with two parameters. I then needed a Java TriFunction() to pass three parameters. Java 8 did not have one. I had to get my article published so I left the code as is. This meant that the code that multiplied matrix cells was coded to multiply four cells. Here is an example of a BiFunction() with two parameters that can be converted to three inputs Continue reading →

Why Learn Scala?

With the difficulty of learning a new paradigm like functional programming, one might ask, why learn Scala, or any functional programming languages? After all, most experienced developers have been doing imperative programming with C, C++, and Java for years. Why learn a new way of programming that requires an enormous reworking of the thought process? Learning functional programming is a bit like learning a new language like Russian. At first it looks doable. There are training courses, videos on the web, and maybe even native Continue reading →