Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,350 members, 7,836,422 topics. Date: Wednesday, 22 May 2024 at 07:33 AM

Procedural Vs Object Oriented PHP - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Procedural Vs Object Oriented PHP (3382 Views)

Object Oriented Programing And Procedural Programing In Php What Is The Diff? / A Beginners Guide To Object-oriented Programming (OOP) In PHP 5+ / Javascript Tutorial For Newbies [both Procedural / Oop Inclusive] (2) (3) (4)

(1) (Reply) (Go Down)

Procedural Vs Object Oriented PHP by Nobody: 2:24am On Aug 26, 2012
Procedural vs Object Oriented PHP

which one do you use and why?
Re: Procedural Vs Object Oriented PHP by Nobody: 3:11am On Aug 26, 2012
OOP because i use frameworks alot
Re: Procedural Vs Object Oriented PHP by Nobody: 4:55am On Aug 26, 2012
pc guru: OOP because i use frameworks alot

because of only frameworks?

how do you manage with the speed of your application or are you not border?
Re: Procedural Vs Object Oriented PHP by WebMonk(m): 9:53am On Aug 26, 2012
Eventually you'll move to OOP. If you've been using procedural for a long while you'll appreciate the speed and management of OOP better especially with larger projects. Adding a framework to it only makes your work faster. Some frameworks are better optimized for speed than others.
Re: Procedural Vs Object Oriented PHP by Nobody: 9:58am On Aug 26, 2012
The reason I stopped using Procedural was that it didn't give me the flexibility and ease of changes in OOP, take for instance I have an App called Zoo and each of these animals make noises so let's iterate the animals and print their noise. In procedural every easy if animal is lion print roar,else if cat meow but wait a min we got 100 animals what's not to say in future we'd get a 1000 so u see that's a problem because procedural doesn't have Class Hint,we have to manually check the animal ok let's go OOP create a class animal and have an abstract method makeNoise, create a Lion Class and implement make noise. For each instance of animal, instance.makeNoise two lines and your app is good. But the down size is you get to create a lot of file classes but as long as flexiblity is kept in mind then no problem, I use Yii Framework which is fast coupled with MemCache together, usually speed is the list of the problem getting your Application Logic is key then you can decided to scale which was why I stuck with Zend despite the slow speed, I wrote an app in procedural it was a seven months project the project died because there was no structure. Procedural is meant for simple web but if its a complex app pls switch to OOP its by far saner. Trust me u don't even need to use a framework.
Re: Procedural Vs Object Oriented PHP by Nobody: 12:16pm On Aug 26, 2012
WebMonk: Eventually you'll move to OOP. If you've been using procedural for a long while you'll appreciate the speed and management of OOP better especially with larger projects. Adding a framework to it only makes your work faster. Some frameworks are better optimized for speed than others.
pc guru: The reason I stopped using Procedural was that it didn't give me the flexibility and ease of changes in OOP, take for instance I have an App called Zoo and each of these animals make noises so let's iterate the animals and print their noise. In procedural every easy if animal is lion print roar,else if cat meow but wait a min we got 100 animals what's not to say in future we'd get a 1000 so u see that's a problem because procedural doesn't have Class Hint,we have to manually check the animal ok let's go OOP create a class animal and have an abstract method makeNoise, create a Lion Class and implement make noise. For each instance of animal, instance.makeNoise two lines and your app is good. But the down size is you get to create a lot of file classes but as long as flexiblity is kept in mind then no problem, I use Yii Framework which is fast coupled with MemCache together, usually speed is the list of the problem getting your Application Logic is key then you can decided to scale which was why I stuck with Zend despite the slow speed, I wrote an app in procedural it was a seven months project the project died because there was no structure. Procedural is meant for simple web but if its a complex app pls switch to OOP its by far saner. Trust me u don't even need to use a framework.

for me i see this as a waste of resources and also time consuming....

see this

class pcguru{

var $pc_guru_name = "Okeowo Aderemi";

function pc_guru_function()

{
return $this -> pc_guru_name;
}

}

$pc_guru_name = new pcguru();
echo $pc_guru_name ->pc_guru_function()

When a simple procedural code can do it simple

$procedural_pc_guru_name = "Okeowo Aderemi";

echo $procedural_pc_guru_name;
Re: Procedural Vs Object Oriented PHP by DualCore1: 12:37pm On Aug 26, 2012
There are 2 classes of people who would choose procedural programing over object oriented programming.

