vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Is OOP overrated? (https://vborg.vbsupport.ru/showthread.php?t=106051)

harmor19 01-22-2006 11:39 PM

Is OOP overrated?
 
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 Code:

<?php
//the non-OOP way
echo "Name: Andrew";
?>

PHP Code:

<?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

Quote:

Originally Posted by filburt1
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 ^^

[high]* 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 ^^[/high]

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

Quote:

Originally Posted by Xenon
JAVA is not a good example, it's so inefficient ^^

[high]* 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 ^^[/high]

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

Quote:

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

Quote:

Originally Posted by Andreas
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 ;)


All times are GMT. The time now is 01:20 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02180 seconds
  • Memory Usage 1,770KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete