It's often said that software engineers have no code of ethics. This is untrue. For example, no respectable software engineer would ever consent to writing a function called DestroyBaghdad().
Professional ethics would compel them to instead write a function DestroyCity, to which "Baghdad" could be passed as a parameter.
> Professional ethics would compel them to instead write a function DestroyCity, to which "Baghdad" could be passed as a parameter.
A common rule in the profession would be that that would only be true after they’d coded city-specific destruction functions for two previous cities, otherwise it would be premature abstraction.
Sometimes you might want to know success though. So...
status = destroyCity(&city);
This way, because assumingely we may mutate city in some way we’ll still have what comes after to examine, we didn’t pass the name or Od of the city, but the location itself. And we’ll know if overall our destruction worked. It’s also better if you code to MIRSA destruction.
A programmer is drafted by the military and ordered to write the software for a city destroying weapon. Given the freedom to choose the implementation language, he chooses Javascript. The user enters the city to be destroyed, which is passed to the Function destroyCity().
The General returns from the weapon's fist use in battle furious. "We fired your damn weapon at Bahgdad, and the city's still there! What's going on?"
"I think I know" says the programmer. Javascript passes it's parameters by value, not by reference."
Depending on the language the ampersand could mean by copy or by reference. I suspect the commentor wants by reference, since they want to examine it later.
> Depending on the language the ampersand could mean by copy or by reference
Yikes. Which languages use ampersand to signal passing by value? That's a massive footgun if I'm ever cargo-culting my way through writing some code in one of those languages for the first time.
I generally learn a new language by cargo-culting my way through a few small-ish programs. I wouldn't put anything in production in a language that I didn't adequately understand, but I could certainly waste a bunch of time debugging if I got the meaning of & flipped.
Professional ethics would compel them to instead write a function DestroyCity, to which "Baghdad" could be passed as a parameter.
https://en.wikiquote.org/wiki/Nathaniel_Borenstein