(DRAFT)
Programming with expectations is a new way of programming. There are several kinds of programming:
- programming by accident (many people are here)
- programming by theorem (people want to be here, almost no one is)
- genetic/evolutionary programming (people do it, but no one is sure if it’s right)
- programming by contract (somewhat widely used, to greatly varying degrees of success)
- programming with expectations (my new entry)
Note that I’ve left out how people organize code (structural, object) or coordinate (procedural, event-driven, message-passing). Those are orthogonal to the central conceit, which is “writing programs that work correctly”.
Programming by accident refers to how the vast majority of software engineers work. They write some code, run it, and poke and prod at it until it seems to be working (and sometimes they just write code and pray). This is a fairly insulting term, but also fairly accurate. If you use a debugger while writing code, then you are following this pattern.
Programming by theorem assumes that you can write code to a theoretical proof. A fair amount of work was done on this approach starting in the 1960’s, and while it had good spin-offs, as a programming discipline, it has pretty much been useless. Almost no programs are written this way. Note that most (all?) unit tests really do not fall into this category. If you needed a unit test, then you didn’t have theoretically sound code in the first place. Unit tests belong in the first category.
Genetic/evolutionary programming is the idea that we will grow our code by setting up a set of constraints and having our code be discovered through endless generations of semi-random permutation, loosely following biological genetics principles. It too has had some interesting spin-offs, but has failed as a widely used discipline of programming. Almost no programs are written this way.
Programming by contract was a response to the failure of programming by theorem, and was founded on the idea that if each piece of code had a contract that it enforced with all callers, then life would be good and we would have solid, dependable programs.
More stuff here.