• Greg (unregistered)

    I can't help but wonder how their interview process goes... I guess somehting like this: Manager: Can you press keys on a keyboard? Candidate: Yes Manager: When can you start?

  • (nodebb)

    This stumped them, as the following C# code only ever printed out a zero

    Well, duh. new DateTime(), according to what I can find(1), initializes the internals of the DateTime to all zeroes (and most definitely not to a representation of "now"), so the "timestamp" would be 0+0+0 (hour, minute, second).

    So:

    I don't think this actually only ever printed out a zero. It certainly didn't print out a timestamp, but it also didn't print out a zero. So not only is the code bad, but the understanding of how it's bad is also bad. It's bad. Bad. Bad.

    The code is bad, but the article's writer (that is, our friend RemyP), sad to say, is ALSTWTF.

    ("At least somewhat the WTF")

    (1) My language of choice is normally C++, with a descent into madness ^W C when necessary (the codebase is an unholy mix of the two, and dosed with plenty of its own WTFs...)

    Addendum 2024-12-19 07:03: And by 0+0+0, I mean the actual arithmetic sum of the three zeroes, that is, 0.

  • some guy (unregistered) in reply to Greg

    Maybe they were really at a blackboard. Back when I started, dotnetfiddle wasn't a thing, but now it is. Please show it to any .NET beginners.

  • Mpripper (unregistered) in reply to Steve_The_Cynic

    Yes, new DateTime() initializes everything to 0. To get the current time, one needs to use DateTime.Now or DateTime.UtcNow

  • Hans (unregistered)

    Was that co-worker a (former?) javascript developer? There a new Date() returns the current date+time, while in C# (as mentioned before) it returns a fixed value: DateTime.MinValue (=01/01/0001 00:00:00)

  • Greg (unregistered) in reply to some guy

    Where I work, the hiring process (for developers) includes a programming test where the candidate writes pseudo code to solve a fairly simple problem. I highly recommend this approach...

  • Jaloopa (unregistered) in reply to Steve_The_Cynic

    Yes, DateTime is a struct in C#, which as a general rule will be created with default values when invoked via a parameterless constructor. To get the current time you use DateTime.Now() or DateTime.UtcNow(), and if you want a specific value you can use one of the constructor overloads. Adding a number to a string does concatenate themso this code will print the message prepended by a 0.

    Maybe this developer was used to Javascript where date objects initialise to the current time, but even then, adding the minute, second and millisecond together would give you a number rather than a concatenation. A common way to get around this in JS would be to start the addition with "" +, so a marginally more useful version in Javascript would be

    let d = new Date;
    let timestamp = "" + d.getMinutes() + d.getSeconds() + d.getMilliseconds();
    let message = "hello world";
    console.log(timestamp + message)
    
  • Tim Ward (unregistered) in reply to Greg

    1980s hiring technique. We used to say that if you could spell the world "computer" with only a couple of errors then you were in.

  • (nodebb)

    During Dotcom era, my consulting employer hired anyone with a pulse, I was handed an employee who did not understand for loops, and I was expected to have him bill 40 hrs a week. I wound up doing my work plus his, and sent him to training continuously, up until we went out of business...

  • (nodebb)

    I don't think this actually only ever printed out a zero

    It does. DateTime is a struct, so new DateTime() initializes an instance of it with all zeros, i.e. 01/01/0001 00:00:00

  • Brian (unregistered)

    Most places I've worked have a probationary period - if you're not performing adequately within the first few months, you're done. Guess these guys never heard of that.

  • Chris O (unregistered)

    That's the kind of code where you have to ask the programmer what he was actually trying to do, and what he is expecting the output from that code to be.

  • Argle (unregistered)

    Must have been hired by the brillant Paula Bean.

  • aCompetentDate (unregistered) in reply to Greg

    I'm starting to see more and more resistance to coding interviews, along the lines of "But I don't ever need to reverse a linked list in practice!" I wonder if those people are so aggressively contrarian they have to complain about everything they don't understand even when it is no problem whatsoever... or if they actually struggle with the basic tasks those interviews require them to do. I don't know which is worse.

  • Deeseearr (unregistered) in reply to Greg

    I suspect the interview went a little like this:

    "You said on your CV you have a lot of experience with computers."

    "I did say that on my CV, yes. I have a lot of experience with the whole computer thing you know, emails, sending emails, receiving emails, deleting emails, I could go on."

    "Do."

    "The web. Using a mouse, mices, using mice. Clicking, double clicking. The computer screen, of course. The keyboard. The... bit that goes on the floor down there."

    "The hard drive."

    "Correct."

  • (nodebb)

    This code is weird, usually timestamp is a synonym with datetime. No idea why it is minutes plus seconds plus milliseconds ... but no microseconds or nanoseconds?

    Something here is totally wrong, I can think about thousands of bad practices that could be going on here from using timestamps for optimistic concurrency checks or doing benchmarks instead using something proper like benchmark.net... to bad we only see the peak of this giant iceberg of WTF.

  • Some python guy (unregistered)

    I dabble in Python and the way I would approach the original problem would be to use the logger module and let it figure out the date & time stuff. Isn't there something similar in C#?

  • (nodebb) in reply to Some python guy

    Yes, the currently best logging package is Serilog: https://serilog.net/

  • Drak (unregistered) in reply to MaxiTB

    It probably depends on how grainy you want your logs, and whether you are using them to figure out which part of your process is taking up that unexplained half-second of time. In that case microseconds and nanoseconds just add noise to the log. If your implementation of datetime actually goes that precise. From the Microsoft site, about the DateTime.Now property: The resolution of this property depends on the system timer, which depends on the underlying operating system. It tends to be between 0.5 and 15 milliseconds. As a result, repeated calls to the Now property in a short time interval, such as in a loop, may return the same value.

  • (nodebb)

    I can't fault Remy for this. I too, completely missed that the programmer used new DateTime() instead of DateTime.Now.

  • Officer Johnny Holzkopf (unregistered)

    Given the confusion of strings and ints, the "all zero" initialisation and what a + sign does, should the expected timestamped messages look like this?

    3504263 Error in Daterbase: FILE_NOT_FOUND

    This happened at 14:35:04 and 263 milliseconds. Almost an hour later, the following message appears (at 15:10):

    1058012 Competencery exceded: PAULA flag setted in modul Aktenkoffer.EXE

    Of course, this kind of timestamp provide no usable sorting feature, let alone something was logged yesterday or will be logged tomorrow...

  • Graculus (unregistered)

    If the hiring process involves a coding test involving anything CS related (e.g. linked lists, sorting etc) then as a candidate you have the right to say "no thanks" and apply to a different company who know how to recruit good developers. Equally if the coding test involves anything too close to the problem the potential employer is involved with - then say "no thanks". Too many times I have seen "coding tests" as a free way of solving an existing problem. A good coding test involves reading and debugging code and fixing issues in both simple ways and ways that involve a progressive (read refactoring) redesign that involves a discussion around compromises (assuming the coding test is part of the interview and not something you are given to do in your "free time"). "Free/own time" code tests are a completely different kettle of fish.

Leave a comment on “Zero Competence”

Log In or post as a guest

Replying to comment #:

« Return to Article