• LCrawford (unregistered)

    Time is so valuable that it should be treated the same as money - use Decimal!

  • Dave Hemming (unregistered)

    So he has tsDifference.Hours and tsDifference.Minutes RIGHT THERE.

    I don't work in this language but surely it's just

    If tsDifference.Hours > 0 then txtEstWaitHours.Value = tsDifference.Hours.toString;

    txtEstWaitMinutes.Value = tsDifference.Minutes.toString;

  • (nodebb)

    The author of this code snippet votes, serves on jury, and drives, too. Think about that!

  • P (unregistered)

    Yeah, sure sure, "Time to Wait" because the WTF today was delayed. TRWTF is, again, Remy.

    Remy: I recommend you skim the HTML for comments. ;)

  • Hans (unregistered)

    Apparently he not only had a hammer (which would mean everything is a nail), but also a screwdriver! And then proceeded to bang the hammer on the screwdriver for optimal effect...

  • Craig (unregistered)

    This might stem from the author's lack of knowledge about the framework.

    The .Hours and .Minutes properties of TimeSpan are never greater than 24 or 60 (respectively). They show that portion of the time span, but only the remainder which is not handled by the next-highest-order portion of the time. Probably the original author wanted .TotalMinutes which is a decimal number and can be very high because it is not exposing only "the remainder, after the whole hours have been removed".

    What's really dumb as all hell though is that this could be:

    var moreThanAnHour = tsDifference.Hours > 0; txtEstWaitHours.Value = moreThanAnHour? tsDifference.Hours.ToString() : String.Empty; txtEstWaitMinutes.Value = tsDifference.Minutes.ToString();

    If that weren't two separate textboxes, then the whole thing could have been an overload of TimeSpan.ToString(string format).

  • Pedro (unregistered)

    I dread to think how they calculated dtWorkTime, which must be a future timestamp...

  • (nodebb)

    Still more accurate an estimate than anything a programmer can give.

  • Anon (unregistered) in reply to jinpa

    I will respond angrily to your comment in 6 months, 7 days, 16 minutes and 5 seconds (roughly).

  • Brian (unregistered)

    You know, C# has the handy keyword "var" which basically says to the compiler "You deal with all the type-safety stuff, 'cause I don't want to be bothered with it." (Which, it should be noted, is still very different from mushy-typed languages like Javascript & PHP). Once you get into that style of thinking, all this Hungarian nonsense tends to fall by the wayside, because it's not really so important to keep track of the exact datatypes anymore. And of course any halfway-decent IDE can tell you the type if you really want to know it. Better to name a variable for the information it represents rather than the shape it has.

  • (nodebb) in reply to Brian

    I like the word "auto" more like in C++, its meaning aligns with its function. "Var" is meaningless. Does it stand for variable? Or varying type? Or varsity baseball? Who knows.

  • Brian Boorman (google) in reply to Hans

    If you need a chisel, but don't have a chisel, then a hammer and screwdriver is the next best thing.

  • Brian Boorman (google) in reply to Mr. TA

    Right - because someone who is bad at one thing is automatically bad at everything else. -1 for social awareness.

  • Jaloopa (unregistered) in reply to Mr. TA

    It's a variable. What type? don't care, the compiler will sort that for me

  • (nodebb) in reply to Hans

    If all you have is a three-headed hammer, everything looks like three nails.

  • (nodebb) in reply to Mr. TA

    I like the word "auto" more like in C++, its meaning aligns with its function.

    I personally favour stabbing people who use that for anything other than iterators to death with the hot end of a GAU-8.

  • (nodebb) in reply to Craig

    But... if TimeSpan.Minutes might equal 60, then you have to check for that and stringify and convert to "1 hour" before destringifying, so that you never display "60 minutes" in the output field. Or did you mean that TimeSpan.Minutes is strictly less than 60?

  • (nodebb) in reply to Jaloopa

    If var means variable, then surely we should prefix explicitly typed declarations with var, too? Var into x; is declaring a variable of type integer.

  • (nodebb) in reply to Steve_The_Cynic

    Are you that guy who always writes ApplicationVersionIncrementorContainerFactory x = new ApplicationVersionIncrementorContainerFactory(); ?

  • I can be a robot if you want me to be (unregistered)

    Estimating wait time is the WTF, any code is an afterthought.

  • Ducks (unregistered) in reply to Brian

    Using Hungarian notation is all-the-more important once you start using keyword "var".

  • Anon (unregistered) in reply to Mr. TA

    Who knows what keyword "var" stands for? According to https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var, it means "an implicitly typed local variable".

    According to your logic, keyword "for" could mean "fortran", "foremost", "for your eyes only", etc.

  • (nodebb) in reply to Anon

    Big difference, the word "for" exists in English and its meaning in programming is very similar to its English meaning. There's no word "var" in English, and even if we accept it to be an abbreviation of "variable", it doesn't communicate at all that it's implicitly typed. The keyword "auto" in C++ on the other hand is a clear reference to "automatic", meaning the compiler automatically determines the type.

  • Olivier (unregistered) in reply to Pedro

    And that is the biggest WTF in my opinion: dtWorkTime is a date in the future, seemingly the date&time when the work will be completed. Where does that date&time come from? From knowing the date&time when the job was submitted and the duration for said job, So dtWorkTime was calculated using the very data that this thing is trying to figure out!

  • Russell F. (unregistered)

    Actually, no. The value of dtWorkTime is only partly determined by how much time that kind of job takes; it's also determined by the time at which a service bay will next become free.

  • doubting_poster (unregistered)

    hungarian means the programmer has learned to code a long time ago. This could imply experience, but certainly does not indicate good code.

    It's entirely obsolete in a modern IDE and just slows down the review process.

  • Jaime (unregistered) in reply to Ducks

    No. Using var implies that your code isn't terribly concerned with the exact type of the data you're handling and you'd rather not make it fragile. If you use Hungarian in these scenarios, you're likely to see that the variable declared as "var intMinutes = x.Minutes" now handles decimal data because someone changed a property type. It also would imply that the person changing the data type should be responsible to go find everywhere the property is used and update the variable names in those methods. Otherwise, your handy notation of telling people the type in the name would could never be trusted, and therefore be less useful (in extreme cases become more misleading than helpful).

  • life be like that (unregistered)

    So we all gathered here to bash and mock this code. In the meantime, the guy got paid, the code made it to production, and will work just fine until the product dies.

  • Barf4Eva (unregistered) in reply to Mr. TA

    Seriously, that's the guy you are worried about on jury..? Can I live in your universe please? I imagine it must be very different from mine.

  • Jaime (unregistered) in reply to life be like that

    Yes, because the only thing that matters is that you get your paycheck and the software "works". This shows a complete lack of pride, craftsmanship, or even concern for the future of your job and your workload. How can we, as a profession, build more maintainable code when our own ranks see maintainability as a waste of time?

  • (nodebb) in reply to Craig

    Sometimes he uses .ToString and other times he uses Convert.ToString. Is there a difference, or is that just another in the long line of WTFs?

    Addendum 2019-09-17 09:38: (That wasn't meant to be a reply; sorry about that.)

  • Jaime (unregistered) in reply to urkerab

    Decompile of appropriate overload of Convert.ToString:

    public static string ToString(int value) { return value.ToString(CultureInfo.CurrentCulture); }

    So, yes, even though it uses a different overload of ToString, it boils down to the same thing when passed CultureInfo.CurrentCulture.

  • (nodebb) in reply to P

    skim the HTML for comments

    Or use a Greasemonkey script like https://userscripts-mirror.org/scripts/show/112851 or a bookmarklet like the one at https://what.thedailywtf.com/topic/12789/remy-s-back-a-script-for-those-who-don-t-want-to-read-the-source You might need to update the class names though: "ArticleBody" is spelled "article-body" these days.

  • Ducks (unregistered) in reply to Jaime

    Granted, my sarcasm was very subtle, but I still think you deserve a "whoosh".

Leave a comment on “Time to Wait”

Log In or post as a guest

Replying to comment #:

« Return to Article