Naming is the most important part of design. Concise yet meaningful names are hugely important.
One of my favorite tips is to shortcut ‘rename in file’ in Eclipse as Ctrl-~.
For parameters or variables, however, I prefer either math names or meaningful names — customer, name, customerName, id, value, val, x, str, text, obj.
I never ever use ‘foo’. Is foo a name, an ID, a value, an object? “Foo” is no shorter, but is definitely less informative.
When “foo” is used, I sometimes get the impression that the fact that it’s meaningless is almost a conceit. This seems to me like an anti-pattern in naming & communication.
Blocking methods in Java often declare they may throw InterruptedException. How should we handle it?
In this article, Brian Goetz explains why rethrowing it is usually the most correct approach.
Documentation is important. All of us have experienced the challenge of finding the documentation we need, and most of us have struggled to try and write well. But it need not be so difficult.
Following is an easy approach plus a few guidelines that will help to produce & maintain real, usable, documentation easily.
Eclipse recently has suffered increasing numbers of questionable autocompletions — sometimes auto-wrongly replacing perfectly good code typed by the developer.
While there might be a few underlying issues, I found replacing “map.put()” with “map.compute()” particularly annoying and went to investigate. Here’s the solution.
Just today, I found the “amusing” fact that Tomcat server developers have taken it upon themselves to delete support for the HTTP Status Reason.
Think “200 OK” or “404 Not Found”. Even for applications sending a reason & clients expecting it, Tomcat is coded to explicitly drop the value — sending just a bald 200 or 404.
Unsurprisingly for those with the slightest knowledge of protocol compatibility, this is now breaking clients in the wild.
When processing SQL data in Spark, sometimes single rows are not the right unit — your calculation may need a collection or group of records as input.
This post shows how to group SQL data for use in Spark. Continue reading
Today I got a very unusual error while trying to debug the DeepLearning4J framework.
Conditional breakpoint encountered runtime exception. Reason: java.lang.InternalError: Got MethodID of ReferenceType that is not a member of the ReferenceType occured retrieving stack frames.
Continuing last month’s theme of searching Git history — here we look at how to find the source of changes, even after other people have worked on (or reformatted) the area in question.
The question: which commit actually introduced a given string into the file? Continue reading
Great post on inheritance from the Sicpers blog, and why — as a concept — it often fails in OO languages such as Java.
This blog post can help you understand why:
- “Cat and Dog extend Animal” is poor use of OO.
- “Square extends Rectangle” is poor use of OO.
From my own experience, I’ve moved to primarily using inheritance in only two ways: Continue reading
Working on many separate enhancements.. How to find which branch my changes to a particular file are on? And if a file was deleted, how can I find that?
Luckily, Git can help us! Continue reading