The Rambam writes [Yesodei HaTorah 5-1]:
כל בית ישראל מצווין על קדוש השם הגדול הזה שנאמר ונקדשתי בתוך בני ישראל ומוזהרין שלא לחללו שנאמר ולא תחללו את שם קדשי כיצד כשיעמוד עובד כוכבים ויאנוס את ישראל לעבור על אחת מכל מצות האמורות בתורה או יהרגנו יעבור ואל יהרג שנאמר במצות אשר יעשה אותם האדם וחי בהם וחי בהם ולא שימות בהם ואם מת ולא עבר הרי זה מתחייב בנפשו:
The entire house of Israel are commanded regarding the sanctification of [God's] great name, as [Leviticus 22:32] states: "And I shall be sanctified amidst the children of Israel." Also, they are warned against desecrating [His holy name], as [the above verse] states: "And they shall not desecrate My holy name."
What is implied? Should a gentile arise and force a Jew to violate one of the Torah's commandments at the pain of death, he should violate the commandment rather than be killed, because [Leviticus 18:5] states concerning the mitzvot: "which a man will perform and live by them." [They were given so that] one may live by them and not die because of them. If a person dies rather than transgress, he is held accountable for his life.
When you read this - you can't help but be astonished at the turn events. The Rambam first tells us that we must be מקדש שם שמים i.e. die for Torah. The he says "כיצד" and presents a scenario where he DOESN'T have to die and is not even ALLOWED to die? Only in the NEXT Halacha does he tell us when one has to sacrifice his life. Why didn't the Rambam first tell us when to sacrifice our lives which would follow from how he opened up the Halacha??!