RE: [PHP] Speaking of OOP

From: Date: Tue, 09 Jan 2001 22:26:47 +0000
Subject: RE: [PHP] Speaking of OOP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33566@lists.php.net to get a copy of this message
In short, nothing. I can't think of a single thing I can do in an OOP design that I can't do in a procedural design. A class simply allows related code and data to reside together. In a shopping cart system written in procedural code, (HEY! Who among you hasn't written your own shopping cart yet???) you have functions like saveLine() saveHeader() getItem() etc. In an OOP shopping cart you would have a Cart object that would contain a header object and an array of line objects. calling $myCart->save() would first call $myCart->header->save() and then spin through the array of line items calling $myCart-lineItems[$x]->save() Each line would know everything it needs to know to save itself to the database. I find that my OOP methods are usually smaller and more granular than my procedural functions were. most of my classes are subclasses that add a little here and a little there. The OOP way of thinking is difficult for procedural programmers to grok. (Ok, it was for me when I made the switch.) but once you get there (IMHO) it's much easier to design and code systems. Cal http://www.calevans.com -----Original Message----- From: John Guynn [mailto:John.Guynn@telescan.com] Sent: Tuesday, January 09, 2001 4:06 PM To: Php (E-mail) Subject: [PHP] Speaking of OOP I am a hardware guy hacking my way through building dynamic web pages using PHP and MySQL and I just can't get the concept of OOP. I don't understand what a class can offer that I can't do with a function. I've tried to read a couple of books about OOP and a chapter about classes and such in a PHP book and I just can't grasp the concept. Can someone explain to me how a class makes my life easier compared to using functions. Thanks in advance, John Guynn This email brought to you by RFCs 821 and 1225. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#33566) next »