Don't trust input



  • I was asked to do a code review. The architecture looks like this:

    external system -> feed -> single point of entry -> split out into internal processing modules/threads

    Every single method of every single file looks like this:

    public <type> methodName(type1 arg1, type2 arg2, ...) {
    if (arg1 == null) { handle error and return }
    if (arg2 == null) { handle error and return }
    if (arg1.startsWith("some invalid value")) { handle error and return }
    if (arg1.startsWith("some other invalid value")) { handle error and return }
    if (arg2.startsWith("yet another invalid value")) { handle error and return }
    if (arg2.startsWith("and so forth")) { handle error and return }
    ...
    <ACTUAL method in code>
    

    Multiply this by thousands of methods in hundreds of classes and the code is 10 times the size it needed to be. The explanation? The feeding system routinely passes nulls instead of the required values so we need to check for it everywhere.

    I went to the single module where the data comes in off the wire and added a single function that checks all required fields for null/invalid values and told them to remove all the in-method checks, and declare exceptions ("you can use exceptions for that?").

    Why do big companies assume that 2 experienced engineers can compensate for 500 inept idiots?



  • @snoofle said:

    Why do big companies assume that 2 experienced engineers can compensate for 500 inept idiots?

    Wait.

    But they do. 



  • @dhromed said:

    @snoofle said:

    Why do big companies assume that 2 experienced engineers can compensate for 500 inept idiots?


    Wait.

    But they do.

    Nonsense.  500 idiots churn out way more stupidity than 2 experienced engineers can repair.  Unless the engineers have admin permissions to the version control system... 



  • It goes both ways.  They also believe that 500 inept idiots (paid minimum wage) can replace 2 experienced engineers, and round and round we go!

     



  • @Critter said:

    It goes both ways.  They also believe that 500 inept idiots (paid minimum wage) can replace 2 experienced engineers, and round and round we go!

     

     

    No, I think they believe that 2 inept idiots can replace 2 experienced engineers. 



  • @skippy said:

     

    No, I think they believe that 2 inept idiots can replace 2 experienced engineers. 

    I've seen that happen, when an experienced senior programmer leaves and the company hires a green junior programmer to replace them. Sure it's cheaper, but there's a reason for that...



  • @skippy said:

    @Critter said:

    It goes both ways.  They also believe that 500 inept idiots (paid minimum wage) can replace 2 experienced engineers, and round and round we go!

     

     

    No, I think they believe that 2 inept idiots can replace 2 experienced engineers. 

    Or that 2 inept idiots can replace 10 experienced developers. 


Log in to reply
 

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