Coding Hell

🐞

If hell is paved with good intentions, then computing hell is paved with bad excuses. Some look like reasonable design ideas, but very often they only quack like a duck…

This code can be hacky, it will never be used in production.
Useful code gets deployed, or did you intended to write useless code?
I added an abstraction layer.
You tried to protect yourself from learning on how a library works, and added a level of indirection that obscures the call path and makes the code more complicated.
Hash-maps have O(1) lookup time.
Yes, and they are also 100 times slower, and you structure holds less than 100 items…

I have not deleted this code, because it could be useful later
Clearly, you do not understand how version control systems work, and increased the use the fossilized lava flow design pattern.
It is an object, object-oriented is better.
Your method is static, but not marked as such, so we need to instantiate a class just to unit-test that method.
Values are not integers, so I used floats
And you did not consider using fixed point notations, or normalising values properly. So now we cannot use simple equality, and our accounting code will never be right.
I made my code generic
There is only one use case, you made your code needlessly complex, and probably added some bugs in the mix.
Doing X is trivial, so I wrote a quick function
You avoided looking for the library or reading its documentation. Your code works for the trivial case and breaks for corner cases we will happily discover in production.
I don’t need to think about memory usage, this language has a garbage collector
The garbage collector will slow the system to a glacial pace before throwing out of memory errors.
This system will only be used by engineers, so supporting only ASCII is fine.
Because engineers never, ever, ever use data from the real system.
This error cannot be fixed, so it is fine to call abort()
Clearly any system that links-in your code wants to crash when this condition occurs.
I designed an elegant language to hold this data
Clearly, the engineer who will need to change that data in a hurry wants to learn a new language, and then fix the bugs in the interpreter.
I’m calling an external tool like awk, it’s the Unix way
You have added an external dependency, made the code less readable and probably added a few bugs in argument generating and result parsing code.
Putting dates in strings is safer
And you did not document in which format…
That notation is universally known, so there is no need to document it.
Clearly, all of the planet uses the same school system and same notations as you did.
Assertions are for people who do not write proper error handling
No, they are for checking that impossible things never happen, and nobody writes error handling for impossible things, that would be silly.

5 thoughts on “Coding Hell”

  1. Pour la couche d’abstraction, la hash table, le garbage collector, awk (ou tout appel à un produit externe éprouvé), ça peut être un choix délibéré dans un cadre précis (« There is only one use case », right? :-) Sera toujours temps d’optimiser ou de réinventer la roue plus tard.

    La date dans une string devrait être puni de mort. Même documenté ça fait mal. Oui, j’ai déjç vu un 30 février…

  2. Appeler un langage de script depuis un langage de script, c’est une mauvaise idée™, le pire que j’ai vu, c’est un appel à sleep en python…

  3. @Thias : Bon, même moi je chercherais comment faire ci ou ça en python avant d’appeler un soft externe. Y a peut-être un existant, et il y a beaucoup plus complexe que awk. L’important est d’être conscient que c’est goret et de l’isoler le jour où on veut contre toute attente passer en prod :-)

  4. L’article est intéressant, mais je ne suis pas d’accord avec sa théorie que les unit-test sont un luxe qu’on ne se permet pas pour aller vite, les unit-test sont ce qui fait que tu n’as pas besoin de refaire encore et encore les mêmes bugs. Au boulot je refuse du code sans unit-test.

Leave a Reply to ThiasCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.