Wednesday, May 18, 2005

MDA and code generation

Context CurrencyOption::currentPrice::get
 "WebServiceDispatcher.find
  ('\"Options Price Info\").execute("+
  ("self.currency.country+","+
    self.putOrCall = OptionKind::#put ?
      "put" : "call"+","+
    self.americanOrEuropean =
      ExerciseKind::#american? "1" : "2"+","+
    self.expirationDate+")"


The above code fragment appears in Model Driven Architecture and is an example of an action statement that can be used to generate code for an operation.

I could be wrong here, but doesn't this call into question the whole premise of using MDA to automate the code generation and produce error-free code? The generated code would only be error-free in as much as the above code is error-free (ignoring for the time being the fact that it would give any self-respecting Perl script a run for its money in the Complex Code Sweepstakes). In effect, you are simply moving the debugging effort up a level, from the Java layer to the action statement layer.

I am veering around to the view that MDA will only go so far; there will always be some code that will have to be manually written (whether you do it at the action statement level or at the programming language level), unless the problem is so well understood that code generation is a breeze.