5 skills Java developers should learn in 2021

Yes, COVID-19 has slowed down the economy and the labor market, but that’s no reason to sit around and watch Netflix. 2021 may be the perfect year to change jobs and get a better salary or just be selected to participate in a great IT project. That’s why, as a Java developer, you absolutely must take advantage of this respite at home to learn the 5 ultimate skills that will set you apart from other coders.
2021-Java meme\
Keep pace with Java version 9, 10, 11… 16
Java is, at times, called a vintage language, but is still very much in use and the pace of the new releases has singularly increased thanks to OpenJDK and the innovations.
JDK is evolving too fast\
For instance, JDK 15 is now available (launched on 15 September 2020) and some companies are still dealing with Java 8.
Here is a list of features that you will need to master because they are already available in the new JDK :
- JDK 9: What’s new
- JEP 269: Convenience Factory Methods for Collections: Makes it easier to create instances of collections and maps with small numbers of elements. New static factory methods on the List, Set, and Map interfaces make it simpler to create immutable instances of those collections.
Set<String> alphabet = Set.of("a", "b", "c");
- JDK 10:
- Learn how to use properly the Optional object and how to avoid NullPointerExceptions.
- APIs for Creating Unmodifiable Collections: Favor immutability when you are manipulating the collections.
- JDK 11:
- JEP 321 HTTP Client (Standard): Learn the default HTTP Client API provided in the JDK
- Local-Variable Syntax: you can use var keyword rather than specifying your local variables with their types.
- Understand the basics of the modules and how to declare a module.
- JDK 13:
- JEP 354 Switch Expressions (Preview)
Example of switch expressions :
switch (experience) {
case 1 -> System.out.println("Débutant");
case 2 -> System.out.println("Junior");
case 3 -> System.out.println("Confirmé");
case 4 -> System.out.println("Sénior");
case 5 -> System.out.println("Expert");
}
Example 2 :
libelle = switch (experience) {
case 1, 2 : yield "Débutant et junior";
case 3, 4 : yield "Confirmé et sénior";
case 5 : yield "Expert";
default : throw new IllegalArgumentException("valeur experience invalide");
};
System.out.println(libelle);
- JEP 355 Text Blocks
/ Using a literal string
String dqName = "Pat Q. Smith";
// Using a text block
String tbName = """
Pat Q. Smith""";
- JDK 14:
- Accounting Currency Format Support: finally decent currency support!
- JEP 359 Records a new data structure
- Thread Suspend/Resume Are Deprecated for Removal
- JDK 15:
- Added isEmpty Default Method to CharSequence ( finally!)
- JEP 371 Hidden Classes (link)
- JDK 16 ( only in GA version ) :
- JEP 388 Vector API: to perform vector computation on the supported hardware architectures (link)
- JEP 394: Pattern matching for instanceof (link)
- JEP 395: Records: Improvements of the new data structure record.
As you can see in a few years, the Java Foundation has evolved the JDK a lot, so stay up to date and prepare for one release a year!
Become a master of the subtleties of the Java language
We wrote recently an article about the most common mistakes made by younger Java developers and how to avoid them.
I am
I am a Java developer\
Here are crucial skills to achieve in the Java language :
- Naming: learn how to name properly your identifiers
- Exception management: how to deal with exceptions, how to design a functional exception, and report an error
- Monolithic methods: Cut out your methods and improve their testability
- Poor OOP Practices: learn what is a code metric, coupling, and how to cut your code dependencies to make it more testable.
- Not Paying Much Attention To Readable Code: read again the Uncle bob best practices about comments, readability, SOLID principle, and complexity.
- Code cannot be tested ( and probably is not tested too): don’t use the basic features of JUnit 4. Learn JUnit 5 and mock libraries and the testing jargon ( stubs, fakes, dummies)
- Memory Leaks: know how to describe a Memory leak in case, common pitfalls and how to fix them
- Poor null expression management: don’t fall into the NullPointerException trap thanks to the latest API, annotations, and some best practices.
- Not closing resources: close your resources once for all using try..resources and learn how to create custom components with Autocloseable behavior.
Another important recommendation is to learn how to use static analyzers both in your local IDE or in your CI/CD (like Embold). The ability to understand and fix code quality issues will improve greatly your general Java skills and put you as a de facto tech lead among your colleagues.
Learning how to use a static analyzer to track your code defect is definitely a vital skill to become a rock star.\
Give a try to TDD
TDD is on all Java developer languages, in your Linkedin feed, on Hacker news. Here is the big trend for this year 2020. Even if the practice is not new, marketing and consulting companies (and startups must admit it) only talk about it.
Whether TDD brings a significant gain to the global code quality is not the subject. If you expect to be noticed by recruiters and receive qualified positions, you not only need to know the acronym, you also have to know how to use it.
TDD: what is it
Here are the steps to becoming a TDD master:
- know the JUnit framework and its latest version and developments
- know how to model a test
- make a code testable, in particular by abstracting its dependencies
- know how to verify the result of a test by knowing at least one assertion framework (assertJ)
- know how to create parameterized tests
- understand the notion of black/white box tests
- understand the notion of incremental design
- understand the notion of red/green tests.
- practice several Kata
The TDD methodology may seem overwhelming, but by following this plan and with online courses, you will acquire important skills that can be reused on all your projects and in all languages. The question of incremental design development is not necessarily the alpha and omega of quality code.
Here are a few interesting Kata websites :
- http://codekata.com/
- https://www.programmingwithwolfgang.com/tdd-kata/
- https://osherove.com/tdd-kata-1
Find your way around the microservices architecture with Spring Boot 2
Except for Java developers specialized in legacy or IBM environments (and the few banks that drag along with them), EJB and JSF technologies can be ignored in 2021.
The Spring framework is the standard today for many companies, regardless of whether it is used to write microservice architectures, monoliths, on-premise, or native Cloud applications.
Spring is a vast ecosystem covering a very wide range of needs and with an equally important history. Of its longevity, it is not easy to orient oneself on the bricks to be discovered.
Here are the modules that we recommend for becoming an experienced developer with Spring :
- Spring Boot (link)
- Spring Core and Spring DI (link)
- Spring Web (link)
- Spring Security (link)
- Spring Validation (link)
- Spring Hateoas (link)
- Spring Rest template (link)
- Spring Data (link)
- optionally Spring JDBC
- optionally Spring AOP
My recommendations for learning a Spring module are generally as follows:
- Follow the Spring tutorial (which really doesn’t take long)
- Quickly read (diagonally) Spring’s documentation
- Read the code of a GitHub project that contains the technology to see a typical use case
- Use it in a project
- Read the Spring documentation a little more carefully later.
Be polyglot
We are all inclined to confuse the Java language with the virtual machine. Nevertheless, for a long time now, the JVM has enabled other languages to be run.
We are referring to JRuby, Groovy, and Jython which are the first experiments with other languages that use the same virtual machine as Java.
This year, the Kotlin language deserves your attention. Founded by JetBrains, the usage of Kotlin has widely exploded beyond the IDE. Used by Android, Google, and numerous companies, it provides many advantages over Java at the cost of the performance and the capacity to precisely debug things.
This language has the potential to be very popular in the next few years and like Scala, a genuine Java programmer will be unable to disregard the programs that use this language.
The second reason behind our recommendation of becoming polyglot when using JVM is the amazing buzz of GraalVM, Quarkus.io, and Micronauts.
GraalVM is a Java VM and JDK based on HotSpot/OpenJDK, implemented in Java. It supports additional programming languages.
One of the project goals is “To allow freeform mixing of code from any programming language in a single program, billed as “polyglot applications”.[11][13]”
According to the Wikipedia page; the following technologies are already supported :
- GraalVM JavaScript:[29] ECMAScript 2019 compliant JavaScript runtime, with support for Node.js
- TruffleRuby:[30] Ruby language implementation with preliminary support for Ruby on Rails
- FastR:[31] R language implementation
- GraalVM Python:[32] Python 3 language implementation
- GraalVM LLVM Runtime (SuLong):[33] LLVM bitcode interpreter implementation
- GraalWasm:[34][35] A WebAssembly implementation
We anticipate GraalVM’s success due to the cost-savings that GraalVM provides with its very small memory footprint which makes this the perfect solution for native Cloud applications.
Conclusion
In that article, we presented our projections for the year 2021. We expect the Java ecosystem to be in a state of turmoil after many years of apathy and the combined effort of Oracle with GraalVM and the forced march of the Java foundation are making Java developments thrilling again.
To embrace these innovations, we are encouraging all Java developers to stay up to date with the new features and to reasonably arm themselves with tools such as code analyzers like Embold to manage the technical debt and thereby allow faster adoption of these changes