Jump to content


Photo

OOP Question...


  • Please log in to reply
4 replies to this topic

#1 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 18 July 2006 - 02:00 PM

My friends and l are going to be making an online game, and l will be doing the PHP coding side of it.  I am thinking about using OOP so l typed it up on google to find some tutorials on it however l came accross this site http://www.webmasterstop.com/56.html.  I am hoping for a high number of players to play this game and if l make the site using OOP would this slow it down?  What are your thoughts about using OOP?

Thanks,

dual_alliance

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 18 July 2006 - 02:10 PM

OOP is used mainly for more organized and portable code.

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 18 July 2006 - 02:11 PM

these line from the article sum it up nicely:

From this test case, we can see that using classes for simple tasks end up being very inefficient...
But just because it is slower, does not mean we should stop writing OOP code all together...


if you're doing simple calculation and/or processing, do not use classes, however, when you're writing a management system to obtain database information and do multiple calculations at the load of a page, you almost have to use OOP. remember that programming for web is quite different than programming for applications. if you get into it, you'll see that almost all high-end game engines are written linearly in C. why is this? well, because it runs faster. however, while the engine and renderers to many games are written linearly, when you start to delve into structure of RPGs and other more massive games, they are pulled together with OOP.

especially when it comes to writing code in PHP for webpages, i am under the understanding that the page will most likely be changing repeatedly over time. i need to write my page in such a way as to offer myself the quickest update time later. we're talking about milliseconds in processing time in most cases, and with web, many people's internet connection will take longer than the server processing time to load the page anyway. there are many things to consider, but when it comes down to it, i just write anything that is complex and repetative in nature in an OOP way.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 18 July 2006 - 02:24 PM

Thankyou for your reply obsidian, it was a great help.  You said that you used OOP when the web page changes repeatedly over time, and this will be the same for the online game we are making so l might use it.

Thanks,

dual_alliance

#5 willfitch

willfitch
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 18 July 2006 - 03:30 PM

The purpose of OOP is to simply eliminate redundant code.  If you can find common grounds among multiple procedural scripts, you are likely a good candidate for OOP.  With the many design patterns in place, you can find a fit for almost any situation.
Zend Certified Engineer (ZEND001989)
www.willfitch.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users