View Full Version : Is OOP overrated?
harmor19
01-22-2006, 11:39 PM
I just don't see why OOP is so nice.
I think it makes the script look "cooler" because it's more confusing to someone new to OOP.
For those who don't know OOP I'll make two scripts.
<?php
//the non-OOP way
echo "Name: Andrew";
?>
<?php
//the OOP way
class Person
{
var $name;
function name()
{
return $this->name;
}
}
$person = new Person;
$person->name = "Andrew";
echo "Name: ".$person->name()."";
?>
They should print
Name: Andrew
akanevsky
01-22-2006, 11:46 PM
OOP is nice not because it makes the code look "nicer", but because it provides better encapsulation of the code as well as a way to easily implement reusable code that does not have multiple copies throughout multiple files. An example of how OOP can be used to create efficient code: vBulletin's data managers. When you need to alter the way a certain data is managed, you do not have to edit multiple files, but instead you just have to edit the code of that data manager.
AN-net
01-22-2006, 11:50 PM
procedural and OOP do not differ much in speed when bottlenecks are removed and code is optimized. OOP is more useful when you have a large system of code where that code will be utilisized multiple throughout multiple files. with OOP you can easily reuse code and build off of existing code with no problem.
harmor19
01-23-2006, 12:01 AM
I guess for database retrieval it's nice ($vbulletin->userinfo) but for what I did then it's pointless.
speaking of data managers, is there one to private message someone?
Edit:
nevermind, I looked for the class file.
Edit 2:
now I have to figure out how to use it. :ermm:
akanevsky
01-23-2006, 12:34 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=82786" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=82786</a>
harmor19
01-23-2006, 12:52 AM
thanks
Xenon
01-23-2006, 01:04 PM
Well, oop is overated, but on the other hand it's also underestimated.
It's not that non-plus ultra some people tend to say, but it's also not bad.
same would be with aspect orientated programming languages.
every thing has pro's and contras.
My personal pov is that oop is very usefull in big projects with a real coding language like c++, but it's not that good that a script language like php goes more and more into oop.
but as said, that's just my pov.
filburt1
01-23-2006, 06:00 PM
With respect to those who disagree, anybody who thinks OOP is overrated doesn't understand the massive benefits it introduces. Sure, you can get polymorphism, encapsulation, and inheritance, but you also get implied namespaces, grouping of objects, enforced code structure (abstract methods) which itself leads to polymorphism...
OOP may be confusing if you're only used to normal PHP, but once you write in something like Java, you realize how stupid half of PHP is (and how broken PHP's OO model still is).
Andreas
01-23-2006, 06:38 PM
C (and I mean C, not C++, C# - just C) will never die ;)
Xenon
01-23-2006, 07:41 PM
OOP may be confusing if you're only used to normal PHP, but once you write in something like Java, you realize how stupid half of PHP is (and how broken PHP's OO model still is).
JAVA is not a good example, it's so inefficient ^^
* Xenon remembers of the good old times when oop wasn't yet planned and everything was done in ASM, there you have had to know what you do ^^
Marco van Herwaarden
01-23-2006, 07:47 PM
Lol ASM. I have been running mainframes where you had to enter the bootcode by manually programming the bootsequences with 16 switches. You would set each line of the bootstrap code by setting the correct switches out of the 16, then hit Start, then move to the next line, and continue until you programmed enough bootstrap code to make it read a punchtape/punchcards with the real software you wanted to run.
Xenon
01-23-2006, 08:56 PM
i am not that old yet ^^
all i know are pcs ^^ (ok, and Amigs, but i don't count them in that context ;))
Paul M
01-23-2006, 09:08 PM
Hmm, 6502 Assembler code on a BBC Micro, those were the days .... :)
As for OOP - vastly over-rated IMO ;)
filburt1
01-23-2006, 09:41 PM
JAVA is not a good example, it's so inefficient ^^
* Xenon remembers of the good old times when oop wasn't yet planned and everything was done in ASM, there you have had to know what you do ^^
Respectfully, you must not have coded a lot in Java in order to say that. It's not the speediest language, but it's scalable and a hell of a lot more efficient in terms of structure and design than PHP.
Xenon
01-23-2006, 09:56 PM
Actually i have coded a lot in JAVA, as i has had to do it at university.
and you are just prooving my point, it is much better in design and structure than php, yep, but i talk about efficiency.
Scriptlanguages like php, shouldn't use much OOP, OOP is more for design languages
filburt1
01-23-2006, 10:22 PM
It is slower, but not inefficient. Its runtime architecture is fundamentally different from PHP. For that matter, PHP is an interpreted language whereas Java is compiled to byte code.
I long for the day when JSP is common on servers.
Andreas
01-23-2006, 10:33 PM
I long for the day when JSP is common on servers.
Do you honestly think this will happen?
Xenon
01-24-2006, 12:52 PM
@filburt: i don't compare JAVA with PHP on efficiency, but with C and C++
PHP is a scripting language which is interpreted, yes, and therefore has a totally different use than JAVA has. Java has it's own advantages, but it has it disadvantages as well, and you won't be able to change that.
Of course i would never code a real game in PHP, as this would be an inefficient language for that task.
All i said is that the new hype around oop is overrating it's strengthes. OOP has a lot of advantages of course, and for big projects it's really usefull, but that does not make it the non plus ultra a lot of people mean it to be.
harmor19
01-24-2006, 01:21 PM
I think people write OOP for two reasons.
One is too use it effectively as I would say vbulletin does.
The other reason is just for the heck of it.
They just want to show clients some complicated code and make them believe you know what you're doing.
filburt1
01-24-2006, 04:03 PM
Do you honestly think this will happen?
No, but I can still long.
Name three disadvantages OOP (not Java, C++, etc. specifically) has over a basic procedural language where everything is in a functional or global scope.
Xenon
01-24-2006, 05:04 PM
use of Memory
bloating up short code
and the lack of knowledge what code especially is executed in a more complicated program (multiple parents oop like for example c++)
filburt1
01-24-2006, 06:06 PM
1. OOP does not use a lot of memory in its nature. It depends on the implementing language.
2. True, but how many tiny projects are developed and sold commercially?
3. Depends on the implementing OO model. C++'s is a piece of crap with multiple inheritance as you mention, but Java and, dare I say, PHP get it right with single inheritance. Java supports interfaces too which is like pseudomultiple inheritance but far safer.
But I digress. I will remove the gun at your head forcing you to write OO code.
Xenon
01-24-2006, 06:50 PM
1. well, on it's nature, nothing uses memory, it's always the implementing which uses memory, but storing objects and functions will use always more memory than functions alone, that cannot be covered by any implementation ;)
2. hmm, i regard a lot of php projects as "small", but thats a pov
3. you said i should mention disadvantages of oop itself, and multiple inheritance belongs to oop, it's not a speciality of c++ (on the other hand, i don't know other oop languages right now which use it, but that's just because i have just thought of the default languages right now ;))
But yeah let's stop here.
And you don't have to force me wrinting oop code. I code that way already in a lot of projects as well, i just said, that i think it is overrated, not that it is generally a bad thing, something completely different ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.