Code Only What You Need

Only commit to code that which needs to committed to code.  Only write what needs to be written.  How hard can that be?  You might be surprised, but there are developers out there that are so enamored with the code design that they implement entirely unnecessary things. The best of intentions is actually a waste when you implement something that is never actually used.

Continue reading

Posted in Coding, Design, practice | Tagged , , , , | Leave a comment

Error Message Video

Here is a video tutorial giving an overview of the error message problem. Continue reading

Posted in Coding, Design, Poor Error Msg | Tagged , , | Leave a comment

Numbered Error Messages Do Not Work

As part of a series of posts about error messages, this post covers a very specific claim: a single error message picked from a list of error messages is a bad idea and produces poor error reporting.  We start with the canonical example, and show how no single error message will be useful to the users.  It would be far too costly to maintain the full list of all possible problem combinations in a single list. Continue reading

Posted in Coding, Design, Poor Error Msg | Tagged , , , | Leave a comment

Code Copy Guidelines

This post presents some guideline reduce duplicates in the code. Whenever you notice that you’re writing blocks of code that are substantially similar, try to make a routine (method) that embodies that code and call it from all the places. This reduces the amount of code.  Furthermore, if there is a bug in the approach, or the approach needs to be changed, there is one place to change it, instead of many. Continue reading

Posted in Coding | Leave a comment

Variable Naming

Here are some coding guidelines about using meaningful names in the program. Most of them are taken from from Clean code book
Choosing good names takes time but saves more than it takes. Continue reading

Posted in Coding, Example Code | Tagged | Leave a comment

Canonical Execution Error Example

If we are going to talk about error messages, we need to flesh out a typical computation scenario within which an error occurs.  I use this example in other places to talk about possible error messages. Continue reading

Posted in Coding, Design, Example Code | Tagged , , , , | Leave a comment

Don’t Use java.util.Optional

This is a class that attempts to replace null with different way to check for null.  While I can imagine some very rare cases that this could be useful, in general it is more complicated, slower, and takes more memory than checking for null.  So don’t use it. Continue reading

Posted in Coding, Design, practice | Tagged , , | Leave a comment

Catching Generic Exception Classes

In Java you can have a try statement with multiple catch clauses.  In a method that handles exceptions, by for example wrapping and rethrowing, it is important to catch the root-most “Exception” class and this post explains why even though some misguided recommendations suggest otherwise. Continue reading

Posted in Coding, Design, Poor Error Msg | Tagged , , , , , , | Leave a comment

Holographic Testing Technique

I write a lot of code, and I want there to be solid tests on that code.  Creating tests can be tedious, and that prevents many good tests from being written.  Also, because tests can be fragile, maintaining those tests can be a lot of work.  The holographic testing technique is a way to create a lot of tests, and to maintain those tests without tedium.  Continue reading

Posted in Coding, Example Code, practice | Tagged , , , , | Leave a comment

Handling Dates

In a globally distributed system, there are some key patterns for handling dates so that they work reliably, performantly, and are unlikely to be misused by developers.  Oddly, a number of new classes were added to Java which should be avoided.

Continue reading

Posted in Coding, Design | Tagged , , , , , , | Leave a comment