288 Methods Chapter 6 Chapter Recursion examples and (Web design course)
288 Methods Chapter 6 Chapter Recursion examples and exercises Linked-list insert Linked-list delete Search a linked list Print a linked list backward Binary-tree insert Preorder traversal of a binary tree Inorder traversal of a binary tree Postorder traversal of a binary tree Fig. 6.15Summary of recursion examples and exercises in this text (part 2 of 2). g. 6.15 Let us reconsider some observations we make repeatedly throughout this book. Good software engineering is important. High performance is often important. Unfortunately, these goals are often at odds with one another. Good software engineering is key to making more manageable the task of developing larger and more complex software systems. High performance in these systems is key to realizing the systems of the future, which will place ever greater computing demands on hardware. Where do methods fit in here? Software Engineering Observation 6.11 Modularizing programs in a neat, hierarchical manner promotes good software engineering. But it has a price. Performance Tip 6.5 A heavily modularized program as compared with a monolithic (i.e., one-piece) program without methods makes potentially large numbers of method calls, which consume execution time and space on a computer s processor(s). But monolithic programs are difficult to program, test, debug, maintain and evolve. So modularize your programs judiciously, always keeping in mind the delicate balance between performance and good software engineering. 6.15 Method Overloading Java enables several methods of the same name to be defined, as long as the methods have different sets of parameters (based on the number of parameters, the types of the parameters and the order of the parameters). This characteristic is called method overloading. When an overloaded method is called, the Java compiler selects the proper method by examining the number, types and order of the arguments in the call. Method overloading is commonly used to create several methods with the same name that perform similar tasks, but on different data types. Good Programming Practice 6.9 Overloading methods that perform closely related tasks can make programs more readable and understandable. Figure 6.16 uses overloaded method square to calculate the square of an int and the square of a double. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01