Site uses cookies to provide basic functionality.

OK
Query
Tags
Author
1 2 3
Link Quote Stars Tags Author
fdca2f3 NASA's Software Engineering Laboratory studied ten projects that pursued reuse aggressively (McGarry, Waligora, and McDermott 1989). In both the object-oriented and the functionally oriented approaches, the initial projects weren't able to take much of their code from previous projects because previous projects hadn't established a sufficient code base. Subsequently, the projects that used functional design were able to take about 35 percen.. Steve McConnell
4da5f69 NASA identifies reuse candidates at the ends of their projects. They then perform the work needed to make the classes reusable as a special project at the end of the main project or as the first step in a new project. This approach helps prevent "gold-plating"--creation of functionality that isn't required and that unnecessarily adds complexity." Steve McConnell
996dc08 Containment is the simple idea that a class contains a primitive data element or object. A lot more is written about inheritance than about containment, but that's because inheritance is more tricky and error-prone, not because it's better. Containment is the work-horse technique in object-oriented programming. Steve McConnell
d93d18f developers' estimates tend to have an optimism factor of 20 to 30 percent Steve McConnell
c16e058 Be critical of classes that contain more than about seven data members. The Steve McConnell
33b8ff5 If a class contains more than about seven data members, consider whether the class should be decomposed into multiple smaller classes (Riel 1996). You might err more toward the high end of 7+-2 if the data members are primitive data types like integers and strings, more toward the lower end of 7+-2 if the data members are complex objects. Steve McConnell
b4d45dc Inheritance is the idea that one class is a specialization of another class. The purpose of inheritance is to create simpler code by defining a base class that specifies common elements of two or more derived classes. The common elements can be routine interfaces, implementations, data members, or data types. Inheritance helps avoid the need to repeat code and data in multiple locations by centralizing it within a base class. When you decid.. Steve McConnell
a38874a Implement "is a" through public inheritance. When a programmer decides to create a new class by inheriting from an existing class, that programmer is saying that the new class "is a" more specialized version of the older class. The base class sets expectations about how the derived class will operate and imposes constraints on how the derived class can operate (Meyers 1998)." Steve McConnell
c7fe5ad 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 the duplicate code from both routines, put a generic version of the common code into a base class, and then move the two specialized routines into subclasses. Steve McConnell
db1545c The underlying message of all these rules is that inheritance tends to work against the primary technical imperative you have as a programmer, which is to manage complexity. For the sake of controlling complexity, you should maintain a heavy bias against inheritance. Steve McConnell
fa18b00 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 classes share common behavior but not data, derive them from a common base class that defines the common routines. If multiple classes share common data and behavior, inherit from a common base class that defines the common data and routines. Inher.. Steve McConnell
1b0993f developer testing should probably take 8 to 25 percent of the total project time. Steve McConnell
59dd2b9 Immature testing organizations tend to have about five clean tests for every dirty test. Steve McConnell
3678a20 Mature testing organizations tend to have five dirty tests for every clean test. Steve McConnell
158ab13 it's done by creating 25 times as many dirty tests Steve McConnell
8ad80fc Be sure that the names you choose favor read-time convenience over write-time convenience. Steve McConnell
afa61f0 The most challenging part of programming is conceptualizing the problem, and many errors in programming are conceptual errors. Because Steve McConnell
91b757c Example 6-11. Java Example of Enforcing a Singleton with a Private Constructor public class MaxId { // constructors and destructors private MaxId() { <-- 1 ... } ... // public routines public static MaxId GetInstance() { <-- 2 return m_instance; } ... // private members private static final MaxId m_instance = new MaxId(); <-- 3 ... } (1)Here is the private constructor. (2)Here i.. Steve McConnell
0d53cfd 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. Steve McConnell
c49f4be 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 Hide global data Streamline parameter passing Make central points of control Facilitate reusable code Plan for a family of programs Package related operations Accomplish a specific refactoring Steve McConnell
0130637 Class Quality Abstract Data Types Have you thought of the classes in your program as abstract data types and evaluated their interfaces from that point of view? Abstraction Does the class have a central purpose? Is the class well named, and does its name describe its central purpose? Does the class's interface present a consistent abstraction? Does the class's interface make obvious how you should use the class? Is the class's interface abs.. Steve McConnell
b4663f2 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 putting it into its own routine. Steve McConnell
2fd813e Error processing is turning out to be one of the thorniest problems of modern computer science, and you can't afford to deal with it haphazardly. Some people have estimated that as much as 90 percent of a program's code is written for exceptional, error-processing cases or housekeeping, implying that only 10 percent is written for nominal cases (Shaw in Bentley 1982). With so much code dedicated to handling errors, a strategy for handling t.. Steve McConnell
a7bf2a8 If the derived class isn't going to adhere completely to the same interface contract defined by the base class, inheritance is not the right implementation technique. Consider containment or making a change further up the inheritance hierarchy. Steve McConnell
81adb71 inheritance is a powerful tool for reducing complexity because a programmer can focus on the generic attributes of an object without worrying about the details. If a programmer must be constantly thinking about semantic differences in subclass implementations, then inheritance is increasing complexity rather than reducing it. Steve McConnell
dbbecec 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 drawing diagrams of a few class relationships before coding them. It might be asking another programmer which design pattern seems like a better choice. Regardless of how it's done, small projects benefit from careful design just as larger proje.. Steve McConnell
eab8f92 On their way to America, the Pilgrims argued about the best maximum length for a routine. After arguing about it for the entire trip, they arrived at Plymouth Rock and started to draft the Mayflower Compact. They still hadn't settled the maximum-length question, and since they couldn't disembark until they'd signed the compact, they gave up and didn't include it. The result has been an interminable debate ever since about how long a routine.. Steve McConnell
aeeb3dd Use locking to control access to global variables. Similar to concurrency control in a multiuser database environment, locking requires that before the value of a global variable can be used or updated, the variable must be "checked out." After the variable is used, it's checked back in. During the time it's in use (checked out), if some other part of the program tries to check it out, the lock/unlock routine displays an error message or fi.. Steve McConnell
5d43a90 Design Is a Wicked Problem Horst Rittel and Melvin Webber defined a "wicked" problem as one that could be clearly defined only by solving it, or by solving part of it (1973). This paradox implies, essentially, that you have to "solve" the problem once in order to clearly define it and then solve it again to create a solution that works." Steve McConnell
d94f946 The picture of the software designer deriving his design in a rational, error-free way from a statement of requirements is quite unrealistic. No system has ever been developed in that way, and probably none ever will. Even the small program developments shown in textbooks and papers are unreal. They have been revised and polished until the author has shown us what he wishes he had done, not what actually did happen. -- David Parnas Paul Cle.. Steve McConnell
38c085c 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 wrapped with access routines to minimize potential problems. In a tiny number of remaining instances, you really do need to use global data. Steve McConnell
b9a3f85 One of the main differences between programs you develop in school and those you develop as a professional is that the design problems solved by school programs are rarely, if ever, wicked. Steve McConnell
021cf73 Programming assignments in school are devised to move you in a beeline from beginning to end. You'd probably want to tar and feather a teacher who gave you a programming assignment, then changed the assignment as soon as you finished the design, and then changed it again just as you were about to turn in the completed program. But that very process is an everyday reality in professional programming. Steve McConnell
0d62698 Too much of anything is bad, but too much whiskey is just enough. -- Mark Twain Steve McConnell
9cc1613 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 show that the else case has been considered. Coding null elses just to show that that case has been considered might be overkill, but at the very least, take the else case into account. When you have an if test without an else, unless the rea.. Steve McConnell
d702d2c 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 needed to make the classes reusable as a special project at the end of the main project or as the first step in a new project. This approach helps prevent "gold-plating"--creation of functionality that isn't required and that unnecessarily adds co.. Steve McConnell
061fdc0 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 mechanically inept person whose car breaks down--so he puts water in the battery and empties the ashtrays. -- P. J. Plauger Steve McConnell
740c4fe At the software-architecture level, the complexity of a problem is reduced by dividing the system into subsystems. Humans have an easier time comprehending several simple pieces of information than one complicated piece. Steve McConnell
6f67427 The more independent the subsystems are, the more you make it safe to focus on one bit of complexity at a time. Carefully defined objects separate concerns so that you can focus on one thing at a time. Packages provide the same benefit at a higher level of aggregation. Steve McConnell
f70a7a2 modern software is inherently complex, and no matter how hard you try, you'll eventually bump into some level of complexity that's inherent in the real-world problem itself. This suggests a two-prong approach to managing complexity: Minimize the amount of essential complexity that anyone's brain has to deal with at any one time. Keep accidental complexity from needlessly proliferating. Once you understand that all other technical goals in s.. Steve McConnell
d893039 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 levels. Figure 5-2. The levels of design in a program. The system (1) is first organized into subsystems (2). The subsystems are further divided into classes (3), and the classes are Steve McConnell
63dec29 Encapsulation says that, not only are you allowed to take a simpler view of a complex concept, you are not allowed to look at any of the details of the complex concept. What you see is what you get--it's all you get! Steve McConnell
edc94e8 Identify items that seem likely to change. If the requirements have been done well, they include a list of potential changes and the likelihood of each change. In such a case, identifying the likely changes is easy. If the requirements don't cover potential changes, see the discussion that follows of areas that are likely to change on any project. Separate items that are likely to change. Compartmentalize each volatile component identified .. Steve McConnell
903e8f5 Don't use a boolean variable as a status variable. Use an enumerated type instead. It's common to add a new state to a status variable, and adding a new type to an enumerated type requires a mere recompilation rather than a major revision of every line of code that checks the variable. Use access routines rather than checking the variable directly. By checking the access routine rather than the variable, you allow for the possibility of mor.. Steve McConnell
1 2 3