THE ADVANTAGES OF OBJECT-ORIENTED PROGRAMMING USING C++
Object-oriented programming is a new way of approaching the job of programming. Programming over the years has evolved to accommodate the increased complexity of programs. (1) Structured, easy to understand programming has been around since the late 60’s. These advances allowed programmers to write fairly complex programs relatively easy using such languages as C and Pascal. However, once a program reached a certain size it was just too complex to manage. In 1980 at Bell Laboratories in Murray Hill, New Jersey, Bjarne Stroustrup developed a new programming paradigm. (2) His new concept was built on structured programming and incorporated a few new powerful ideas. Some of the more noteworthy include Classes, Polymorphism, overloading, and inheritance.
C itself is a powerful language to begin with. C++ builds on C to make it much easier to deal with very large programs, as well as providing the tools to build black boxes. A black box, or object, is some code that performs a function with a specific type of input and gives a specific type of output.Once a black box or function is implemented, clear concise notation is used to apply the function. Condsider the following C code and output.
The Term Paper on Program Development and Evaluation
Early Childhood Education focuses on the education, language, culture, development and care of young children. As a profession, Early Childhood Education has emerged as one of the major vehicles for child-advocacy in the provision of accessible, high-quality child care and pre-school education. Child care, in this society of increasingly busy working couples, is an important service in the ...
int daysinweek = 7;
printf(“Hello world there are %d days in a week”,daysinweek);
This would give us the output
Hello world there are 7 days in a week
There are numerous print functions in C and to use them correctly you must know the correct parameters. For C++ however, the use of operator overloading and Polymorphism allow the programmer to freely flow any type of data to the screen regardless of data type. Like so.
cout << "Hello world" << " there are " << daysinweek << " in a week";
This would give the same output as the aforementioned. You can see how larger statements with a multitude of data types can be dealt with much easier using C++.
Encapsulation is the mechanism that binds together code and data. (3) This is also the concept that allows the construction of objects. The mechanisms to arrive at the output are hidden, or encapsulated, from the programmer. This gives protection against some other, unrelated part of the program accidentally modifying or using the private part of the object. In essence, an object is a data type defined by the programmer and by using overloading, the object can be treated like a data type.
Polymorphism is an attribute that allows one interface to be used with a variety of actions. (4) For example, the function sqrt() finds the square root of a number. Well, in C++ there are many different data types of numbers (e.g. decimal, integer, float point etc. ) The function sqrt() is implemented to find the square root of many data types. If a user wishes to perform the sqrt() function on a object that is not supported by the sqrt() function initially, it can be implemented. This is very useful in reducing complexity and making very powerful functions.
Inheritance is when one object can acquire the properties of another. In any instance, things can be grouped in a hierarchy. (5) For example, a grouper is a fish, a fish is an animal, an animal is a living thing. This is important for C++ in that smaller, more specialized objects can be derived from existing ones which saves time and allows for easier implementation.
The use of all these tools in an intelligent manner can result in a highly effiecient and powerful way to develop software. C++ makes it easy for multiple developers to program a separate peice of code and then converge to complete the whole utilizing objects. A useful object can be used countless times on many different programming platforms. C++ Object oriented programming is the leading language for developers of large, complex applications.
(1) Herbert Schildt, C++, the complete reference,(McGraw-Hill incorporated, 1995) p250-253
(2) Bjarne Stroustrup, The C++ Programming Language 2edition, (AT&T Bell Labs 1991) p 6-9
(3) Schildt, page 252
(4) http://uu-gna.mit.edu:8001/uu-gna/text/cc/Tutorial/node7.html#SECTION00730000000000000000
(5) Schildt, page 250