Sister Miriam Joseph Rauh’s book “The Trivium: The Liberal Arts of Logic, Grammar, and Rhetoric“, is one of the best books on programming. But it’s not about programming – it’s about the Trivium.
What is the Trivium? Its the first three subjects of classical education. Grammar is all about languages and their rules. Logic is well, logic. And Rhetoric is about persuading people. The third topic may not relate to programming (maybe in meetings), but the first two are crucial.
This work puts into words a whole swath of thought that you take for granted while you write your programs.
One little snippet that illustrates the point is a section called “Creating Symbols from Reality: Generation of a Concept”
First the external senses-sight, hearing, touch, smell, taste-operate on an object present before us and produce a percept.
Can I describe my program well without observing it’s behavior? Sure I can throw some code up, but the code won’t be very good unless I observe it’s behavior with tests and make adjustments.
The internal senses, primarily the imagination, produce a phantasm or mental image of the individual object perceived, and this phantasm is retained and can be reproduced at will in the absence of the object.
The definitions of our classes which we use to create individual instances, can only be defined with respect to the behaviors we observe in our tests (manual or automated), or they are the subject of our imaginations.
Sister Miriam Joseph goes on to state that the external senses (our tests) aren’t the only ones used to create a class (definition or any instance of it).
There are four internal senses: the imagination, the sensuous memory, the common or central or synthesizing sense, and instinct. The intellect through abstraction produces the concept. The imagination is the meeting ground between the senses and the intellect. From the phantasms in the imagination, the intellect abstracts that which is common and necessary to all the phantasms of similar objects… this is the essence.
I almost see our upfront design is our imagination, our tests are our senses, and we use our intellect to create the abstractions (classes) that make our design and tests agree.
She comes up with some definitions:
Percept: the image created by the external sense upon encountering reality.
Phantasm: the mental image created by the internal sense, primarily the imagination.
Concept: the abstraction created by the intellect through the recognition of the essence.
When we write classes, what we have in mind to create is the phantasm, the finished class is the concept, and the percept is the result of our tests. If our tests create a percept that conflicts with the phantasm, then the concept is incorrect, our tests are incorrect, or our imagination of it is wrong (change the design). This is the core of TDD.
I’m going to be taking notes and posting as I go through this book. When you read it, she’s using so many words that programmers use all the time. I’ve come to realize that programming is a liberal art. Programming is the application of grammar and logic to solve problems.