Re: Getting and Setting and best practise
- From: "Steve" <no.one@xxxxxxxxxxx>
- Date: Sat, 21 Apr 2007 14:03:20 -0500
"Jim" <jimyt@xxxxxxxxx> wrote in message
news:1177180911.763041.218230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| I've been reading the responses eagerly and can appreciate all the
| opinion. Truth is, I like the idea of being able to set a property
| with:
|
| $obj->prop = "a value";
|
| That seems natural to me and I think it's going to be the option I
| take........depending on the responses to my next question:
yes, it is natural. however you cannot currently control the immediate
validation of the property being accessed. __set and __get do NOT do what
you think it does.
| When properties are set, there'll be validation taking place. For
| example a string might be too long or in the wrong format in which
| case I need to let the user know that. Ideally the failure of
| validation should allow the user to continue assigning values to other
| properties and then once all the values are assigned, they can check
| to see if there were any validation errors.
this is all common stuff that everyone wants/has to do. however, you cannot
do it immediately when a property is set, unless you use a public setter.
| My first thought on this would be to have a "errors( )" method which
| would return a reference to an array of error messages which the user
| could then loop through and output to the browser. This same function
| could again be used by "component" object when assigning the "item"
| object to it to confirm it's valid.
|
| Does this seem sensible?
all of it is very sensible. i just wish __set and __get would work on
DEFINED properties instead of UNDEFINED properties of a class.
.
- References:
- Getting and Setting and best practise
- From: Jim
- Re: Getting and Setting and best practise
- From: Steve
- Re: Getting and Setting and best practise
- From: Jim
- Getting and Setting and best practise
- Prev by Date: Appml and PHP
- Next by Date: A simple photosharing application written in php
- Previous by thread: Re: Getting and Setting and best practise
- Next by thread: Re: Getting and Setting and best practise
- Index(es):
Relevant Pages
|