Git Product home page Git Product logo

Comments (5)

GreatOwl avatar GreatOwl commented on July 16, 2024

Interesting question, the function is available on the pipeline as a public method, but it looks like it's being used by the invoke method as if it were a private method. The process function does belong to the processor interface, and doesn't belong to the pipeline really. I wouldn't say that we would want the pipelineinterface to extend or be extended by the processor interface since that could confuse people on the functionality of the processor. I think that method may have been put there for convenience and not meant to be used as part of the interface. But this is one I would be interested to know if all my arbitrary theorizing is correct, when we get an answer.

from pipeline.

motammem avatar motammem commented on July 16, 2024

According to Separation of Concerns it's good practice to separate structure from it's processor.
And to do this in the clean way we can pass structure to executor in order to process it, passing structure to processor should be done through process method ( not constructor ) to make processor stateless and reusable to process other structures as well.

In our case I suggest to remove ProcessorInterface reference from Pipeline class and refactor process method on ProcessorInterface to accept PipelineInterface and $payload.

from pipeline.

GreatOwl avatar GreatOwl commented on July 16, 2024

I really like this suggestion actually. Replacing the current contract of the processor to accept the pipeline and providing access to the stages on the pipeline for use in the processor. By doing that, you don't have to know up front how you want to process the stages, that can now be done later if you want.

Similarly, we could finally make the pipeline immutable if we wanted, as it is only an ordered collection of callables at that point. But maybe I'm hoping for too much with that.

from pipeline.

shadowhand avatar shadowhand commented on July 16, 2024

I think the current structure is doing Dependency Inversion correctly.

from pipeline.

courtney-miles avatar courtney-miles commented on July 16, 2024

I think the current structure is doing Dependency Inversion correctly.

In this case, perhaps the docs need to change?

This is the example from the docs.

$pipeline = (new Pipeline)
    ->pipe(new TimesTwoStage)
    ->pipe(new AddOneStage);

$pipeline->process(10);

The issue is that $pipeline is an instance of PipelineInterface and not Pipeline, so it's wrong to assume there is a process() method that can be called. Insightful IDEs correctly report this code as a problem.

I suspect the example should instead be the following.

$pipeline = (new Pipeline)
    ->pipe(new TimesTwoStage)
    ->pipe(new AddOneStage);

$pipeline(10);

Otherwise, the examples should be switched around to the following:

$pipeline = new Pipeline(
    null,
    (new TimesTwoStage),
    (new AddOneStage)
);

$pipeline->process(10);

I'm happy to submit a PR for the change if there is an agreement.

from pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.