why we use oop concept for our programming

The question arises why we prefer OOP to Procedural programming. The first term we must be familiar with procedural programming; it is the way where we have to code it procedurally first we make all things must be collaborative and interactive and method oriented again and again we have to write all procedures to execute the programme and if i am not wrong the procedural programming was lenthy one and complicated one also . i am just giving you below an example of what procedural programming says to real world.

code example of procedural programming

<?
$user_input_field = $_POST[‘field‘];
$filtered_content = filter($user_input_field);
mysql_connect(“database_hostname”,”database_user”,”database_password”); //database
mysql_select_db(“database_name”);
$sql = “query”;
$result = mysql_query($sql);
while ($data = mysql_fetch_assoc())
{
process ($data);
}
process_user_input_field($filtered_content);
?>

now we come to example of oop

 

<?
$input_user_field = new field();
$input_user_field->field_user_input_field(); //filter the user inputs
$database = new datalayer(“mysql”); //data  layer,access point
$db->connect($dbconfig);//sql commant we are using
$query_result = $db->execute($sql);
ReportGenerator::makereport($query_result);
$model = new Postmodel($field->get_filtered_content());
$model->insert();
?>

every thing from above code is clear and comprehensive and understandable easily as oop is not going to be an tough way to learn.

oop is not more than just the term use for Object Oriented Programing.

the advantages of oop over procedural programming are as follows:

  1.  It is more secure than procedural programming
  2. It is more and far more stable than procedural programming
  3. It has top notch programming concept over procedural programming.
  4. It is easy to learn and remember your own made code over what is written in procedural programming.
  5. It leads us to faster development than procedural programming.
  6. It supports inheritance in fast oriented way.
  7. It supports encapsulation in fast oriented way.
  8. It supports polymorphism in fast oriented way.
  9. It supports abstraction in fast oriented way.
  10. In short, it is more self explanatory than what other procedural languages are.