Tag Archives: structure

Lots of Folders != Project more Organized

Making a development project with lots of folders does not mean that the project is more organized.  However, there is a seemingly irresistible desire to make a folder for every possible purpose, and then put the one or two files that fit in there, all in the name of keeping the project organized.  This might make the programmer feel good, but it is a large pain for anyone new who has to join the project or review the source for any reason. Read the rest of this entry »

Leave a comment

Posted by on May 18, 2017 in Coding, practice


Tags: , ,

Error-First Design in JSON/REST/AngularJS integration

You have heard about “mobile-first” when creating your UI, but there is something you should do before you start designing the UI:  you should design the error handling/display mechanism first. Read the rest of this entry »

Leave a comment

Posted by on December 4, 2015 in Coding


Tags: , , ,

Storing Date Values in Files

XML and JSON files store and transport data.  What is the best way to store a Date-Time value? Always, always, always use the integer epoch format: the number of milliseconds since Jan 1, 1970 UTC. This post tells you why. Read the rest of this entry »

1 Comment

Posted by on January 17, 2014 in Coding


Tags: , , ,

Method Exception Signature

In short, all interface methods, if they throw anything, should be declared to throw ‘java.lang.Exception’ and never a specialized exception class.  Find this surprising? then please read on.  The original goal to allow methods to declare the type of exceptions they might throw was a valiant attempt to clarify program behavior, but unfortunately it was misguided, does not work, and if used incorrectly can turn into a maintenance nightmare. Read the rest of this entry »


Posted by on April 4, 2013 in Coding, Design


Tags: , , , , , ,

#33 Eliminate Exceptional Cases before the Main Logic

When writing code, you naturally want the code to be readable so it can be maintained easily.  Generally, you try to reduce the cognitive load, and one recommendation is to handle exception cases that might occur up front, in a small, localized block of code, before falling through to the main block of logic. Read the rest of this entry »

Leave a comment

Posted by on December 31, 2012 in Coding, Example Code


Tags: , , ,

#27 Don’t Declare Variables at the Top

Somewhere long ago you attended a course that said that all variables should be declared at the top of the method.  Modern languages allow you to declare the variable at the point in the code that it is initialized and this is a significant advantage.  However, the outdated idea of declaring all variables at the top of the method persists.  This post explains why this is a bad idea. Read the rest of this entry »

Leave a comment

Posted by on April 14, 2012 in Coding, Example Code


Tags: , , ,

#19 Reduce Cognitive Load

Deeply nested IF statements can be hard for the brain to unwind and process correctly.  In many cases, the branch statements are selecting for a single, or a small set of conditions for which processing will be done, and outside of those conditions nothing will be done.  Given this, the code can be structured to avoid complexity, make it easier to understand, and less costly to maintain. Read the rest of this entry »

1 Comment

Posted by on October 29, 2011 in Coding


Tags: ,