- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The goggles! They do nothing! WHY?!
Admin
So it was ready to 'upgrade' to Javascript, which lacks basic number manipulation.
Admin
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.
Admin
So, er, TRWTF is that the original coder can't spell "decimals"...?
Admin
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?
Admin
Or OP was german? (Which have a lot of words which use z where the english use c)
Admin
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.
Admin
Given that it uses a comma for decimals, you can be sure it was a German developer.
Admin
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
Admin
Top notch code, on the up and up, raising the bar for everyone to a new height of value.
Admin
Many languages use the decimal comma, true, but I can only think of one which spells it with a 'z'.
Admin
C#/.Net does not have a String::Tokenize() -method.
Admin
C#/.Net does not have a String::Tokenize() -method.
Admin
I can't think of a single language that spells "comma" with a 'z'.
Admin
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.
Admin
"Decimalni zarez" (decimal comma)
Croatian :P And it has 2 'z's!
Admin
I stand corrected. And I learned some Croatian, to boot!
Admin
LIKE button, please, even if it's a "feature" of a shitty platform.
Admin
Whoosh to everyone.
Admin
JavaScript has had Math.ceil() forever.
Admin
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?
Admin
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.
Admin
The real wtf is paying someone to "upgrading" code without adding / changing behavior.
Admin
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.
Admin
Now it has:
public static string Tokenize(this string value) { ... }
Admin
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.
Admin
commas with a 'Z', possibly lolspeak?
(oh, and dobar dan to the Croatians among us)!
Admin
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?
Admin
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.
Admin
I was just going to say - "you can't think" and forget the rest of the sentence.
Admin
You are absolutely correct, except it's usually 'In the second phase you add features but never bother fixing the old bugs'
Admin
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...)
Admin
"Upgrade this, but don't change the functionality."
Hands back the exact same code. "Done."
Admin
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".)
Admin
I'm not seeing how this is C#.
There's no implementation of String.Tokenize in C#.
There's no implementation of String.ToNumber in C#.
There's no implementation of Decimal.ToString(int), Int.ToString(int) or Anything.ToString(int) in C#.
I guess it's possible to create extension methods for each of these, but doubtful. Seems more like pseudo-code or something else.