Information Technology Reference
In-Depth Information
Building programs and applications using object-oriented programming languages is like
constructing a building using prefabricated modules or parts. The object containing the data,
instructions, and procedures is a programming building block. The same objects (modules
or parts) can be used repeatedly. One of the primary advantages of an object is that it contains
reusable code. In other words, the instruction code within that object can be reused in dif-
ferent programs for a variety of applications, just as the same basic prefabricated door can be
used in two different houses. An object can relate to data on a product, an input routine, or
an order-processing routine. An object can even direct a computer to execute other programs
or to retrieve and manipulate data. So, a sorting routine developed for a payroll application
could be used in both a billing program and an inventory control program. By reusing pro-
gram code, programmers can write programs for specific application problems more quickly
(see Figure 4.20). By combining existing program objects with new ones, programmers can
easily and efficiently develop new object-oriented programs to accomplish organizational
goals.
Figure 4.20
Internally designed
objects
Reusable Code in Object-
Oriented Programming
By combining existing program
objects with new ones,
programmers can easily and
efficiently develop new object-
oriented programs to accomplish
organizational goals. Note that
these objects can be either
commercially available or designed
internally.
+
Commercial
objects
Commercial
objects
+
Commercial
objects
+
Internally designed
objects
Existing objects
New objects
New
object-oriented
program
Programmers often start writing object-oriented programs by developing one or more
user interfaces, usually in a Windows or Web environment. You can create programs to run
in a Windows or Web environment by using forms to design and develop the type of interface
you want. You can select and drag text boxes to add descriptions, buttons that can be clicked
and executed, a list box that contains several choices that can be selected, and other input/
output features. After creating the Windows interface, you can write programming code to
convert tasks a user selects in the interface into actions the computer performs.
Some of the most popular object-oriented programming languages include Smalltalk,
Visual Basic .NET, C++, and Java (see Figure 4.21). Some old languages, such as COBOL,
have been modified to support the object-oriented approach. As mentioned earlier, Java is
an Internet programming language from Sun Microsystems that can run on a variety of
computers and OSs, including UNIX, Windows, and Macintosh OSs.
Object-oriented programs often use methods , which are instructions to perform a specific
task in the program. The following instructions in C++ use a method named ComputeArea
to compute the area of a rectangle, given the width and length.
// Method to Compute the Area of a Rectangle Given the Width and
Length
double Rectangle::ComputeArea()
{
return width * length;
}
// End of the ComputeArea Method
 
 
Search WWH ::




Custom Search