Good advice is worth its weight in gold when improving code
Can you tell an experienced developer from a beginner? I don’t mean that
as a put-down. Everyone starts somewhere, and we’re all still learning. You can spot an old hand
by looking at their code. Why the code, specifically?
Certain practices and habits make for better code, and there are two ways to pick them up. The first, somewhat
painful way is hands-on. You write enough code to realize
that the route you took was the wrong one. The second and much more interesting way is to learn
from technical articles and books. There’s nothing new in what I’ve just said,
but let me take the thought a little further.
A lot of advice is so general that without further explanation it loses
all its value. Some Java examples come to mind.
Use StringBuffer instead of concatenating strings,
honor method contracts such as equals and hashCode, write Javadoc for public APIs,
and use checked exceptions, among others. You may have heard all these tips,
but can you explain the reasons for following them?
One source of useful advice I’ve found is Joshua Bloch’s book
Effective Java Programming Language Guide,
published in Czech as JAVA efektivně, 57 zásad softwarového experta. The original impetus
for this post was advice from Robert Simmons Jr.’s book Hardcore Java,
which is highlighted in the article Seven Low-Cost Ways to Improve Legacy Code.
While we’re on books, is it just me, or do you also wish there were more reviews
of Java books?
Related articles
Related CZ Podcast episodes
- #261 · Leadership
On leading people and teams. · Czech audio
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio