Painting yourself into a corner



  • Like I've mentioned in the past I'm currently fixing a C#/.NET CRM application written by a long gone "programmer" of ours, whom we will be referring to as Jack. Jack is the type of coder that will deliver what the customer asks for, not what the customer wants. He is the type of person who considers working code production code, no matter how brittle or short-sighted it may be. In sort you don't want to be the developer that has to maintain his code.

    First a bit of background info for those not familiar with .NET, since the app makes extensive use of datatables and bindignsources. A DataTable is essentially a virtual database table (in memory) whose data is derived from one or more actual database tables (on disk). This can be quite handy, since you can very easily tie the DataTable to the GUI. What decides what data will be put in the DataTable is an object called a TableAdapter which you configure via Visual Studio's GUI (look ma, I can code without typing). You create SQL queries for your TableAdapter each one of which is encapsulated in a method. So if you wanted to fill your "customers" DataTable will the data from your "Customers" database table, you'd call the TableAdapter's Fill() method. If you wanted to populate the DataTable only with a single customer, you'd call the TableAdapter's FillByCustomerID() method and so and so forth.

    One of the things that Jack had to build in this app is a bunch of reports
    that list results based on certain search criteria the user may or may
    not specify. The best way to describe the current situation is to
    describe the route he took. I wasn't there when he was building it, but
    knowing the guy and judging from the evidence, I have a pretty good idea
    of what happened. 

    What the customer asked for was a report of their customers that could be filtered by criteria like name, location, date of addition, etc, etc. So Jack built a form with all the necessary controls and then added a query to the relevant TableAdapter that got a list of all the customers. He then added another query for when the list of customers is filtered by location and added an if statement in the code to decide which TableAdapter method to call (Fill or FillByLocation). That's one search criteria taken care of. He then proceeded to the next one which was a name search. He added another query to filter by name (FillByName) but then realized that you couldn't filter by name and location so he added yet another query for that (FillByNameLocation). He added the relevant conditionals in his code. 

    Jack then went on to tackle the third search field at which point it must have finally registered that he was digging himself into a hole. He could keep following this tactic and write <number of criteria>^2 queries along with a ridiculous amount of conditional statements to decide which one to use. Or he could rip out the whole thing and find a different solution. He decided to go with option #3 which was to deliver the form with some of the search criteria hooked up to thin air and bugger off to go mess someone else's codebase. More than a year later (!) the job of fixing the form landed on my lap as a bug fix request at which point I had to reengineer the whole thing jut to get a couple of form controls working.

    The best part of it all is that when the guy first started working here, the boss asked for my opinion on his work. I told him, and I quote "I haven't even seen students deliver code like this". I was chastised for "talking about my colleague like that". Apparently being hired by my company makes him family.

    Oh, well, at least he's gone and can't fuck up anything else here...

     

     



  • @DOA said:

    Oh, well, at least he's gone and can't fuck up anything else here...

     

     

    Shouldn't we start some "coders wall of shame" with names on it to avoid?



  • @DOA said:

    Like I've mentioned in the past I'm currently fixing a C#/.NET CRM application written by a long gone "programmer" of ours, whom we will be referring to as Jack. Jack is the type of coder that will deliver what the customer asks for, not what the customer wants. He is the type of person who considers working code production code, no matter how brittle or short-sighted it may be. In sort you don't want to be the developer that has to maintain his code.

    First a bit of background info for those not familiar with .NET, since the app makes extensive use of datatables and bindignsources. A DataTable is essentially a virtual database table (in memory) whose data is derived from one or more actual database tables (on disk). This can be quite handy, since you can very easily tie the DataTable to the GUI. What decides what data will be put in the DataTable is an object called a TableAdapter which you configure via Visual Studio's GUI (look ma, I can code without typing). You create SQL queries for your TableAdapter each one of which is encapsulated in a method. So if you wanted to fill your "customers" DataTable will the data from your "Customers" database table, you'd call the TableAdapter's Fill() method. If you wanted to populate the DataTable only with a single customer, you'd call the TableAdapter's FillByCustomerID() method and so and so forth.

    One of the things that Jack had to build in this app is a bunch of reports that list results based on certain search criteria the user may or may not specify. The best way to describe the current situation is to describe the route he took. I wasn't there when he was building it, but knowing the guy and judging from the evidence, I have a pretty good idea of what happened. 

    What the customer asked for was a report of their customers that could be filtered by criteria like name, location, date of addition, etc, etc. So Jack built a form with all the necessary controls and then added a query to the relevant TableAdapter that got a list of all the customers. He then added another query for when the list of customers is filtered by location and added an if statement in the code to decide which TableAdapter method to call (Fill or FillByLocation). That's one search criteria taken care of. He then proceeded to the next one which was a name search. He added another query to filter by name (FillByName) but then realized that you couldn't filter by name and location so he added yet another query for that (FillByNameLocation). He added the relevant conditionals in his code. 

    Jack then went on to tackle the third search field at which point it must have finally registered that he was digging himself into a hole. He could keep following this tactic and write <number of criteria>^2 queries along with a ridiculous amount of conditional statements to decide which one to use. Or he could rip out the whole thing and find a different solution. He decided to go with option #3 which was to deliver the form with some of the search criteria hooked up to thin air and bugger off to go mess someone else's codebase. More than a year later (!) the job of fixing the form landed on my lap as a bug fix request at which point I had to reengineer the whole thing jut to get a couple of form controls working.

    The best part of it all is that when the guy first started working here, the boss asked for my opinion on his work. I told him, and I quote "I haven't even seen students deliver code like this". I was chastised for "talking about my colleague like that". Apparently being hired by my company makes him family.

    Oh, well, at least he's gone and can't fuck up anything else here...

    Nobody ever thought of making the parameters nullable?  The strongly types DataTables that the GUI builds are really very useful.  If done right, strongly typed DataSets are not a WTF.



  • @DOA said:

    The best part of it all is that when the guy first started working here, the boss asked for my opinion on his work. I told him, and I quote "I haven't even seen students deliver code like this". I was chastised for "talking about my colleague like that". Apparently being hired by my company makes him family.
     

    TRWTF is your boss asking for your opinion and then chastising you for it.



  • @mott555 said:

    TRWTF is your boss asking for your opinion and then chastising you for it.

     

     

    You're allowed to have whatever opinion you want, as long as it matches the boss's opinion.



  • In that case you'll have to ask back:
    "Do you want an honest answer or a polite answer?" 🙂

    Usually the boss does not need either of those when you say that



  • @DOA said:

    The best part of it all is that when the guy first started working here, the boss asked for my opinion on his work. I told him, and I quote "I haven't even seen students deliver code like this". I was chastised for "talking about my colleague like that". Apparently being hired by my company makes him family.
     

    Pfft, I bet he took it personally because he hired him, and he was dumbstruck that you dared to (honestly) imply that he hired someone who have even lower quality than college students, thus by insulting Jack, you inadvertently insulted your boss.

    Note I'm not saying what you said was wrong. Much to the contrary: I am saying your boss doesn't have a pair of balls and should be banned from his mommy and daddy's modem.



  •  @mott555 said:

    TRWTF is your boss asking for your opinion and then chastising you for it.

    I regularly get either that, or something to that effect.

    The last time was about a new project he though of. He asked me what I thought about it. I told him it was doomed to failure, and explained why. I got the reply "Your just being negative. Your always negative. I'll go find someone else.".



  • @Mole said:

     @mott555 said:

    TRWTF is your boss asking for your opinion and then chastising you for it.

    I regularly get either that, or something to that effect.

    The last time was about a new project he though of. He asked me what I thought about it. I told him it was doomed to failure, and explained why. I got the reply "Your just being negative. Your always negative. I'll go find someone else.".

    I say the same thing to people and then they look at me funny when the project in question is deemed a failure and I start laughing and going "told you so!". Did that particular project fail perchance?



  • @The_Assimilator said:

    I say the same thing to people and then they look at me funny when the project in question is deemed a failure and I start laughing and going "told you so!". Did that particular project fail perchance?

    While that may be satisfying, I don't think it really helps in any way. If all you achieved that next time they'll go discuss the project with someone who just says "yes" and "great", then you're even more screwed.

    To get my misgivings across, I try to explain that I understand that a certain project is important or interesting, but that there are major issues or risks. If I don't see why you would want a project at all, I try to find that out first. I try to indicate what it would take to mediate the issues so he understands why I'm being negative (why is it always a he? women bosses seem to listen better, I think). And I try to get across: I'm being critical exactly because I want it to be a succes.

    Of course it depends a bit on how braindead the project in question is. Some projects/people just can't be saved.



  • @b-redeker said:

    @The_Assimilator said:

    I say the same thing to people and then they look at me funny when the project in question is deemed a failure and I start laughing and going "told you so!". Did that particular project fail perchance?

    While that may be satisfying, I don't think it really helps in any way. If all you achieved that next time they'll go discuss the project with someone who just says "yes" and "great", then you're even more screwed.

    To get my misgivings across, I try to explain that I understand that a certain project is important or interesting, but that there are major issues or risks. If I don't see why you would want a project at all, I try to find that out first. I try to indicate what it would take to mediate the issues so he understands why I'm being negative (why is it always a he? women bosses seem to listen better, I think). And I try to get across: I'm being critical exactly because I want it to be a succes.

    Of course it depends a bit on how braindead the project in question is. Some projects/people just can't be saved.

    Of course I try to explain why the project is going to go down in flames, why it should be done differently, etc. But if people aren't willing to listen to my input, then they don't get to complain when their project does fail and I laugh at them.


Log in to reply
 

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