Site uses cookies to provide basic functionality.

OK
Query
Tags
Author
Link Quote Stars Tags Author
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
a6700a7 Keep Coupling Loose Coupling describes how tightly a class or routine is related to other classes or routines. The goal is to create classes and routines with small, direct, visible, and flexible relations to other classes and routines, which is known as "loose coupling." The concept of coupling applies equally to classes and routines, so for the rest of this discussion I'll use the word "module" to refer to both classes and routines. Good .. Steve McConnell
a7976b6 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." Steve McConnell
10fd5b5 The concept of modularity is related to information hiding, encapsulation, and other design heuristics. But sometimes thinking about how to assemble a system from a set of black boxes provides insights that information hiding and encapsulation don't, so the concept is worth having in your back pocket. Steve McConnell
60bbd48 Summary of Design Heuristics Here's a summary of major design heuristics: More alarming, the same programmer is quite capable of doing the same task himself in two or three ways, sometimes unconsciously, but quite often simply for a change, or to provide elegant variation. -- A. R. Brown W. A. Sampson Find Real-World Objects Form Consistent Abstractions Encapsulate Implementation Details Inherit When Possible Hide Secrets (Information Hidin.. Steve McConnell
9672d93 work, Jacob was not claiming to make a detailed and correct prediction of climate changes over the next several hundred thousand years, only to determine whether our influence could be strong enough to interrupt the Milankovic oscillations over the coming millennia. His first model results suggest that the answer is yes. David Grinspoon
0ccc9a4 One of the most effective guidelines is not to get stuck on a single approach. If diagramming the design in UML isn't working, write it in English. Write a short test program. Try a completely different approach. Think of a brute-force solution. Keep outlining and sketching with your pencil, and your brain will follow. If all else fails, walk away from the problem. Literally go for a walk, or think about something else before returning to t.. Steve McConnell
ad40ac4 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 attributes of the interface that can be enforced by the compiler. The semantic part of the interface consists of the assumptions about how the interface will be used, which cannot be enforced by the compiler. The semantic interface includes considerati.. Steve McConnell
3821fa3 If you can't figure out how to use a class based solely on its interface documentation, the right response is not to pull up the source code and look at the implementation. That's good initiative but bad judgment. The right response is to contact the author of the class and say "I can't figure out how to use this class." Steve McConnell
9e27d76 Design is sloppy because a good solution is often only subtly different from a poor one. Steve McConnell
da9bfe8 Design is also sloppy because it's hard to know when your design is "good enough." How much detail is enough? How much design should be done with a formal design notation, and how much should be left to be done at the keyboard? When are you done? Since design is open-ended, the most common answer to that question is "When you're out of time." Steve McConnell
14dac4e Computing pioneer Edsger Dijkstra pointed out that computing is the only profession in which a single mind is obliged to span the distance from a bit to a few hundred megabytes, a ratio of 1 to 109, or nine orders of magnitude (Dijkstra 1989). Steve McConnell
470079a the automatic computer confronts us with a radically new intellectual challenge that has no precedent in our history." Of course software has become even more complex since 1989, and Dijkstra's ratio of 1 to 109could easily be more like 1 to 1015 today." Steve McConnell
86e21f3 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 our skulls at once; we should try to organize our programs in such a way that we can safely focus on one part of it at a time. Steve McConnell
ee2b4bc Poor Charlie's Almanac: The Wit and Wisdom of Charles T. Munger (Charles T. Munger), Timothy Ferriss
369260b Toy Box Killer David Parker Ray Jack Rosewood
41e9008 rigid, boot camp-style discipline; a purgatorial menu of hazing and bullying by other inmates, menial tasks, public shaming, and an idolization of authority figures. Robert F. Kennedy Jr.
cb38a5e As David Eagleman describes it in his wonderful book Incognito: Your brain is built of cells called neurons and glia--hundreds of billions of them. Each one of them is as complex as a city. . . . The cells [neurons] are connected in a network of such staggering complexity that it bankrupts human language and necessitates new strains of mathematics. A typical neuron makes about ten thousand connections to neighboring neurons. Given billions .. Ray Dalio