View Full Version : OOP vs Regular
So, here's the ultimate question. OOP, or plain ol' PHP?
I haven't bothered to learn it, normal PHP has been fine for me up until now, but it's becoming something that everyone is starting to use, and I'm worried I'm missing out. What are the advantages between OOP and just regular PHP? I mean, obviously for functions (encypting passwords, grabbing user details from database upon every page load) it'd be ok. But for everything? Half the apps I look at nowadays are full of it, when PHP would be fine.
I think I'm going to buy a book specifically on OOP (that's after my book on AJAX ships from Amazon.com, that is :D). But I was interested to hear people's opinions on it :)
Invent
29-10-2007, 04:38 PM
OOP for me is basically easier debugging for me AND the end-user. It also makes my code much more efficient (if I say use classes).
By using a class the end-user would simply have to re-define or change a few variables to make the script do a completely different thing. You can also create a different way of debugging for things such as queries by making a function for a query which (if the query went wrong) could report the error.
There is a lot of great and useful things you could/can do with OOP which is why I like it (:
Luckyrare
02-11-2007, 06:59 PM
I would say all decent coders use OOP, when doing larger script adleast.
It basicly allows you to update the code quicker, saves time and makes the code neater. So rather than making 10s/100s of edits if you wish to add something you can make a few edit on your class/function files.
Been using OOP for almost about 10 months.
It depends if its for a client or you. If its for you, use a little OOP, but it can be messy. For a client, dont use alot of OOP (so much that it confuses them) but make it look neater and dont go OTT
Luckyrare
02-11-2007, 07:43 PM
I disagree, most people who want work doing would rather have OOP as it makes it more simple.
I disagree, most people who want work doing would rather have OOP as it makes it more simple.
But if your making it for yourself, your more likly to take less care, meaning having to go through e.g. a 600 line file to edit 1 function.
Luckyrare
02-11-2007, 08:12 PM
If you have problems looking though classes then you should split them in to organizable named files. eg. admin.inc.php, users.inc.php so on.
It basicly allows you to update the code quicker, saves time and makes the code neater. So rather than making 10s/100s of edits if you wish to add something you can make a few edit on your class/function files.
That's what everyone has said when I've asked them. My rebuttal to this, is that you can do it with vanilla PHP anyway. I'm using custom functions at the moment, which I include into scripts when I require them, which is practically what OOP is anyway, just without classes and the object variable type.
Luckyrare
03-11-2007, 11:48 AM
If you would like some reading about OOP, you can buy this months .net as they have a article regarding it.
Very basic article tbh, you can get more information on the technique on php.net
php.net/oop
OOP Just makes it easy to debug things, and easier to organise.Although it is generally only used for larger scale projects.
MrCraig
09-11-2007, 04:52 PM
Its easier to use what you know i think
For instance, if i tried to do an OOP app with all the defines and $this->$somethin[post]
I would most likely make it unsecure, so like, use what you know how to use.
W1zzy
16-11-2007, 01:13 PM
When I'm doing personal development, I prefer to use procedural. However, I do find that the maintenance, reuseability, and the 'neatness' of OOP are great for large scale projects.
I would, however, like to get fully into OO PHP, in preparation for other full scale OO languages, such as C++.
Mentor
25-11-2007, 08:10 PM
OOP, means u get good code reuseabilty (saveing time, effort and makeing stuff more efficent), localises problems, aka if u have an error in a bit of code, u only have to fix it once in the code, not every time its called.
So oop has advantages :)
Hitman
26-11-2007, 09:44 PM
Ohh, should I continue learning normal PHP or OOP?
And if so where is a good place to learn?
I'm converting an application I recently created to OOP code. It's neater, I guess, but practically the same as normal code...
Mr Macro
03-12-2007, 10:54 PM
Ohh, should I continue learning normal PHP or OOP?
And if so where is a good place to learn?
There the same language. Just get to grips with normal PHP and then try and organise your code into files and classes etc etc
Raremandan
03-12-2007, 10:58 PM
OOP is generally a must-know if you want to learn programming in languages such as Java.
Mr Macro
04-12-2007, 08:21 PM
OOP is generally a must-know if you want to learn programming in languages such as Java.
I agree, but there is know point jumping in at the deep end when your still wearing arm bands my friend.
Invent
04-12-2007, 08:23 PM
I agree, but there is know point jumping in at the deep end when your still wearing arm bands my friend.
I dissagree. Using OOP once you know PHP can be quite difficult as you have to forget the way you've organised your code for a long time.
If you learn how to use OOP from the beginning it will be MUCH easier in the long run.
Mr Macro
04-12-2007, 08:25 PM
I dissagree. Using OOP once you know PHP can be quite difficult as you have to forget the way you've organised your code for a long time.
If you learn how to use OOP from the beginning it will be MUCH easier in the long run.
A good point, personally i started OOP when i realised that i was typing mutch of the same stuff over and over again.
Raremandan
05-12-2007, 01:35 AM
I agree, but there is know point jumping in at the deep end when your still wearing arm bands my friend.
I disagree, jump in at the deep end and either swim or drown... If you don't learn how to swim then you will drown, therefore if you are going to learn a language like Java or C++ then you should learn OOP concepts very early on, I found that many books believe you to be knowledgable on C before moving onto C++ but those that aren't seem to always introduce OOP first and never even mention a GUI.
Also two books which seem to be favourites among many good universites an on some recommended lists for 1st, 2nd, 3rd and even 4th years are "Head First Java" and "Head First Design Patterns" because they introduce objects, OOD (Object Oriented Design) and OOP (Object Oriented Programming) very early on. The evidence being in Head First Java the second chapter being: "2 A Trip to Objectville: yes, there will be objects " which I believe is a very good read (more into C++ at the moment myself)
I believe and this is my opinion, which I know others will believe to that OOP is a certain frameset, for example if you went from doing Java to Haskell (an old enemy to many) you would need to change your mind-frame entirely, I know many programmers have issues with doing this because of the sheer annoyance at Haskell which is a pure-functional non-strict programming language, generally logical and very mathematical (I hear, don't quote me on that)
So if you want to learn OOP then do so, with PHP I would learn the concepts of OOP using say Java and then use them with PHP as I find Java docs will be better than most books on PHP OOP.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.