Overview of Object Oriented Programming

2014 words (8 pages) Essay in Computer Science

08/02/20 Computer Science Reference this

Disclaimer: This work has been submitted by a student. This is not an example of the work produced by our Essay Writing Service. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

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, it has been become a widely-used, important programming paradigm that is supported in many different languages.

In the early 1970s, the U.S.A Department of Defense (DoD) commissioned a task force to research why the IT budget went out of control all the time(Robert Nesmith,1986). However, while not a lot of to point out for, the findings are:

  1. 80% of the budget went to the software system (with the remaining 20% to the hardware).
  2. Over 80% of the software system budget went to maintenance (only the remaining 20% for new software system development).
  3. Hardware parts may be applied to variied products, and their integrity usually didn’t affect other products.
  4. Software procedures were typically non-sharable and not reusable. Software system faults could have impact to other programs that running in computers.

The task force proposed to form software behave like hardware OBJECT. Later on, the Defense Department replaces over 450 computer languages, which were then used to build Defense Department systems, with an object-oriented language known as Ada. Object oriented programming languages was designed to overcome these issues. It allowed programmers to re-use codes, it is a type of programming in which programmers define not only the data structure, however additionally the types of operations that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. additionally, programmers might create relationships between one object and another. For instance, objects can inherit characteristics from different objects. One in every of the principal advantages of object-oriented programming techniques over procedural programming (such as C and Pascal) techniques is that they let programmers to create modules that don’t have to be modified when a new type of object is added. A programmer could just simply create a new object that inherits many of its features from existing objects. This makes object-oriented programs easier to use, understand and modify.

Structured, easy to know that programming has been around since the late 60’s. these advances allowed programmers to write fairly complicated programs comparatively easy using such languages as C and Pascal. However, once a program reached a certain size it was too complex to manage. SIMULA was the first object language that ever exist in the history. As its name suggests it was used to create simulations. Alan Kay, who was at the University of Utah during the time (Alan Kay, 1997), liked what he saw in the SIMULA language, it inspired him to have the vision of a personal computer that would provide graphics-oriented applications and he felt that a language like SIMULA would provide a decent way for non-specialists to create these applications. He sold his vision to Xerox Parc. In the early 1970s, a team headed by Alan Kay at Xerox Parc created the first personal computer called the Dynabook.

But the concept of object-oriented programming gained momentum when a man known as Bjorn Stroustrup showed up in the  late1970s and in the early 1980s(Alex Stone 2008), he integrated object-oriented programming into the C language, the resulting language was called C++ also known as C with classes, and it became the first object-oriented language to be widely used commercially. In the early 1990s a group at Sun led by James Gosling developed a simpler version of C++ called Java that was meant to be a programming language for video-on-demand applications (James Gosling, 2000). This project was going nowhere until the group re-oriented its focus and marketed Java as a language for programming Internet applications. The language has gained widespread popularity as the Internet has boomed, though its market penetration has been limited by its inefficiency.

The C++ programming language is currently the most widely available and widely used language and as such, many programmers are familiar with the object-oriented paradigm through their experience with C++. The java programming language is the second widely used language, the difference between them is their heritage, as they were designed for different goals. C++ is was developed as an object-oriented extension of procedural programming language C (which was designed for efficient execution), and it was use for systems and applications programming. Java is designed to minimize implementation dependencies.  Java syntax has a context-free grammar that can be analysis by a simple LALR analysis. Parsing C++ is more complicated, for instance, Boo<1>(3), is a sequence of comparisons, if Boo is a variable, but creates an object if Boo is the name of a class template. C++ allows namespace-level constants, variables, and functions. In Java, such entities must belong to some given type and must be defined inside a type definition either a class or an interface. In C++, objects are values, while in Java they are not, C++ uses value semantics by default, Java always use reference semantics.  For example, in C++, the code will be like:

