Object Oriented Torah

Several years ago one of my livejournal friends reb_moyshe wrote a post about how object-oriented programming reminds him structure of Torah.
Since I started developing in .Net and Java, I think, I got the point. And I think, I got also the differences between programming and Torah object-orientation.

Let’s try some basic example.
Noahide laws have 7 basic rules.
Let’s create a class for it:

class NoahideLaws ()
{
	public int NO_PUNISHMENT = 0;
	public int PUNISHMENT = 1;
	public int Idolatry(Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public int Murder (Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public int Theft(Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public int SexualImmorality(Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public int Blasphemy(Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public int EatingFleshTakenFromAnAnimalWhileItIsStillAlive(Boolean isDone)
   	{
   		if (isDone)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
	public in EstablishmentOfCourtsOfLaw(Boolean isDone)
   	{
   		if (isDone)
      		return NO_PUNISHMENT;
      	return PUNISHMENT;
   	}
}

Later this law was extended and applied only on Jews.

class TenCommandments extends NoahideLaws ()
{
	private Boolean _isJewish = false;
	public void setNation(Boolean isJewish)	{
		_isJewish = isJewish;
	}
	
	public int KeepShabbat(Boolean isDone)
   	{
   		if (isDone || !_isJewish)
      		return NO_PUNISHMENT;
      	return PUNISHMENT;
   	}
   	
   	public int HonourFatherAndMother(Boolean isDone)
   	{
   		if (isDone || !_isJewish)
      		return NO_PUNISHMENT;
      	return PUNISHMENT;
   	}
   	
   	public int FalseWitness(Boolean isDone)
   	{
   		if (isDone && _isJewish)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
   	
	public int CovetNeighborsHouse(Boolean isDone)
   	{
   		if (isDone && _isJewish)
      		return PUNISHMENT;
      	return NO_PUNISHMENT;
   	}
}

General difference between Torah and programming is that nobody can override or deprecate any part of the code.
Torah code can be only extended following certain rules.

Leave a Reply

%d bloggers like this: