Friday, March 29, 2019

Box Oriented Programming (BOP)

Concentric Hierarchy

In English, "box" (like "ox"), registers a container, likely a cube, but even more likely the generic hexahedron of all right angles.  Could be brick shaped, oblong.

A useful exercise in a literature class, when introducing "namespace" as a concept, would be to say something like:  for the purposes of today, we're going to use "box" to mean "any polyhedron" (teacher holds up a tetrahedron as a demo "box").

That hardly seems a stretch as what's special about a box is it's a rigid container with well defined edges, corners and faces.  A box is a polyhedron already.  The only change we're making is we're enlarging "box" to mean rigid shapes with potentially fewer or more corners, edges, facets.

What we've really accomplished, with all this talk, is rescuing the generic "object" of Object Oriented Programming, from being something flat and UML like.  Not that I'm against flat, 2D representations of objects as circles or little clouds (flat, curvilinear).  I'm OK with flat.

But at the end of the day, we need to get off the plane and be true containers, little boxes.

Then of course we know that boxes may contain boxes.  Boxes come in flavors.  Indeed, the "hat box" was already round.  Those are cylindrical.  When our family lived in Rome, we could buy fresh milk in tetrahedrons.  The cartons were easy to make, and sturdy.  The plastic bag system was less secure.

Some of you may be thinking "Russian Dolls" when I talk about boxes inside of boxes, and that would be fine.  We're in the realm of compartmentation, the "division into separate sections or units" by whatever means.  Architecture.  Cell biology.  Mitochondria live inside the cell (city) wall.

In Minecraft, the worlds are pretty ruthlessly XYZ, meaning boxes of the hexahedron kind rule.  Then students jump into an Escher like floating kingdom, an underwater oasis populated with planaria.  Flatworms I guess they are.  Instead of XYZ, it's "IVM" as we say in American literature.

Remember this is a literature class, and we're using "box" in place of "polyhedron" to become more accustomed to the "namespace" idea, which translates as "shoptalk" or even "dialect".  The problem with "dialect", often, is that we expect different pronunciations, whereas in some cases it's more a matter of vocabulary.

Now go back to OOP with your boxes and talk about "types" as before.  The "string type" hatches string instances.  Those types that hatch instances, such as string, also form a type:  the "type" type (we're talking Python now, but any OOP language will be similar).