1. People who are very comfortable with the tons of functions they have written over time (to simplify almost every task).
2. People who are just too lazy to grasp the OOP concept and then take consolation in the fact that they can code in procedural.

Its the way forward. Some employers now ask to see a code snippet you have written in OOP, as part of the determining factors to get hired.

Again, its the way forward and its worth learning now even if you don't know why you should learn it or you don't intend to switch to it immediately.
Re: Procedural Vs Object Oriented PHP by DualCore1: 12:52pm On Aug 26, 2012
ActiveMan:

for me i see this as a waste of resources and also time consuming....



OOP: Spend 1 hour writing a class once and then subsequently spend 30 seconds instantiating that class whenever you need it for various conditions.

Procedural: Spend 10 minutes each, writing a block of code with same functionality but different conditions and applications. For each of the different conditions and applications of the function, its a fresh 10 minutes. Imagine writing that same block for a hundred different applications and conditions.

Bottom Line:
Use what works for you. Its a technological sin to waste time and its punishable by a life of regrets sooner or later. Life is too short.
Re: Procedural Vs Object Oriented PHP by Nobody: 12:59pm On Aug 26, 2012
Procedural wastes a lot of time. Write a class once and forget how you write it. Caramba! I have some classes i have written like 10 years ago, and i still keep using them till other - some of them have spanned over 100 websites!!! and i am still counting!!!
Re: Procedural Vs Object Oriented PHP by Nobody: 1:28pm On Aug 26, 2012
Dual Core:
Bottom Line:
Use what works for you. Its a technological sin to waste time and its punishable by a life of regrets sooner or later. Life is too short.


Very Reasonable statement.

*dhtml:
Procedural wastes a lot of time. Write a class once and forget how you write it. Caramba! I have some classes i have written like 10 years ago, and i still keep using them till other - some of them have spanned over 100 websites!!! and i am still counting!!!


You have your class library and you can also have your function library (even the class contains some functions).

in programing laziness is a hubby,
when you write a login script you do not need to write it again, you keep it in your library and you re-use it when you want to do something like that...

MY MAIN POINT HERE IS

You create a class and in the class their are functions include why not just create your function directly and call it when you need them?
and have a library of functions instead of class library.

everyone is talking FRAMEWORK?
Re: Procedural Vs Object Oriented PHP by Nobody: 2:41pm On Aug 26, 2012
^^whether it is a function or a class, just avoid procedural - thats the koko. Leave the frameworks - that is a topic for another day.
Re: Procedural Vs Object Oriented PHP by DualCore1: 8:30am On Aug 28, 2012
Make una no fight tongue

I think I was being general with my previous posts. OOP for web development is different for OOP for standalone dev.

In my opinion OOP for standalone development is serious business and that for web development can be toyed with.

OOP PHP is just a buzz word that most people get swayed by. If you are going to be working in a very small team and have everything planned out well, modular procedural coding is just fine and gets the job done. The strength of OOP is in its polyphormism, abstraction and encapsulation. The GOAL: Never write the same piece of code twice.

You do NOT need OOP in PHP to achieve the goal of never writing the same code twice. This can also be achieved with procedural programming using a well planned modular approach to coding in the form of functions. Most OOP PHP tutorials always use the example of a list of cars and trucks and their similarities and differences. It beats my comprehension how the writters of this tutorial try so hard to write very stuupiid procedural codes and compare it with a very well written OOP code just to point out the benefits of OOP.

So really... a lazy man is a lazy man... OOP does not save your time. Self discipline saves your time. Use what works best with minimum investment in time and a high return on this minimum investment of time.

As far as PHP is concerned I see OOP as just another style of coding. I have written pure procedural scripts in the past, after learning OOP I didn't start writing pure OOP scripts. Its now a blend of both... in fact I just call my style of coding "functional programming". Its neither fully procedural or fully OOP... its a perfect blend. I'm too old to be swayed by buzz words, I just pick out the juice from the buzz words.

My thoughts, really.
Re: Procedural Vs Object Oriented PHP by Nobody: 10:39am On Aug 28, 2012
^^^I love it when you take time out to do a good post. . . .
Re: Procedural Vs Object Oriented PHP by Nobody: 2:00pm On Aug 28, 2012
Dual Core: Make una no fight tongue

I think I was being general with my previous posts. OOP for web development is different for OOP for standalone dev.

In my opinion OOP for standalone development is serious business and that for web development can be toyed with.

