Remotely Over-Cast



  • I'm currently maintaining an application written by a former co-worker. The entire application is a huge WTF and if I had enough time I would re-write it from scratch. It makes use of .NET Remoting, which is a great thing if you do it right. However, my co-worker didn't quite grasp the concept...

    Normally you'd have an interface exposed by a service and the client would call the exposed methods. My co-worker must have considered the process of creating a proper interface too time consuming, so he invented an interface which consists of exactly ONE method: "ExecuteCommand". This method takes a string containing the command, then a DataSet (!!) reference for the result and an array of string (!!) parameters for the command to be executed. It also returns an int value that informs about success/failure.

    The service implements this method in the form of a huge switch-statement that executes methods (of a separate class containing only these methods - does that ring a bell?) depending on the command string. There are about 50 commands handled by this switch statement. Every case block contains a return statement for the success/failure-result. So there are about 50 return statements saying ... (*drumroll*) ...

    <font face="courier new,courier">return (int)0;</font>
     



  • Sounds suspiciously much like a layer on top of ODBC: send an SQL command, get a list of strings back...



  • @TGV said:

    Sounds suspiciously much like a layer on top of ODBC: send an SQL command, get a list of strings back...

     

    While most of the commands actually perform database queries, the command string is not the actual SQL command. Also, the logic behind each command may contain several calls to the database. If it had just passed SQL commands through to the database, I'd have definitely refused to maintain that application...



  • I have to do a client-service app myself, and I actually thought about a similiar approach myself, as all IPC I have ever seen was a little of Windows messaging.

    Thank god there is http://www.stackoverflow.com, google, and a competent coworker here to get me started ;-)

     And no, I wont do the above, I'll use WCF.



  •  Hey, there are good reasons to do that!

    What if the compiler interperted the zero as a boolean or float?


Log in to reply