In most instances, global data is really class data for a class that hasn't been designed or implemented very well. In a few instances, data really does need to be global, but accesses to it can be wr...
People who are effective at developing high-quality software have spent years accumulating dozens of techniques, tricks, and magic incantations. The techniques are not rules; they are analytical tools...
Keep Your Design Modular Modularity's goal is to make each routine or class like a black box: You know what goes in, and you know what comes out, but you don't know what happens inside.
An algorithm gives you the instructions directly. A heuristic tells you how to discover the instructions for yourself, or at least where to look for them.
Avoid duplicate code. Undoubtedly the most popular reason for creating a routine is to avoid duplicate code. Indeed, creation of similar code in two routines implies an error in decomposition. Pull th...
Because it's a poor tradeoff to add complexity for dubious performance gains, a good approach to deep vs. shallow copies is to prefer deep copies until proven otherwise.
Classes and routines are first and foremost intellectual tools for reducing complexity. If they're not making your job simpler, they're not doing their jobs.
Dijkstra pointed out that no one's skull is really big enough to contain a modern computer program (Dijkstra 1972), which means that we as software developers shouldn't try to cram whole programs into...
Here's a summary list of the valid reasons to create a class: Model real-world objects Model abstract objects Reduce complexity Isolate complexity Hide implementation details Limit effects of changes...
Here's a summary of when to use inheritance and when to use containment: If multiple classes share common data but not behavior, create a common object that those classes can contain. If multiple clas...
Defect corrections have more than a 50 percent chance of being wrong the first time
Hurrying to solve a problem is one of the most time-ineffective things you can do.
One symptom that you have bogged down in complexity overload is when you find yourself doggedly applying a method that is clearly irrelevant, at least to any outside observer. It is like the mechanica...
Levels of Design Design is needed at several different levels of detail in a software system. Some design techniques apply at all levels, and some apply at only one or two. Figure 5-2 illustrates the...
Make interfaces programmatic rather than semantic when possible. Each interface consists of a programmatic part and a semantic part. The programmatic part consists of the data types and other attribut...
Notably, the core of NASA's approach to creating reusable classes does not involve designing for reuse. NASA identifies reuse candidates at the ends of their projects. They then perform the work neede...
On small, informal projects, a lot of design is done while the programmer sits at the keyboard. Design might be just writing a class interface in pseudocode before writing the details. It might be dra...
One indication that a routine needs to be broken out of another routine is deep nesting of an inner loop or a conditional. Reduce the containing routine's complexity by pulling the nested part out and...
One key to successful programming is avoiding arbitrary variations so that your brain can be free to focus on the variations that are really needed.
Classic General Motors analysis found that 50 to 80 percent of if statements should have had an else clause (Elshoff 1976). One option is to code the else clause—with a null statement if necessary—to...
Showing 61 to 80 of 100 results