date | 2001-02-09:14:13 |
Software |
There's a great deal in Chapter 24 of Stroustoup's The C++ Programming Language that's of value, but its very hard to read, and I think I understand why now that I've read it again recently. The problem is that he mixes the abstract and the concrete together in a jumble, passing from one to the other within a single paragraph or even a single sentence. If you have some prior grasp of the abstractions he's presenting this is a style that allows him enormous expressive depth, but for beginners its almost unreadable. One of the most important abstractions he uses, entangled in all the concretes, is what I call the Principle of Verisimilitude: the idea that the structure of the code ought to be as close to the structure of the reality it represents as possible. This is an idea that is treated with scorn in most OO books, dismissed with chest-thumping about how the implementation has to be free to vary at whim of the designer, and domain concepts should be clearly distinguished from implementation concepts. This is true up to a point--there is such a thing as an implementation detail. But if your users want your software to represent left handed widgets, and your software nowhere contains anything that can be isolated and pointed to and labelled "left handed widget representation" then the odds are good you have a problem. More than one, in fact. The first problem is that you aren't going to know what it is you're representing. Maybe it's what the user wants, maybe not. The second problem is that whatever you're representing, its representation is going to be distributed mysteriously and probably largely implicitly throughout the code. This leads to the code rapidly becoming unmaintainable, because any time a maintenance coder changes something the implicit representation of some core concept may break. Add to these the impossibility of documenting the representation, the inability to figure out what to change when you need to change a behavior, the dangling dependencies, and so on, and you'll see that this is a very bad idea. Thinking is hard, and one particularly hard kind of thinking is mapping, in which you take a concept from one hierarchy and map it to some combination of concepts from another hierarchy. The great value of OO programming is that when the design is done well, very little mapping is required, at least at the level of public interfaces. This eases comunicaiton and verification of designs, as well as making the code more flexible and maintainable. |
Reading |
A fortuitous combination of some bonus points and Terry Pratchet's The Fifth Elephant appearing in paperback have determined my light reading for bit. Pratchet is worth reading--though as uneven as you'd expect any series of books running into the double digits to be, the Discworld stories taken as a whole are wonderful, and the very best, like Reaper Man and Lords and Ladies go far beyond the nominal limitations of genre fiction. I'm reading the kids the City Watch books as part of their bedtime reading--we're currently on Feet of Clay--and finding that the books are literally children's literature. They have all the elements of literature, but done in big print. The characters, while broadly drawn, are still quite recognizable in life. When I was a soldier I knew a corporal who was the living image of Corporal Nobs--his nickname was "the Whirling Dirtbag." So the books serve as an excellent way of showing the kids something of the internal workings of literature, how the characters are portrayed, how the plot works through them, what the functions of metaphor are. The not-very-sub text on the role of stories in many of the stories helps a lot: Alex knows what a metaphor is because Lupine Wonse was killed by one, and Carot Ironfounderson's inability to grasp them helps the kids see clearly what they are. One of the things that makes Carot funny is that he can't understand metaphor, and the reader can. There's nothing like humor of focus the attention on something, to make it memorable. I like the City Watch books in particular because I share Vimes' distaste for kings, and his thoughts like, "Humans had a fundamental design flaw: a tendency to bend at the knees" get the point across nicely. Pratchet's libertarianism can come across too strongly at times, as it does in Interesting Times, but his deep and sincere belief in the value of liberty for all people is a pervasive positive influence on his work. These books, which deal in part with interspecies relations, do a good job as well of portraying the value of diversity while not ever becoming sermons. I have to wonder if Pratchett will ever exhaust the Discworld. The Truth is his 25th book in that setting, and while he has admittedly a whole world to play in, I can imagine him getting stale. Yet he's come a long way from the mediocre The Colour of Magic and The Light Fantastic--I read Mort before either of those, and I think if I'd've read them first I wouldn't have read any more, which would have been a great pity. Pratchet is in part a testament to the value of volume--you can't do it perfectly every time, but if you do it a lot, then you have a better chance of getting it right. One of the common characteristics of genius is volume: most great writers are remembered for a very small fraction of their work, and are distinguished in part from their fellows by the quantity of work they turn out. This may have to do with simple statistics, or it a product of the need that drives them. But I think at least a few of Pratchet's books will stand the test of time. |