Sunday, July 25

Mercurial HG on the wiki

I spent the better part of the morning reading about hg from Joel's tutorial. Check my notes if you're interested in a quick hg reference.

Sunday, June 27

Worse Case time complexity for binary search

If we represent the time complexity of Binary Search as

W(n) = W(n2) + 1.

Prove the following:

W(n) = floor(lg n) + 1

Saturday, March 6

Configuration Is Not Inherently Evil

Personally, it's not that I don't like configuration or xml files. It's more that I don't like complicated configuration.

Web Xml Order

I sort-a-knew this but nice to see it down on paper.

Despite some developers stating that the order of elements in web.xml must follow an exact order, for the most part this is incorrect. However, some elements must be defined before others. Filter and filter-mapping are one such example …

I think this used to be the case pre the 2.x spec maybe?

Exception Handling for Exceptional Handling

Found an interesting writeup on Exception Handling. I agree with their assertion

Exceptions should be thrown only when there is no meaningful way of handling the situation. If these situations (conditions) can be handled programmatically in a meaningful manner, then throwing exceptions should be avoided. For instance if it is possible to handle the problem of withdrawal amount exceeding the balance in some other way, it has to be chosen over throwing an application exception.

but am particularly confused with one of their contradictory examples elsewhere in the expose:

A rule of thumb is to model application exceptions as checked exceptions and system exceptions as unchecked exceptions. The code below is an example of application exception.
    if (withDrawalAmt > accountBalance)
    {
        throw new NotEnoughBalanceException(
        “Your account does not have enough balance”);
    }
When the account does not have enough balance for requested withdrawal amount, the user gets a NotEnoughBalanceException. The user can decide to withdraw lesser amount. Notice that the application exception is not logged. In case of the application exceptions, the developer explicitly throws them in the code and the intent is very clear.

Friday, March 5

A Versioning Strategy

Jackson versioning follows guidelines similar to [the] ones Eclipse project uses, so that:

  • Major version upgrade indicates incompatible changes.
    • You MUST recompile (and re-test) your application or service when upgrading to a new major version
    • Major version upgrades occur rarely
  • Minor version upgrade indicates added functionality, but without removing existing functionality
    • It is possible that observed behavior changes, but this should usually not cause compatibility problems
    • Changes are binary compatible so it is possible -- although not recommended -- to just upgrade jar. Instead, you should recompile application, and re-test code that uses Jackson
  • Patch version upgrades are strictly for bug fixes, and no new functionality is added
    • Only changes to observed behavior is to fix broken behavior
    • Upgrade by swapping jars should work without problems

Thursday, March 4

Basic JEE Web Config

web.xml (2.4):

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
    version="2.4">
   …
</web-app>

Saturday, February 27

FindBugs vs PMD

This post nicely distinguishes FindBugs, PMD and a few other static code checkers.

Each of them is mainly targeting a certain type of coding rules : conventions (Checkstyle), bad practices (PMD) and potential bugs (FindBugs).

Where Is JAVA_HOME On A Mac?

The Java homes on Macs are in the /System/Library/Frameworks/JavaVM.framework directory.

Or, if you prefer, try ~/Libary/Java/Home or reading this.