On Wed, 2009-02-04 at 11:46 +0100, Jakob Westhoff wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Frederik Holljen wrote: > >>> Design goals ============ > >>> > >>> The workflow of a creating a SystemProcess object applying > >>> certain arguments as well as options to it and finally spawning > >>> the process should be intuitive as possible. The best way to > >>> achieve such an intuitive API would be to design it having the > >>> fluent interface pattern in mind. The used interface should look > >>> something like this:: > >>> > >>> new ezcSystemProcess( 'echo' )->argument( 'foo' )->execute(); > >> > >> Method chaining can not be done with "new classname", so it has to > >> be: > >> > >> $p = new ezcSystemProcess( 'echo' ); $p->argument( 'foo' > >> )->execute(); > > > > I don't see why the fluent interface pattern makes this more > > intuitive. I'd say it makes it less intuitive as a command is really > > not complicated at all and the fluent interface pattern is to make a > > complicated API more intuitive to use. > > > > Consider: cmd = array( 'program_name', 'arg1', 'arg2', 'arg3', > > 'arg4', 'arg5', 'arg6', 'arg7' ) pOpbject = > > ezcSystemProcess::execute( cmd ) > > > > vs $p = new ezcSystemProcess( 'program_name' ); $p->argument( 'arg1' > > )->argument( 'arg2' )->argument( 'arg3' )->argument( 'arg4' > > )->argument( 'arg5' )->argument( 'arg6' )->argument( 'arg7' > > )->execute(); > > > > Which one is easier to read and less hassle to write? Another > > advantage of the top one is that you can easily alter one parameter > > and then run the command again. > > I agree with you, that in the case presented above the array seems to be > more readable. But as soon as arguments tend to get a little bit longer > or contain variables in my opinion the fluent interface provides much > more readability, especially with proper formatting.
Also, it allows to extend the functionality with "special" arguments, which require processing, like ->pathArgument() with some applied magic to work cross different OS. Kind regards, Kore -- Mit freundlichen Grüßen / Med vennlig hilsen Kore Nordmann (GPG: 0xDDC70BBB) eZ Components Developer eZ systems Headquarters tel +49 (0) 231-9742-7750 | fax +49 (0) 231-9742-7751 k...@ez.no | eZ systems | ez.no
signature.asc
Description: This is a digitally signed message part
-- Components mailing list Components@lists.ez.no http://lists.ez.no/mailman/listinfo/components