If this is your coding test... no thanks.



  • Browsing through a local job board, I came upon a rarity - small software company actually included a coding test as part of their job ad.

    A way for me to procrastinate on working on my hobby projects or fulfilling social obligations? Bring it on!

    Fail no. 1 - broken English. If you can't put together smooth sounding English, just write it in Serbian. This is embarrassing.

    0_1481392667739_upload-2e3a7a41-ee6e-43d4-a6de-7733a59409a4

    Windows 7 screenshot, Firefox. Someone hasn't been keeping pace with technology.

    But whatever, let's see the task itself. You're given an HTML and PHP file each, and you're supposed to write an AJAX function to log the user in. Ok, reasonable enough. A bit on the easy side, since almost everything is already filled in. But whatever, I suppose this is a frontend version of FizzBuzz.

    Their code, though...

    <!DOCTYPE html>
    <!test.html>
    <html>
    <body>
    Name:<div id="name"><br></div>
    Age:<div id="age"><br></div>
    Accepted:<div id="accepted"><br></div>
    Weight:<div id="weight"><br></div>
    <form>
    	Username:<br>
    	<input type="text" name="username"><br>
    	Password:<br>
    	<input type="password" name="password"><br>
    </form> 
    <button type="button" onclick="sendData(document.forms[0].elements['username'].value,document.forms[0].elements['password'].value)">Submit</button>
    
    <script>
    
    function sendData(username, password) {
    }
    
    </script>
    
    </body>
    </html>
    
    <?php
    error_reporting(E_ALL);
    session_start();
    if (isset($_GET['username'])) {
    	UpdateForms($_GET['username'],$_GET['password']);
    	echo $_SESSION["age"]. "," . $_SESSION["weight"]. "," . $_SESSION["accepptuser"]. "," .$_SESSION["name"];
    }
    function UpdateForms($username, $password) {
    		if ($username=="test" and $password=="testiranje")
    		{
    			$_SESSION["age"]=30;
    			$_SESSION["weight"]=90;
    			$_SESSION["accepptuser"]=1;
    			$_SESSION["name"]="Jovan";
    		}
    		else {
    			$_SESSION["age"]=0;
    			$_SESSION["weight"]=0;
    			$_SESSION["accepptuser"]=0;
    			$_SESSION["name"]="No user";
    		}
    }
    ?>
    
    1. What are those <br>-s doing inside data fields?
    2. Ewww, calling js function directly from html? Accessing <form> data through the name fields. So flakey. So 90-ies.
    3. Is that two-tab indentation down at the bottom of PHP file?
    4. Oh God, are you expecting the login form to go through GET?
    5. Why are you testing if the username is sent in? And then just failing silently? What's the point?
    6. What if you give it a wrong password? It... just nulls out all the data. No HTTP error codes or anything.
    7. Let's just concatenate return data into an easily breakable CSV, it's not like API-s have standardized on JSON or anything
    8. You... you are basically using SESSION just as a global var to pass data between functions, that's not what it's for.... AGGGH!

    Dear small company, THANK YOU for posting a sample of your coding practices right inside the job ad. More shops should do this.

    If they expect to be able to see my code and fail me based on that, I should be able to see their code and fail them based on that.

    And so I did.



  • <!test.html> 
    

    doesn't look like something from the 90s OR today, or anytime in between. WTF is that?


  • Winner of the 2016 Presidential Election

    @cartman82 said in If this is your coding test... no thanks.:

    Ewww, calling js function directly from html? Accessing <form> data through the name fields. So flakey. So 90-ies.

    For this simple example, why not just use the html-only form?

    <form action="wherever" method="whatever">
    	Username:<br>
    	<input type="text" name="username"><br>
    	Password:<br>
    	<input type="password" name="password"><br>
    	<input type="submit" value="Submit">
    </form> 
    


  • @The_Quiet_One said in If this is your coding test... no thanks.:

    doesn't look like something from the 90s OR today, or anytime in between. WTF is that?

    Um?

    No idea. I didn't even notice that.

    Probably copy-pasta from some long-forgotten forum post the author of this test has been dragging along and never stopped to examine.



  • @Dreikin said in If this is your coding test... no thanks.:

    For this simple example, why not just use the html-only form?

    Because then their PHP code would have to render the page, and we couldn't target their "A. P. I." (imagine me flailing my arms around into a quote/unquote guesture).


  • Winner of the 2016 Presidential Election

    @cartman82 said in If this is your coding test... no thanks.:

    Because then their PHP code would have to render the page

    I, uh, what? :confused:

    I get that you're not serious, but I'm trying to follow where that came from.



  • @Dreikin returning bunch of data and getting work done client-side vs. returning whole page.


  • Winner of the 2016 Presidential Election

    @Gąska said in If this is your coding test... no thanks.:

    @Dreikin returning bunch of data and getting work done client-side vs. returning whole page.

    Oh, right, okay.

    (webdev is not yet something I have a lot of familiarity with, as you can tell.)



  • @Dreikin said in If this is your coding test... no thanks.:

    Because then their PHP code would have to render the page

    I, uh, what?

    If you do it through form as you suggested, then it would fully reload the page. The php handler on the server will have to be involved with rendering the response HTML. That's sort of the "traditional" way of making websites.

    If you want request / response to be done without reloading the page (ajax), you have to do it through javascript.



  • @cartman82 said in If this is your coding test... no thanks.:

    What are those
    -s doing inside data fields?

    Maybe to make them take up vertical space even with no data?



  • At first I thought, well-- that's not so bad. Sure, it isn't perfect, but it's just a piece of throwaway code. It was probably just thrown together for the test.

    I mean I could probably write better, but--

    And then I stopped, and thought, well, wait a second. I COULD write that whole thing better. Cleaner, more understandable. Even if I was just throwing it together. In fact, I would WANT to write it better, explicitly because it's a test. I'd want to make sure that the HTML and PHP would actually do what the test expects it to do, so if it's messy and thrown together I wouldn't be able to test it.

    So then I thought-- well, holy fuck. These guys probably don't care about testing their code, or making sure it's maintainable. This is the code they write, every day-- and this is an example of what they consider "good enough" code. They didn't give it a polish or a look over, because they don't care. There's no pride in their work. It just needs to get done, and to the bare minimum of standards.

    And then finally I thought "fuck these guys".


  • Impossible Mission Players - A

    TIL @Lorne-Kates has deeper thoughts than I had originally given competitive for....



  • 0_1481542612068_Capture.PNG

    I have been keeping pace with technology, that's why I've remained as I am :stuck_out_tongue:


  • Winner of the 2016 Presidential Election

    @Tsaukpaetra said in If this is your coding test... no thanks.:

    given competitive for....

    Autocorrect 1 - Logical sentences 0


  • Winner of the 2016 Presidential Election

    @Tsaukpaetra said in If this is your coding test... no thanks.:

    TIL @Lorne-Kates has deeper thoughts than I had originally given competitive for....

    He didn't even ask for remunerations!


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.