• Kaewberg (unregistered)

    The goggles! They do nothing! WHY?!

  • LCrawford (unregistered)

    So it was ready to 'upgrade' to Javascript, which lacks basic number manipulation.

  • Mischa (unregistered)

    It seems that it does have some form of error margin, Which a ceil function usually does not. Which does not excuse the shoddy imolementation and usage.

  • Little Bobby Tables (unregistered)

    So, er, TRWTF is that the original coder can't spell "decimals"...?

  • patrick (unregistered)

    So forgive me - my C# is not that good - but the problem in the code (besides not using a built-in function and besides not isolating this in its own function) but the problem here is that only fractions > 0.0001 are ceiled and fractions like 0.0000001 are ignored?

  • hakko (unregistered) in reply to Little Bobby Tables

    Or OP was german? (Which have a lot of words which use z where the english use c)

  • (nodebb)

    To ceil() or not to ceil(), that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of hidden implementation, Or to take Arms against a Sea of troubles, And by implementing our own: to win, to lose No more; and by a win, to say we end the heart-ache, and the thousand natural shocks that unseen code is heir to? 'Tis a consummation devoutly to be wished.

  • Guest (unregistered) in reply to Little Bobby Tables

    Given that it uses a comma for decimals, you can be sure it was a German developer.

  • Damien (unregistered) in reply to Guest

    Yep, must be German. No way it could be anything else.

    https://en.wikipedia.org/wiki/Decimal_separator#Countries_using_Arabic_numerals_with_decimal_comma

  • my name is missing (unregistered)

    Top notch code, on the up and up, raising the bar for everyone to a new height of value.

  • RLB (unregistered) in reply to Damien

    Many languages use the decimal comma, true, but I can only think of one which spells it with a 'z'.

  • -s- (unregistered)

    C#/.Net does not have a String::Tokenize() -method.

  • -s- (unregistered)

    C#/.Net does not have a String::Tokenize() -method.

  • djingis1 (unregistered) in reply to RLB

    I can't think of a single language that spells "comma" with a 'z'.

  • Darkenon (unregistered)

    I once worked on a Migration where they were converting an old Java Spring app to Hibernate, and we had to replicate bugs. It was pretty difficult writing syntactically incorrect SQL that almost the opposite of what was intended in hibernate.

  • Aurioch (unregistered) in reply to djingis1

    "Decimalni zarez" (decimal comma)

    Croatian :P And it has 2 'z's!

  • djingis1 (unregistered) in reply to Aurioch

    I stand corrected. And I learned some Croatian, to boot!

  • (nodebb) in reply to CoyneTheDup

    To ceil() or not to ceil(), that is the question: Whether 'tis nobler in the mind to suffer The slings and arrows of hidden implementation, Or to take Arms against a Sea of troubles, And by implementing our own: to win, to lose No more; and by a win, to say we end the heart-ache, and the thousand natural shocks that unseen code is heir to? 'Tis a consummation devoutly to be wished.

    LIKE button, please, even if it's a "feature" of a shitty platform.

  • Little Bobby Tables (unregistered)

    Whoosh to everyone.

  • Karl Bielefeldt (github) in reply to LCrawford

    JavaScript has had Math.ceil() forever.

  • Zach (unregistered)

    Which is better? Migrating and then fixing the bugs, or fixing the bugs and then migrating. Why can't you fix the bugs while migrating?

  • Jonathan (unregistered)

    Fun fact, for Windows 8, Microsoft "corrected" the decimal separator for the South Africa locale. Before Windows 8 it was a "." (period), from Windows 8 onwards it changed to a "," (comma) and it highlighted all sorts of incorrect assumptions in our code. So this code could randomly not work on someone else's computer if it doesn't have the decimal separator.

    At the time I was working on a team with half their PCs on Windows 7, and the other half on Windows 8 and it highlighted all sorts of problems with assuming a particular decimal separator in the system, for example SQL Server uses regional settings to correctly work with decimal values. A SQL script which worked fine on Windows 7 wouldn't work when run on a Windows 8 machine and vice-versa.

    In the end it made our code more regionalization friendly as it was taking into account that not all regions are the same. Mostly it affected things like DB migration scripts and the solution was to ensure you used InvariantCulture or setting the region manually for things like that.

  • Mike (unregistered)

    The real wtf is paying someone to "upgrading" code without adding / changing behavior.

  • Little Bobby Tables (unregistered) in reply to Zach

    In certain contexts it is better to migrate first, and fix the bugs later. In that way you can run tests against the before and after, and compare the outputs directly with an automated process. If you fix the bugs while migrating, you accrue differences between the before and after which have to be accounted for: are they caused by fixing bugs or introducing bugs?

    As for whether to fix the bugs first, again, I would rather fix them after migrating because then you have the full infrastructure of your new codebase to work on. As you already know what the bugs are (you made a note of them as you migrated), it is then a straightforward (but structured) task to address them.

  • King (unregistered) in reply to -s-

    Now it has:

    public static string Tokenize(this string value) { ... }

  • Your Name. (unregistered) in reply to Zach

    Because if you fix while rewriting, you can't differentiate between things that break due to faulty upgrading and things that are broken and bugged from the get-go.

    So two phases:

    The first one upgrades the code while completely replicating the behaviour. Things to do in this step: Re-naming internal variables and methods sensibly; ordering the code in a way that similar issues are addressed together as a group instead of interspersed if possible; outlining the high-level code structure and within each part outlining that part's high level structure and so on recursively, so that at each zoom level the code is compact and comprehensible; replacing implicit side effects by explicit parameters; removing any kind of code smell; etc.

    The making and breaking check for this step is that the behaviour must be exactly identical before the changes and afterwards in every way. (For instance with compilers, the rewritten one must produce exactly the same bytes as the original one when given the same input.)

    Then in the second phase, you change functionality and fix bugs.

  • RichP (unregistered) in reply to djingis1

    commas with a 'Z', possibly lolspeak?

    (oh, and dobar dan to the Croatians among us)!

  • Jay (unregistered) in reply to Little Bobby Tables

    What about the bugs that you have to fix because the contexts that created said bugs no longer exist in the language or tech you are translating to?

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to Jay

    For multi-line copypasta crap like this, I think making a function out of it would be the best answer. Then you can encapsulate the stupidity to as few places as possible, and likewise the hacky workarounds to emulate things that don't exist in the target environment.

  • Brian Boorman (google) in reply to djingis1

    I was just going to say - "you can't think" and forget the rest of the sentence.

  • sizer99 (google) in reply to Your Name.

    You are absolutely correct, except it's usually 'In the second phase you add features but never bother fixing the old bugs'

  • (nodebb)

    This is the kind of code I'd move to a class named BugForBug, into a static method called BuggyCeiling(). That would at least make it explicit why it's there.

    ...That, and in the process of porting I'd make explicit the use of the German culture in the ToString() call (we had the same problem for a time with files using French culture for floats -- it became funny when we started getting some NaNs due to an unrelated bug...)

  • I Saw a Robot (unregistered)

    "Upgrade this, but don't change the functionality."

    Hands back the exact same code. "Done."

  • PageTurner (unregistered)

    Nobody has yet mentioned another reason for reproducing bugs:

    The cost savings of not having to update all of the manuals and retraining everyone on the changes made to the system.

    (Saw this mentioned about a point-of-sale system, where the company porting the existing system to a new platform was told, "no, put the bugs back in so we don't have to change our training materials".)

Leave a comment on “Hitting Your Skill Ceiling”

Log In or post as a guest

Replying to comment #:

« Return to Article