OOP PHP is just a buzz word that most people get swayed by. If you are going to be working in a very small team and have everything planned out well, modular procedural coding is just fine and gets the job done. The strength of OOP is in its polyphormism, abstraction and encapsulation. The GOAL: Never write the same piece of code twice.

You do NOT need OOP in PHP to achieve the goal of never writing the same code twice. This can also be achieved with procedural programming using a well planned modular approach to coding in the form of functions. Most OOP PHP tutorials always use the example of a list of cars and trucks and their similarities and differences. It beats my comprehension how the writters of this tutorial try so hard to write very stuupiid procedural codes and compare it with a very well written OOP code just to point out the benefits of OOP.

So really... a lazy man is a lazy man... OOP does not save your time. Self discipline saves your time. Use what works best with minimum investment in time and a high return on this minimum investment of time.

As far as PHP is concerned I see OOP as just another style of coding. I have written pure procedural scripts in the past, after learning OOP I didn't start writing pure OOP scripts. Its now a blend of both... in fact I just call my style of coding "functional programming". Its neither fully procedural or fully OOP... its a perfect blend. I'm too old to be swayed by buzz words, I just pick out the juice from the buzz words.

My thoughts, really.

guy, very nice write, i share same too

One thing i have learnt over time is not depend blindly on tutorials found online, even if 100 articles say same thing.
trying it out yourself is priceless.

OOP rocks, especially when you know what you are doing, when you fully understand the concept, what happens at the background, Polymorphism, Inheritance, Encapsulation, Interfaces etc.
all these features of OOP exists to help programmers get the job done right and in the "most efficient" manner, to benefit fully from them, you probably need more experience in this field, know the importance of planning, be able to think ahead(i.e be able to envisage how your application will work and what problems you will be facing, how to solve the problem, and what problem the solution itself will present, even before you start).
this is because you can confuse yourself when the project gets midway, then you will go back and refactor/clean things up, these are codes you spent days putting together now useless.

for simple things, i support procedural, else, OOP
Re: Procedural Vs Object Oriented PHP by Nobody: 4:15pm On Aug 28, 2012
Dual Core: Make una no fight tongue

I think I was being general with my previous posts. OOP for web development is different for OOP for standalone dev.

In my opinion OOP for standalone development is serious business and that for web development can be toyed with.

OOP PHP is just a buzz word that most people get swayed by. If you are going to be working in a very small team and have everything planned out well, modular procedural coding is just fine and gets the job done. The strength of OOP is in its polyphormism, abstraction and encapsulation. The GOAL: Never write the same piece of code twice.

You do NOT need OOP in PHP to achieve the goal of never writing the same code twice. [/b]This can also be achieved with procedural programming using a well planned modular approach to coding in the form of functions. Most OOP PHP tutorials always use the example of a list of cars and trucks and their similarities and differences. It beats my comprehension how the writters of this tutorial try so hard to write very stuupiid procedural codes and compare it with a very well written OOP code just to point out the benefits of OOP.

So really... a lazy man is a lazy man...[b] OOP does not save your time.
Self discipline saves your time. Use what works best with minimum investment in time and a high return on this minimum investment of time.

As far as PHP is concerned I see OOP as just another style of coding. I have written pure procedural scripts in the past, after learning OOP I didn't start writing pure OOP scripts. Its now a blend of both... in fact I just call my style of coding "functional programming". Its neither fully procedural or fully OOP... its a perfect blend. I'm too old to be swayed by buzz words, I just pick out the juice from the buzz words.

My thoughts, really.


good post


@ dhtml see waiting i bold.... my argument
Re: Procedural Vs Object Oriented PHP by Nobody: 5:32pm On Aug 28, 2012
One of the things i hate arguing the most about is programming techniques, it is by choice and not by force.
So i chose to just waka pass. . . .and yes, dual core is correct.
Re: Procedural Vs Object Oriented PHP by trytillmake(m): 2:59pm On Aug 29, 2012
pc guru: OOP because i use frameworks alot

Bro pls which framework do u use for php and can u put me through on it.
Re: Procedural Vs Object Oriented PHP by Nobody: 3:55pm On Aug 29, 2012
i mostly use Yii and Zend but Yii mostly because it is straight forward but regardless of FW you must know your OOP in PHP well. are good are you with OOP ?

(1) (Reply)

Football Writers Wanted | Paid Part Time Job / 1st Time Job As Website Admininistrator : How Can I Succeed On The Job / What a Newbie Blogger wants to know? Ask it here!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 52
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.