Java Reference
In-Depth Information
Abstraction is a concept that is familiar to us all from object-oriented programming. The dif-
ference is that object-oriented programming is mostly about abstracting over data, while
functional programming is mostly about abstracting over behavior. The real world has both
of these things, and so do our programs, so we can and should learn from both influences.
There are other benefits to this new abstraction as well. For many of us who aren't writing
performance-critical code all the time, these are more important wins. You can write easier-
to-read code—code that spends time expressing the intent of its business logic rather than the
mechanics of how it's achieved. Easier-to-read code is also easier to maintain, more reliable,
and less error-prone.
You don't need to deal with the verbosity and readbility issues surrounding anonymous inner
classes when writing callbacks and event handlers. This approach allows programmers to
work on event processing systems more easily. Being able to pass functions around easily
also makes it easier to write lazy code that initializes values only when necessary.
In addition, the language changes that enable the additional collection methods, default
methods, can be used by everyday programmers who are maintaining their own libraries.
It's not your grandfather's Java any longer, and that's a good thing.
What Is Functional Programming?
Functional programming is a term that means different things to different people. At the
heart of functional programming is thinking about your problem domain in terms of immut-
able values and functions that translate between them.
The communities that have developed around different programming languages each tend to
think that the set of features that have been incorporated into their language are the key ones.
At this stage, it's a bit too early to tell how Java programmers will define functional pro-
gramming. In a sense, it's unimportant; what we really care about is writing good code rather
than functional code.
In this topic, I focus on pragmatic functional programming, including techniques that can be
used and understood by most developers and that help them write programs that are easier to
read and maintain.
Search WWH ::




Custom Search