Sai Stuff to Developers

September 14, 2007

Advantages of Object Oriented Programming.

Filed under: OOPS Languages — tosaik @ 6:37 am
Tags:

These are some of the major advantages of OOP.  

  • Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear.

 

  • Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system.

  

  • Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods.

 

  • Extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones.

  

  • Maintainability: objects can be maintained separately, making locating and fixing problems easier.

 

  • Re-usability: objects can be reused in different programs.

 

Polymorphism:

Filed under: OOPS Languages — tosaik @ 6:36 am
Tags:

Polymorphism means having many forms. Polymorphism can be seen frequently in the English language. There are many English words, which have a different meaning depending on the context of use. The statements “close a book”, “close the file”, “close the door” and “close the deal” all make use of the verb ‘to close’ but the meaning of each statement depends on the context. Another example is the sentence, “I’ve cracked the exam”. The meaning of cracked in this case is different from the crack used in a sentence like, “The pot cracked”. In both sentences the word is the same but its interpretation varies depending on the context. In the same way you can think of many programming examples. For instance, consider the + operator. When it is used on numbers it will act as an addition operator, adding two numbers mathematically and giving the result. When the + acts on two strings, the result will be the concatenation of the two strings.

Data Encapsulation:

Filed under: OOPS Languages — tosaik @ 6:35 am
Tags:

Data encapsulation/ data hiding is an important feature of object oriented programming. The mechanism of hiding data is to put them in a class and make them private. The data is now hidden and safe from any accidental manipulations, i.e. no function (from outside the class) can change the member data. Actually there are two things you can hide: implementation of functions (to the user it doesn’t matter as to how you’ve implemented a particular function) and data. In procedural programming it is possible to only hide the implementation details but you cannot hide/ protect data. OOP lets you achieve this. A simple example is the case of the ‘car’ (Explained in Data Abstraction, go through the next question). We don’t want the user to directly access ‘speed’ and modify it. By making ‘speed’ private, we prevent the user from doing this.

1. What is the difference between Object Oriented Programming and Procedural Programming?

Filed under: Uncategorized — tosaik @ 6:34 am
Tags:

Procedural programming creates a step by step program that guides the application through a sequence of instructions. Each instruction is executed in order. Procedural programming also focuses on the idea that all algorithms are executed with functions and data that the programmer has access to and is able to change. Object-Oriented programming is much more similar to the way the real world works; it is analogous to the human brain. Each program is made up of many entities called objects. Objects become the fundamental units and have behavior, or a specific purpose, associated with them. Objects cannot directly access another object’s data. Instead, a message must be sent requesting the data, just like people must ask one another for information; we cannot see inside each other’s heads. Benefits of Object-Oriented programming include: 

  • ability to simulate real-world event much more effectively
  • code is reusable thus less code may have to be written
  • data becomes active
  • better able to create GUI (graphical user interface) applications
  • programmers are able to reach their goals faster
  • Programmers are able to produce faster, more accurate and better-written applications (in the case of a veteran programmer, by a factor of as much as 20 times compared with a procedural program).

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.