Closed Thread Icon

Topic awaiting preservation: PHP -> OOP or Procedural (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=22745" title="Pages that link to Topic awaiting preservation: PHP -&amp;gt; OOP or Procedural (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP -&gt; OOP or Procedural <span class="small">(Page 1 of 1)</span>\

 
H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 07-31-2004 04:40

Hi all, just wondering which path everyone takes... im sure people have their own opinions of why which is better.. Would love to hear them

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-31-2004 09:37

real prodecural is fine,
but oo makes some things quite a lot easier.

Then again, OO by people who haven't even read c2->DesignPatternsBook often shows a lack of grasp.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 07-31-2004 10:42

Yeh i was reading a bunch of debates about people that think OO is a waste of time...

Im concerned that maybe these people just arent using OO properly or something...

Can you recommend a tutorial that is genuinely proper OO? (Or even lend me some well written code?)

I have found a few, then looked down at comments and seeing people bagging the way it was done saying it wasnt done correctly.

kuckus
Bipolar (III) Mad Librarian

From: Berlin (almost)
Insane since: Dec 2001

posted posted 07-31-2004 11:46

These two might be of help:

http://www.gurusnetwork.com/discussion/thread/2692/
http://www.gurusnetwork.com/discussion/thread/1979/

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-31-2004 13:58

well... basic OO is pretty straight forward, you couple data with the operations that you can do on it - any of the 'animal,fish,mammal,canivore,dog,cat', kind of tutorials can teach you that.

But to see what OO can actually do for you, you have to understand (above) all polymorphism - which for me did not happen till I read c2->DesignPatternsBook. I highly recomend it, go rent it in a library, or buy it yourself, though as all 'real' literature, it's not cheap.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 07-31-2004 15:49

Great thanks, i'm always up for buying books, i think they are great to have around!

Thanks for the links also kuckus, very interesting!

I am creating my own shopping cart and site statistics script from scratch, i think i can make good use of the OO approach.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-01-2004 07:40

I have noticed people reccomend not naming files .inc like constants.inc but intead calling them .inc.php so they must be parsed by the php thingy. I was wondering if this is the same for .obj and other files. i noticed alot of people using .obj files which get included in other php files.

Is it safest just to name all files with a .php extension?

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 08-01-2004 13:51

Short answer yes.

Longer answer, yes and no...
More often than not you keep info in your classes/config files/constants that can be harmful to the system if accessible to all. If you have a file that contains things you don't want public, make sure it cannot be read through the browser. The server has a list of filetypes is should treat as code to parse and all that's not on that list is passed straight through to the browser, leaving the desicion on how to parse it to the browser.

This in turn shold tell you that "all" files should not be named .php if they are, they will all pass through the php parser no matter if it's needed or not. Rule of thumb, if the file contains any php-code at all that needs to go through the parser (regardless of if it is an include or not), name it .php. Same goes for any configuration files or similar things that must not be readable through the browser.

/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-01-2004 15:41

Yeh, well i guess i will keep those important files below the root directory so they cant be directly accessed.

Btw im using your tutorial on OOP with the mySQL database - its great!

I dont suppose you have an OOP tutorial for a shopping cart lying around :P.


On another oop note....
Im learning OOP by using it to create a fairly detailed stats script, the usual ip's, referals, keywords etc... im not exactly sure best way to take advantage of the classes etc in this situation...

What im thinking is a class for the main menu selection, and a class for the information that is displayed. Most of it will be the same type of data, like hits from google, unique hits etc.. Since they will always show the same type of data "hits", this will be in the main class. Any specific data can be extended from that class or something.

Anyhow like i said im a bit unsure the best way, i have it a little planned out but i expect i will start doing it then figure out a better way... any suggestions would be great

(Edited by H][RO on 08-01-2004 15:46)

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 08-02-2004 09:22
quote:
Btw im using your tutorial on OOP with the mySQL database - its great!


Cool! Glad you like it

quote:
I dont suppose you have an OOP tutorial for a shopping cart lying around :P.



Nope... I've just built a complete webshop incl product catalog, payment, shoppingcart and so on, everything based on DAO & VO patterns But unfortunatley it's a clients job so I cannot share code
I'd like to though, it's good code, good db-design and super flexible...
Some more general info around that and more can be found here:
http://www.gurusnetwork.com/discussion/thread/2692/

Actually, take a look here, that might get you started: http://www.php.net/oop/

Here you can usually find useful thingies as well
http://www.phpclasses.org

/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-02-2004 09:50

Thanks DMS, i understand fully about your clients confidentiality - its fair enough they are paying for it after all! Having said that if you have anything similar you can send me let me know, im not here to copy anyones work or anything - if that was the case i wouldnt bother making my own shopping cart from scratch! I just want to learn the best way to do the code, and from what i've seen so far your code seems to be the most well rounded.

Its often hard really, how do you tell whats good practice and whats not when you are learning?... Anyhow i finished your tutorial and it was great, when im a bit further into some of my projects i might get you to take a quick look and see where i can improve if you're up to it!

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 08-02-2004 13:08

If time permits, sure.
Meanwhile you can also take a look at this forum http://www.sitepoint.com/forums/forumdisplay.php?f=34 over at sitepoint.
Search for shoppingcart and you'll find things...
(there are some amazing oop-coders over there)
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-03-2004 10:12

A question on your tutorial DMS.

The function to close the database, closeCon, when do you need to use this and how?

I keep getting an error, if i do something like

code:
$myDB = new dbInterface;
$result = $myDB->doQueryResult($someQuery);
$boolClose = $myDB->closeCon();

OR

$myDB->closeCon;
$myDB->closeCon();



none of them work, it says either undefined variable myDB or call to a member function on a non-object.

Am i supposed to use it here?

Thanks

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 08-03-2004 15:21

Of the top of my head now, you should not need to use it since PHP auto closes the connections if you are not using pconnect (persistent connections).

The method is in there for "good form" so to speak because I believe that you should "pick up your litter"

However, it should work as long as you are in the same scope of the script.
The error you get is because the variable myDB doesn't exist, or that an object lacks the method you are calling.

Out of time right now, but check your scopes first, it sounds like that might be the problem.
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-04-2004 01:02

Ahh persistent connections, i was thinking it might be something like that. I was wondering also when you talk about things like ms access is only good up to about 20 users, is this meaning 20 users with persistant connections?

Good news also my host fixed the security problem, now i cant see everyones databases!

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 08-04-2004 09:25

I meant 20 simultaneous users. I believe InI has more detailed info on what Access can take and not.
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-04-2004 10:46

Oh really, i would love to see it - i hear lots of general comments about it but never see any hard facts or tested evaluations of it.

InI any links or something? Thanks

(is it possible to private message in these forums?)

« BackwardsOnwards »

Show Forum Drop Down Menu