Building blocks of a program - Data and Functions

We human beings speak many different languages and all these languages have one thing in common – Grammar. Every language has a grammar that defines the rules of that language. If we talk about the English language grammar we will find that it defines a noun, adjectives and verbs. As per the English grammar a noun is a word that is used to identify any class of people, places or things. The properties of a noun are called adjectives and the work that a noun can do is defined as verb.

The object oriented theory is also based on the same principles. Although object oriented theory is not as complex as English grammar but still they match in their basic principles. As per the object oriented theory there is an object ( noun ) which has data members ( adjectives ) and functions ( verb ). The data members define the properties of the object and the functions define the work an object can do.

When you start writing computer programs you realize slowly that everything you do in programming involves just two things

  1. Data
  2. Functions

Your goal when you are writing software project should be to organize the data and functions in your project in the best possible manner. The better you organize your code the less time and energy it will consume to get things done.

It’s important to share data

Software applications work by sharing data with each other. Even we humans share data with each other very frequently. For humans data means thoughts or things. Telling someone time from your watch, giving someone your book to read, giving someone your mobile phone to make a call are all examples of sharing data. In object oriented programming different parts of the program talk to each other by passing data in the form of objects.

Our goal when we are building a system is not to hide data between different parts of the application. If you start hiding data then different parts of the application will not be able to work properly. Your goal should be to share data, but in a very controlled manner. Your school or college has a library and there are books in the library. What is the goal of the librarian? Does he/she want to hide the books from you? No. They want to share the books with you but in a way that they can track which books is with whom and put some rules that you have to return the book on time.

Functions

You write a computer program to perform some tasks. Data cannot do work. You cannot ask the book to come out from the cupboard and sit on the table. You need a human being to pick up the book and put it on the table. In software applications we write functions to do different tasks. Functions help us in grouping a given logic together and give it a name. 

In object oriented programming

  1. We divide our program into small objects
  2. Each object contains its own data and functions which it can perform
  3. Objects can talk to each other by passing data
  4. Objects should make sure that their data is shared with other objects in a controlled manner.  

Related Questions

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp