Steven Deobald

Read more by Steven on Medium

The C# expatriate: Tips for settling in Java.

Friday signaled the end of my first Java project in 6 years. Coming from a C#/.NET background, the learning curve was not steep – but by the end of the project I had learned enough small lessons to serve as the basis for this little document.

If you happen to move from a .NET project to a Java project, have a look through these pointers. This is all the advice I wish I had when I started this project six months ago.

1. Learn all your new tools, inside and out.


As a C# developer, you’re already utterly dependent on ReSharper. You will undoubtedly feel at home in IntelliJ. The majority of your day-to-day keyboard shortcuts will remain the same. Those that map directly map closely (CTRL+- is replaced with CTRL+ALT+LEFTARROW).

However, ReSharper is a plug-in which makes .NET development tolerable. IntelliJ is a work of art – and it makes programming a joy. Install the Key Promoter plug-in and never look back.

2. Find New Tools

As far as I know, nothing like Panopticode exists for C#. Guice almost certainly doesn’t. Explore the landscape and enjoy the rich open source bibliotheque that we’re missing on Microsoft-funded frameworks.

3. Testing and Mocking

Use JUnit 4. Use Mockito. Try jBehave.

4. Collections

Eagerly write custom collections and provide yourself with methods for collecting, filtering, and all that other fun stuff. You can augment this with Hamcrest Collections, but keep in mind it’s still v0.1.

5. Other Wrappers

Be even more aggressive about wrapping standard APIs than you would be in .NET. Why? Like collections, the .NET base class libraries have a (small) leg up on Java, thanks to watching Java grow and change. Because of this, you will periodically find features missing you might expect from the standard API. To be fair, once you’ve become accustomed to eagerly wrapping standard APIs in Java, carry that back to .NET with you. Chances are good you weren’t wrapping enough stuff when you were last writing .NET. (I know I certainly wasn’t.)

6. Dates and Times

The Java DateTime libraries are beyond useless; use JodaTime from day one. If anyone imports the JDK DateTime packages, fail the build. Joda comes with all the Hibernate jazz you need to persist Joda’s DateTimes, so you’re good there.

7. Apache Commons

Use it. It rocks. When you go back to .NET, steal ideas.