Tag Archives: code style

Factoring Functionality: Who Needs to Know?

There are many ways you can break the functionality of a program into blocks that are manageable: some right, some wrong.  This post promotes a simple principle.  The primary way should be around “who needs to know.”

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

Good Error Messages Can Be Easy

Here is an error message I encountered one day.  It is frustrating, because obviously the code was checking something, but it is frustrating because you get no real clues what the problem really was, and a simple change would make … Continue reading

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

What is wrong with this code?

It is code review time, and I offer a sample of Java code for you to critique.   Can you find the problems?

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

Eliminate Useless Comments

Be careful what you ask for.   I was reviewing some code that had absolutely no comments. I asked the developer to add some comment.   So, indeed they did, however the comments added no value to the code at all.   There … Continue reading

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

Keep Things the "Same"

This general design principle does not mean to never change anything, but to consciously create a paradigm where the same things have the same names and are accessed in the same way as much as possible.

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

Translatable Error Messages

This is the first of a series of posts, I want to go over some of the groundwork of what it takes to make exceptions localizable into other languages. Nothing new here, but just want to explain clearly the requirements … Continue reading

Posted in Coding, Design, Uncategorized | Tagged , , | 3 Comments

Constants and Errors

Still reviewing that code base and finding more bad patterns for use of constants, this time for error messages.   This is another “don’t do this” post.

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

Context Error Reporting

One of the biggest mistakes I see programmers make when writing an error message is to forget to include details about the context into the message.  The message effectively “assumes” that the reader knows the context, but that assumption is … Continue reading

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

Software is Clutter-Prone

Software will always increase in amount and size, and that includes not only things that are needed, but unneeded things as well.  Unless you fight diligently against it, code will tend to get more and more cluttered.

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

When are "best practices" less than best?

A “best practice” is a heuristic which is used to guide early stages of a project, in order to set some patterns.  When should you use them?  More important: when are you justified in ignoring a best practice?

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