It is code review time, and I offer a sample of Java code for you to critique. Can you find the problems? Continue reading
Tag Archives: code style
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 is no point in adding comments for comments’ sake. In fact, useless comments make the code worse by adding lines without adding value. Let’s talk about what a valuable comment is. Continue reading
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. Continue reading
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 of a localizable exception messages.
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. Continue reading
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. Continue reading
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? Continue reading
Two Kinds of Exceptions
An exception is a message from the system to the user about something that the program can not handle. There are a couple of main categories of exceptions: environmental and program logic. They warrant quite different treatment. Continue reading
Brainless Getters & Setters are a Waste
Someone long ago set a pattern that all members should have a getter and setter method. Some are persuaded that this is OO and this is encapsulation, so a lot of inexperienced programmers do this by default. But this is a problem. Continue reading