At work, we use dependency injection to build up small, decoupled classes each with a single responsibility. DI lets us assemble these in multiple different ways, so we can use the same class for similar processes. This strategy of combining small pieces of functionality in different ways is also a goal of functional programming. Let’s … Read moreDependency Injection vs Functional
And there was pain… I imported an existing Android project into IntelliJ Idea Community Edition 10.5.1. Some things started complaining “Please select Android SDK.” The help pages are out of date; they say to do this in the Android facet settings. It isn’t there. Here is the secret do-things-right button: Module settings (ctrl-alt-shift-S), then pick … Read moreSetting up an Android project in IntelliJ Idea
Guava’s CacheBuilder provides several options for keeping a cache down to a reasonable size. Entries can expire for multiple reasons, entries can be limited to a certain number, and entries can be made available for garbage collection. These options can be used individually or together. Each is simply one more method call during cache creation. … Read moreKeeping Your Cache Down to Size
Google has released a new version of Guava, and it’s bad news for one of my favorite classes, MapMaker. The exciting feature of MapMaker is its ability to produce an insta-cache, a key-value mapping that calculates values on the fly, expires them, and limits the quantity stored — all while maintaining thread safety. In release … Read moreGoodbye, MapMaker. Hello, CacheBuilder.
Remember the early days of XML, when people were all excited about using it to wire up applications? “You can change which implementation is used without changing any code!” Sure, right, XML isn’t code. It gets packaged in your jar files, with the code. It controls how your application works, like the code. It breaks … Read moreSpring configuration returns home
Google’s guava library provides a few constructs that let us use functional style in Java. Personally, I enjoy the slightly more declarative style that results, and have a new game of eliminating loops. Unfortunately, it’s Java. Attempting to do anything functionally is rather ugly. What do you think – worth it? or unreadable? Before: public … Read moreGuava: pidgin functional programming in Java