CodeSOD: maximum character width

One of the “features” of the Oracle database is that, in addition to the “beautiful” PL/SQL language for building stored procedures, you can also write stored procedures in Java.

Now, the skills of “being a good database developer” and “being a good Java developer” don’t necessarily overlap, especially when you’re deep into the world of Oracle’s programming approach. Where is this submission from? Thomas comes from.

    private static final short m_maxCharWidth[][] = 
        
            1, 1
        , 
            2, 1
        , 
            3, 1
        , 
            4, 1
        , 
            5, 1
        , 
            6, 1
        , 
            7, 1
        , 
            8, 1
        , 
            9, 1

       // ... some time later ...

            9998, 3
        , 
            9999, 3
        
    ;

The first thing to notice is that this 2D array uses its first dimension for storage index+1. Maybe someone really liked Matlab and wanted indices based on 1. Hard to say for sure.

It’s also hard to tell what it actually is for. My first thought was that it was a mapping of numbers to their number of digits, for display purposes. Given the name, it seems plausible – but that would mean they’re using 3 characters to represent 4-digit numbers, which would be wrong. Maybe it maps Unicode code points to the number of bytes they need to represent? That’s not good either. Or maybe it is (short)log(n)– a truncated log, but that it would be wrong for all single digit numbers. Our submitter cut the double digit range, so I’m not sure what’s in there, that might answer the question.

But again, why am I even trying to answer this question? This code simply shouldn’t exist.

.comment border: none;

[Advertisement]

Otter – Automatically secure your servers without the need to log into the command line. Get started today!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *