On Mon, Oct 12, 2009 at 01:44:56PM +0100, David Otton wrote:
> 2009/10/12 Stephan Ebelt <s...@shared-files.de>:
> > as far as I understood/use it: I try to hardcode as many workable defaults 
> > in
> > the vo class as possible (ie. see $subject in the example). Then I create 
> > objects
> > by passing result records from the database (arrays) to the constructor. 
> > That
> > either returns a object or crashes the application if something is wrong.
> > Optionally I can create objects without any passed-in parameter which will 
> > give
> > one with only the defaults set. Depending on the class' definition those may
> Ok, I'm going to make a case against the use of default values
> hard-coded within the class here:


I skip a) and b) for now as I mostly agree and first like to clarify...

> c) You should store all your config options in the same place.

... that I do not use this approach for global program config options. If this
was the intent of the original question I may have mistaken it entirely.

(I actually use constants for all on-site configurations and all are defined
in one file, there aren't so many and they can't be modified at runtime (I

My primary objective for using VOs was to have very strict and clear
definitions for data structures inside the program. Passing loosely defined
arrays from function to function caused too many bugs in my code. Now things
crash much earlier and I get to know problems quicker.

(besides: phpdoc creates nice crosslinks that tell precisely what some
method needs, no long parameter lists but thats also straying off).


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to