Class Boo {

Int x = 0;        

Boo ():x (0) {}           

Int bar (int i) {         

Return 3*i + x;}

We can see that in C++, once after declares the class Boo, the private member variable needs to be initialized to 0, if the constructor would not set it. Constructor for Boo: initializes x to 0, if the initializer were omitted, the variable would be initialized to the value that has been given at declaration of x.

In Java, the codes will be different: 

Class Boo {

Private int x; 

Public Boo () {}

Public int bar (int i) {

Return 3*i +x;}}

From the codes in Java, we can see that after defining the class Boo, the member variable normally declared as private to enforce encapsulation initialized to 0 by default, and the constructor for Boo doesn’t has no-arg constructor supplied by default.

Another good example of difference between C++ and Java could be the simple “Hello world” program, if we examine a Java application instead of an applet, we can tell the two programs are very similar. The C++ code will show as:

#include <stdio.h>        

Int main (int argc, char * argv[]){

Printf (“Hello, world! \n”);}

The Java code will show as:

Package hello;

Public class Hello {

Public static void main (string args[]){

System.out.println(“Hello, world!”);}}

See, they are very similar, there are a few key changes, first, there can be global functions such as printf and               main. Second, is the #include statement, this lets the compiler to read into a file that normally contains class or function declarations. Third is the Java program includes a package declaration, however, the C++ has no analogous concept of packages.  And finally, in C++ the main method returns an integer (known as the exit code), which signifies whether the program terminated successfully. But in Java, the main method does not return a value.

Although, the syntax is slightly different between C++ and Java, there also has some similarities, such as the identical comments syntax, they both use // or /* */ to do the single and multiple line comments; they both have same arithmetic (such as +, -, /, *) and relational operators (>, <, =, !=); they have same primitive data types such as int, float, char, double, etc.; and they share many of keywords like break, continue, new, public, private, static, etc. And a more intuitive example for this concept is from the previous “Hello world” program: they both execute the programs start from the main function, even thought, the function declaration is different, but the name is the same.

The syntax is not the only difference between C++ and Java, there also other things are different, such as the C++ language support unions, pointers, structure and operator overloading, but the Java language doesn’t. when talking about pointer, it is relating to the next topic that I’m going to talking about, the memory management. when talking about freeze and delay in a program, the first thing we may thinking about is the memory. The biggest difference is when you create or delete an object, C++ has no garbage collector in its standard library, but Java has an automatic garbage collector which manage all memory in Java and it reclaims all. Which means when you use the object pointers and create an object on the free storage in C++, you must delete the object if you are no longer needed, otherwise it will continue compiling until the computer to run out of memory and cause crash to the program. The Java provide a better object lifecycle, you can just create them, and the Java will take care of the rest of them, the garbage collector will identify and destroy the objects that you are no longer needed. But the disadvantage of the automatic garbage collector is you have no real time control of what time the object is really deleted, which may cause freeze or delay sometimes. For example, in Java you can simply do this:

Void DataWork(int num){

Double [] array = new double(num);

Dataobject ob = new Dataobject();

Hold[] buffers = new Hold[2*num];

After you done the work with array, data object, and buffers, you can simply just leave, don’t have to do anything to it, the memory allocated for array, data object and buffers in the heap will be made available for reuse by the garbage collector. But in C++, you can’t just leave, you have to do one more step. Here’s the example:

Void DataWork(int num){

Double* array = new double[num];

Dataobject* ob = new Dataobject();

Hold* buffers = new Hold[2*num];

Delete [] array;

Delete ob;

Delete [] buffers;

From the C++ codes, we can tell when you want to exit a code with pointer, you must to delete it, or it will keep running.

Both C++ and Java programming languages support OOP paradigms but there exist similarities and differences between them. C++ is more flexible and emphasizes on the runtime efficiency and can form broad type hierarchies. Java emphasizes security and portability at the cost of efficiency and flexibility, it provides abstract interface to imitate multiple inheritance differentiate between object and primitive type semantics.

References:

  • Spinczyk, O., Gal, A., & Schröder-Preikschat, W. (2002, February). AspectC++: an aspect-oriented extension to the C++ programming language. In Proceedings of the Fortieth International Conference on Tools Pacific: Objects for internet, mobile and embedded applications (pp. 53-60). Australian Computer Society, Inc..
  • Lafore, R. (1997). Object-oriented programming in C++. Pearson Education.
  • Balagurusamy, E. (2001). Object Oriented Programming with C++, 6e. Tata McGraw-Hill Education.
  • Rentsch, T. (1982). Object oriented programming. ACM Sigplan Notices17(9), 51-57.
  • Robert N.(1986).A study of software maintaince costs of air force large scale computer system, 9-12.
  • Ingalls, D., Kaehler, T., Maloney, J., Wallace, S., & Kay, A. (1997, October). Back to the future: the story of Squeak, a practical Smalltalk written in itself. In ACM SIGPLAN Notices (Vol. 32, No. 10, pp. 318-326). ACM.
  • Stone, A. (2008). Learning Object Based Instruction. In Encyclopedia of Information Technology Curriculum Integration (pp. 518-524). IGI Global.
  • Gosling, J., Joy, B., & Steele, G. (2000). The Java language specification. Addison-Wesley Professional.
Get Help With Your Essay

If you need assistance with writing your essay, our professional essay writing service is here to help!

Find out more

Cite This Work

To export a reference to this article please select a referencing stye below:

Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.

Related Services

View all

DMCA / Removal Request

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please:

McAfee SECURE sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams Prices from
£124

Undergraduate 2:2 • 1000 words • 7 day delivery

Order now

Delivered on-time or your money back

Rated 4.6 out of 5 by
Reviews.co.uk Logo (188 Reviews)