Have you ever noticed that code follows some basic patterns? JUnit uses Setup(), Test(), Teardown().
I’ve playfully mixed writing and coding below.
//[Play about A Monarch's Destiny, in three acts]
Public KingdomFuture tellTheTaleOfMyRule(Kingdom landMyFatherLeftMe)
{
//[1st Act: Build Drama]
Vassal mySubjects = SoliloquyAboutMyKingdom.getMyPeasants();
Boolean mySubjectsLoyalty = testOfLoyalty(mySubject);
Vassal theCaptainOfTheGuard = SoliloquyAboutMyKingdom.getMyTrustedRightHandMan();
Boolean myTrustedServantsLoyalty = testOfLoyalty(theCaptainOfTheGuard);
KingdomFuture historysTaleOfMyRule = KingdomFuture.UNDECIDED;
//[2nd Act: Drama plays out]
if ( mySubjectsLoyalty == TRUE
&& myTrustedServantsLoyalty == TRUE)
{
HeapPraiseUpon(theCaptainOfTheGuard);
historysTaleOfMyRule = ExpandKingdomByForce(mySubjects);
}
if ( mySubjectsLoyalty == FALSE
&& myTrustedServantsLoyalty == FALSE)
{
ArrestTraitor(theCaptainOfTheGuard);
historysTaleOfMyRule = ImposeDispicableLaws(mySubjects);
}
//[3rd Act: resolve drama]
if ( deceptionHiddenSuccessfully(theCaptainOfTheGuard) )
{
return oldRulerOverthrown;
}
else
{
return historysTaleOfMyRule;
}
}