It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure
"It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter." - Nathaniel Borenstein
The humor in this joke lies in the failed expectations of the reader. The reader is assuming that the ethics that the programmer is trained in are the same ethics that all of the rest of humans use, things like "Don't kill people", or "Be nice to people".
Instead the jokester is talking about coding ethics, which includes (among other, more normal ethical concerns) coding best practices, which are sets of rules that when followed will allow the software engineer to produce quality code in a manner that is fast and consistent.
The statement is not entirely deceptive, however any normal person wouldn't recognize where it was going until it got there. Therein lies the humor.