designates my notes. / designates important.
A “classic” from 1999. Lots of interesting “roots” of some now commonly known programming principles. I was particularly gleeful to hear the lauding of plain text files - my preferred way of storing almost everything. I think even JSON is mentioned alongside the more ubiquitous XML in 1999.
Source control, particularly since git/github, is now defacto. The authors were way ahead of this fact. Similarly they mention something dangerously similar to test driven design, modern buzzwords sure, but still a great way to work. There are also a lot of general how to deal with day-to-day problems programmers face, like customer spec sheets, deadlines, and communication.
Interesting and breezy read, would recommend as light reading to any programmer.
maintenance is not a discrete activity, but a routine part of the entire development process.
Tip 11: DRY—Don’t Repeat Yourself
Get into the habit of being constantly critical of your code. Look for any opportunities to reorganize it to improve its structure and orthogonality.
we suggest that every module have its own unit test built into its code, and that these tests be performed automatically as part of the regular build process
Use basic “tracer” code to get functionality proven, then flesh it out.
The conventional alternative is a kind of heavy engineering approach: code is divided into modules, which are coded in a vacuum. Modules are combined into subassemblies, which are then further combined, until one day you have a complete application. Only then can the application as a whole be presented to the user and tested.
The most daunting piece of paper is the one with nothing written on it.
Tip 23: Always Use Source Code Control
Always. Even if you are a single-person team on a one-week project. Even if it’s a “throw-away” prototype. Even if the stuff you’re working on isn’t source code. Make sure that everything is under source code control—documentation, phone number lists, memos to vendors, makefiles, build and release procedures, that little shell script that burns the CD master—everything. We routinely use source code control on just about everything we type (including the text of this book). Even if we’re not working on a project, our day-to-day work is secured in a repository.
Preprocessors
For C and C++, you may want to investigate Nana [URL 18]. Nana doesn’t handle inheritance, but it does use the debugger at runtime to monitor assertions in a novel way.
Have you noticed that sometimes other people can detect that things aren’t well with you before you’re aware of the problem yourself? It’s the same with other people’s code. If something is starting to go awry with one of our programs, sometimes it is a library routine that catches it first.
All errors give you information.
Tip 32: Crash Early
There is a luxury in self-reproach. When we blame ourselves we feel no one else has a right to blame us. -Oscar Wilde, The Picture of Dorian Gray
Tip 33: If It Can’t Happen, Use Assertions to Ensure That It Won’t
Tip 36: Minimize Coupling Between Modules (Law of Demeter)
As with any technique, you must balance the pros and cons for your particular application. In database schema design it is common practice to “denormalize” the schema for a performance improvement: to violate the rules of normalization in exchange for speed. A similar tradeoff can be made here as well. In fact, by reversing the Law of Demeter and tightly coupling several modules, you may realize an important performance gain. As long as it is well known and acceptable for those modules to be coupled, your design is fine.
First, we want to make our systems highly configurable. Not just things such as screen colors and prompt text, but deeply ingrained items such as the choice of algorithms, database products, middleware technology, and user-interface style. These items should be implemented as configuration options, not through integration or engineering.
Tip 37: Configure, Don’t Integrate
Model. The abstract data model representing the target object. The model has no direct knowledge of any views or controllers.
View. A way to interpret the model. It subscribes to changes in the model and logical events from the controller.
Controller. A way to control the view and provide the model with new data. It publishes events to both the model and the view.
Document your assumptions.
test your assumptions as well.
Don’t be a slave to history. Don’t let existing code dictate future code. All code can be replaced if it is no longer appropriate. Even within one program, don’t let what you’ve already done constrain what you do next—be ready to refactor (see Refactoring).
If you’re not sure how long your code will take, or how much memory it will use, try running it, varying the input record count or whatever is likely to impact the runtime. Then plot the results. You should soon get a good idea of the shape of the curve.
Tip 46: Test Your Estimates
Tip 47: Refactor Early, Refactor Often
At its heart, refactoring is redesign. Anything that you or others on your team designed can be redesigned in light of new facts, deeper understandings, changing requirements, and so on.
Take short, deliberate steps: move a field from one class to another, fuse two similar methods into a superclass. Refactoring often involves making many localized changes that result in a larger-scale change. If you keep your steps small, and test after each step, you will avoid prolonged debugging.
Tests help with refactoring.
“Only an employee’s supervisors and the personnel department may view that employee’s records.” is a vague specification. It could be hard-coded, but should be reinterpreted as an example of a broader specification: “An employee record may be viewed only by a nominated group of people.” The latter will likely lead to an access control mechanism that will be easier to maintain/update.
It’s important to discover the underlying reason why users do a particular thing, rather than just the way they currently do it.
Tip 52: Work with a User to Think Like a User
As soon as you start discussing requirements, users and domain experts will use certain terms that have specific meaning to them. They may differentiate between a “client” and a “customer,”
Tip 54: Use a Project Glossary
So how can you tell when you’re simply procrastinating, rather than responsibly waiting for all the pieces to fall into place?
A technique that has worked for us in these circumstances is to start prototyping. Choose an area that you feel will be difficult and begin producing some kind of proof of concept. One of two things will typically happen. Shortly after starting, you may feel that you’re wasting your time. This boredom is probably a good indication that your initial reluctance was just a desire to put off the commitment to start. Give up on the prototype, and hack into the real development.
On the other hand, as the prototype progresses you may have one of those moments of revelation when you suddenly realize that some basic premise was wrong. Not only that, but you’ll see clearly how you can put it right. You’ll feel comfortable abandoning the prototype and launching into the project proper.
This approach can also lead to a more committed set of developers. Each team knows that they alone are responsible for a particular function, so they feel more ownership of their output.
The project needs at least two “heads”—one technical, the other administrative.
Tip 61: Don’t Use Manual Procedures
A shell script or batch file will execute the same instructions, in the same order, time after time. It can be put under source control, so you can examine changes to the procedure over time as well (“but it used to work…”).
In general, comments should discuss why something is done,
Commenting source code gives you the perfect opportunity to document those elusive bits of a project that can’t be documented anywhere else: engineering trade-offs, why decisions were made, what other alternatives were discarded, and so on.
Design Patterns. A design pattern describes a way to solve a particular class of problems at a higher level than a programming language idiom. This now-classic book by the Gang of Four describes 23 basic design patterns, including Proxy, Visitor, and Singleton.
Eric S. Raymond’s Papers at www.tuxedo.org/~esr
Eric’s papers on The Cathedral and the Bazaar and Homesteading the Noo-sphere describing the psychosocietal basis for and implications of the Open Source movement.