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);
$sql = “query”;
$result = mysql_query($sql);
while ($data = mysql_fetch_assoc())
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);
$model = new Postmodel($field->get_filtered_content());
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:
- It is more secure than procedural programming
- It is more and far more stable than procedural programming
- It has top notch programming concept over procedural programming.
- It is easy to learn and remember your own made code over what is written in procedural programming.
- It leads us to faster development than procedural programming.
- It supports inheritance in fast oriented way.
- It supports encapsulation in fast oriented way.
- It supports polymorphism in fast oriented way.
- It supports abstraction in fast oriented way.
- In short, it is more self explanatory than what other procedural languages are.