Re: Help on objects
| From: | Satyam | Date: | Thu, 05 Oct 2006 18:47:55 +0000 |
| Subject: | Re: Help on objects | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242698@lists.php.net to get a copy of this message | ||
----- Original Message ----- From: "Robert Cummings" <robert@interjinn.com>
To: "Satyam" <Satyam@satyam.com.ar>
Cc: "Deckard" <ml@wordlife.eu>; <php-general@lists.php.net>
Sent: Thursday, October 05, 2006 11:16 AM
Subject: Re: [PHP] Help on objects
On Thu, 2006-10-05 at 07:04 +0200, Satyam wrote:Indeed, they often are: you as an object are defined by properties such as height, color of your hair and many other adjectives and you have many other objects which define you, fingers, legs, etc, which are also properties. Being more detailed, instead of the color of your hair being a property of you as a whole, you might have a property pointing to a hair object (a noun) which has a color property. Other noun properties might not be so helpful in defining you, your friends might give a hint of who you are, your clients do not. But, after all, neither does your hair, mine is deserting me and I'm still myself. So, I would say that while adjectives define an object, nouns are relations in between objects and might not define neither. Anyway, I didn't mean this analogy to be complete, nor I mean to teach OOP to English teachers, and though it can be talked much about, stretching it too far would certainly break it. I don't mean to defend it very strongly. Cheers SatyamI've seen you already had a good answer on the errors in the code so I won't go on that. As for OOP, the one design error you have is that you are asking for an action, not an object. You want to make SQL inserts, that is your purpose, and that is an action, which is solved by a statement, not by an object. There is no doer. Objects are what even your English teacher would call objects while describing a sentence. You are asking for a verb, you don't have a subject, you don't have an object. Of course you can wrap an action in a class, but that is bad design. Classes will usually have names representing nouns, methods will be verbs, properties adjectives, more or less, that's OOP for English teachers.Properties are very often nouns in addition to adjectives. For instance a linked list class will undoubtedly have noun objects referring to the current link, the next link, etc. Cheers, Rob. --