Tagged In java :
Pattern matching in Java with the Visitor pattern
I once read an essay—I cannot find it now—that talked about how learning a more advanced programming language can improve your coding even in a language that lacks those features because those language features are really ways of thinking, and there’s no reason you cannot think in terms of more powerful abstractions just because you… Read more
Configuration… Hardcode it!
If you’ve read other Wealthfront engineering blog posts (Continuous Deployment: API Compatibility Verification, Move cash faster, Pushing a Feature On My First Day), you’re aware that continous integration and deployment forms the core of our development process. Many consequences of a continuous integration and deployment process such as ours are obvious – high confidence test… Read more
Mocking Java enums with jMock is both trivial and impossible
I recently ran into a situation where I needed to test some code that used an enum to select between various strategies. As a toy example of this, we’ll use Accounts which have a list of investments and a Strategy which defines what investments are acceptable. View the code on Gist. Strategy is a Java… Read more
I can haz lambda on Java 7?
Superficially, lambda expressions in Java 8 are just syntactic sugar for instances anonymous inner classes. Syntactic sugar should not require classfile changes, so one might expect that code compiled with Java 8 lambdas could run on a Java 7 JRE. It turns out that you can’t do this, and not just because of an automatic… Read more
Beyond Java’s Access Control: the Visibility Test
It is generally a good practice to use the most restrictive access level that makes sense. However, Java’s access control is not always as expressive as one would want. In this blog post, I am going to give two examples where an access level must be artificially relaxed. Then, I’ll describe Wealthfront’s recently open sourced… Read more
When all else fails, check the documentation
I ran into a bug in my code today because I didn’t implement clone in a class that needed it (it’s used for rescheduling a failed task). Naturally, I went to fix the code to make these errors impossible through the magic of Type Safety, but Java wasn’t playing fair. It turns out this doesn’t… Read more