My space web page - 290 Object-Based Programming Chapter 8 conventional function calls

290 Object-Based Programming Chapter 8 conventional function calls in procedural programming langauages. It also reduces the likelihood of passing the wrong arguments, the wrong types of arguments or the wrong number of arguments. Software Engineering Observation 8.9 The use of an object-oriented programming approach often simplifies method calls by reducing the number of parameters that must be passed. This benefit of object-oriented programming derives from the fact that encapsulation of instance variables and methods within an object gives the object s methods the right to access the object s instance variables. Classes simplify programming, because the client need be concerned only with the publicoperations encapsulated in the object. Usually, such operations are designed to be client-oriented, rather than implementation-oriented. Clients are neither aware of, nor involved in, a class s implementation. Interfaces change less frequently than do implementations. When an implementation changes, implementation-dependent code must change accordingly. By hiding the implementation, we eliminate the possibility that other program parts will become dependent on the class-implementation details. Often, programmers do not have to create classes from scratch. Rather, they can derive classes from other classes that provide behaviors required by the new classes. Classes also can include references to objects of other classes as members. Such software reuse can greatly enhance programmer productivity. Chapter 9 discusses inheritance the process by which new classes are derived from existing classes. Section 8.8 discusses composition (or aggregation), in which classes include as members references to objects of other classes. 8.3 Class Scope In Section 6.13, we discussed method scope; now, we discuss class scope. A class s instance variables and methods belong to that class s scope. Within a class s scope, class members are immediately accessible to all of that class s methods and can be referenced by name. Outside a class s scope, class members cannot be referenced directly by name. Those class members that are visible (such as public members) can be accessed only through a handle (i.e., members can be referenced via the format referenceName.memberName). If a variable is defined in a method, only that method can access the variable (i.e., the variable is a local variable of that method). Such variables are said to have block scope. If a method defines a variable that has the same name as a variable with class scope (i.e., an instance variable), the method-scope variable hides the class-scope variable in that method s scope. A hidden instance variable can be accessed in a method by preceding its name with the keyword this and the dot operator, as in this.hour. We discuss keyword this in Section 8.9. 8.4 Controlling Access to Members The member access modifiers public and private control access to a class s data and methods. (In Chapter 9, we introduce the additional access modifiers protected and internal.)
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Leave a Reply