>  > 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'd take a look at the python subprocess module. It's an elegant
solution which should provide some good ideas.

Cheers,
Frederik
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to