Articles

Affichage des articles du 2015

Set a correct exception template !

As a developer, you'll face bugs in production. To analyze what happened, you'll rely on logs and well-known stack traces. But, in order to get stack traces in your logs, exceptions in your application should be handled correctly. Sometimes, you just see no stack trace in your logs because of a block like this: Loading .... Obviously, if an exception happens, you won't have any clue in your logs. This kind of code is often generated by your IDE. So, take a few minutes and change your try/catch template to the following : Loading .... Now, if the same exception appears, it will be rethrown in an unchecked exception. If your application is correctly configured, it will be caught somewhere and logged there. Try to convince your colleagues to do the same !

Where to put curly braces

Code formatting is clearly something personal. Some prefer code without blank lines, others like when the code is grouped in blocks separated with blank lines. I belong in the second team. A common talk with colleagues is where to put curly braces ?