Samurai Principle

Return victorious, or not at all.

A SoftwareDevelopmentGuideline; as applied to JavaLanguage and PythonLanguage, this means you should either complete your contract and return a valid result, or throw an exception.

Sometimes this is understood to mean not to return a null or a NullObject, since that would be to return in defeat. See NoNullBeyondMethodScope for more on this view.

Others relate this to DaveAbrahams?' "strong" ExceptionGuarantee; the result of any operation should be either the intended target state ('victorious') or the original state ('not at all').

See also WithYourShieldOrOnIt for the Spartan version, or DoOrDie for the Perl version.


Some software implementations of TSP are a CargoCult situation...

(The inside joke: Python's django.db treats "record not found" as a catastrophic error, of the same ken as "your hard drive exploded". The "recommended" way to recover is "except MyModel?.DoesNotExist?". This then leads to the risk of sloppy exception handling. The ORM should simply proffer a method, .default(thing), where thing is either None, a NullObject, or a lambda providing some other alternative.)


The samurai had a strict code of behavior (bushido) surrounding all aspects of life, not just battle. Failure to uphold the code would result in death with dishonor. Personal failure while within the code would probably result in your being allowed to kill yourself honorably (seppuku, to cut one's own stomach). The same applied to samurai (noble) women, who were allowed to cut their own neck.

"...if you are slain in battle, you should be resolved to have your corpse facing the enemy." - YamamotoTsunetomo

However, the Japanese weren't necessarily as obsessed with Bushido as is commonly thought; there's a good (but long) article on actual Japanese attitudes to Bushido here: http://www.ejmas.com/jalt/jaltart_friday_0301.htm -- SteveCooper

It's an odd thing that we carefully distinguish the different cities of ancient Greece, but treat all medieval Japanese as if they were the same. :)

Not odd at all. The Japanese have had relatively little impact on our heritage. (For suitable values of "our"...)

That's a very likely explanation, but also take into account that Japan had wars until only one Shogun ruled all of Japan, therefore only one way of thinking prevailed, while Greece simply expanded and was invaded by others, so no city had the opportunity to rewrite history.


From Chapter 19 of "NADA THE LILY" by H. Rider Haggard (http://www.bookrags.com/books/ndlly/)
"They went singing, after the king had looked upon them and bidden them 'return victorious or not at all.' Their number was so great that from the hour of dawn till the sun was high in the heavens they passed the gates of the kraal like countless herds of cattle..."


This seem even more to the point in Perl, since throwing an exception in Perl is to let the code "die". /JpL


CategoryStory | CategoryException


EditText of this page (last edited September 6, 2010) or FindPage with title or text search