Here's an interesting controversy. In I Don't Like Your Examples! Steven Feuerstein explains why he used controversial political examples in a technical O'Reilly book on Oracle PL/SQL Programming and shares some reader reaction.
Obviously there's no legal issue here: in a free country an author can be political even in a technical reference book. And, equally obviously, political examples pose a commercial issue for a publisher: will a reference/instruction book with 'interesting' examples sell better because the reader stays awake (or because people buy it for the notoriety), or sell worse because those who find the examples distasteful will avoid it? (There's also a question of editorial principle—how much freedom should authors be entitled to have? It's not obvious to me that the answer is the same for technical books in a series as for a novelist or a polemicist, although in the hands of an enlightened and brave publisher it might be. I wonder what Theresa Nielsen Hayden thinks about this…)
But there's also a moral, or at least aesthetic, issue as to whether it's meet to introduce suggestions that Henery Kissinger is a war criminal for bombing Cambodia, CEOs are paid too much, or the gun lobby is too strong. And that's the question which really interests me. In his article Mr. Feuerstein quotes feedback from readers, or might-have-been readers, who think inserting politics into programming examples is at least icky, maybe gross.
Having thought hard about it for several seconds, it turns out that on this last question I have no doubt at all: it is proper, even admirable, to witness one's strongly held beliefs about the society we share in any book you write, and in most (but not all1) daily activities, especially in circumstances where your listener/reader is able to walk away or put down the tome. If this hurts your sales, that's your problem. In general though, I prefer my fellow citizens to be engaged, not passive, committed not apathetic, even if it should happen we don't agree.
1 Which activities? Depends. Class is a bad time for students (or professors) to stand up and read agitprop, but a good time for students to wear political t-shirts. See also More on Civility.