Tuesday, November 26, 2019

ObjectOriented Programming vs Procedural Programming essays

ObjectOriented Programming vs Procedural Programming essays It was way back in the 1970s when Kernighan and Ritchie were working on creating a new programming language they would soon call C. It was called this because a language called B preceded it. C was created with simplicity and flexibility in mind. Its primary use was for writing operating systems, however it became popular for a wide variety of other programs. The one thing that C lacked was support for objects; it was a procedural-oriented program. In a procedural-based programming language, a programmer writes out instructions that are followed by a computer from start to finish. This kind of programming had its advantages, but an object-oriented language makes programming clearer and easier to understand. Object-oriented software is all about using objects. An object actually contains code (member functions) and data (data members). Traditionally, code and data have been kept apart. For example, in the C language, units of code are called functions, while units of data are called structures. Functions and structures are not formally connected in C. A C function can operate on more than one type of structure, and more than one function can operate on the same structure. In object-oriented programming, code and data are merged into a single indivisible thing an object. This has some big advantages. A primary rule of object-oriented programming is this: as the user of an object, you should never need to peek inside the box. The way objects work are that a message is sent in and the object knows how to handle it. Thus the user never needs to see the implementation details. By not knowing what is going on inside an object, the user is unable to change the internal implementation code. Providing access to an object only through its messages, while keeping the details private is called encapsulation. The benefits of objects do not stop with encapsulation. Objects also have the special ability to inherit...

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.