Chapter 6 Methods 183 (Web design careers) Good Programming Practice 6.1

Chapter 6 Methods 183 Good Programming Practice 6.1 Make good use of modularity to increase the clarity and organization of your program. This will not only help others understand your program, but it also will aid in program development, testing and debugging. Software Engineering Observation 6.4 To promote reusability, each method should perform a single, well-defined task, and the name of the method should express that task effectively. Software Engineering Observation 6.5 If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks. Usually it is best to break such a method into several smaller methods. 6.5 Method Definitions The programs presented up to this point each contained at least one method definition (such as Main) that called FCL methods to accomplish the program s tasks. We now consider how to write customized methods. Consider the Windows application in Fig. 6.3, which uses a method called Squareto calculate the squares of the integers from 1 to 10. Notice the comment on line 15 // Visual Studio .NET generated code Throughout the book we will use this comment to denote code that we are not displaying in the chapter. In all cases, this represents code created by the IDE. Most of this code initializes properties of GUI components. The examples in all chapters of the book are included in their entirety on the CD that accompanies this book. The examples also can be downloaded from www.deitel.com via the Downloads/Resources link. Figure 6.4, displays all the code. However, you do not need to understand all the code at this point in the book. Chapter 12, Graphical User Interfaces: Part 1, presents an example in which we discuss all the code in detail. 1 // Fig. 6.3: SquareInt.cs 2 // Demonstrates a programmer-defined Square method. 3 using System; 4 using System.Drawing; 5 using System.Collections; 6 using System.ComponentModel; 7 using System.Windows.Forms; 8 using System.Data; 9 10 public class SquareInt : System.Windows.Forms.Form 11 { 12 private System.Windows.Forms.Button calculateButton; 13 private System.Windows.Forms.Label outputLabel; 14 15 // Visual Studio .NET generated code Fig. 6.3 Using programmer-defined method Square. (Part 1 of 2.)
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Leave a Reply