0

I'm working on re-writing a code base in the shipping/receiving domain and my current plan is to implement the receiving part using a state design coupled with a command/decorator pattern. I wanted to pick some other software engineer's brains to help gain different perspectives.

Consider "Receiving" to be the process in which a client sends inventory to a warehouse and said warehouse employee's must receive the containers (boxes or pallets) and move throuh a series of checks before ultimately allocating the inventory to bins.

Initial plans are as follows:

public class Container
{
  public State CurrentState {get; set;}
}

public abstract class State
{
  public Process  Process {get; set;}
}

public abstract class Process
{
 public Process NextProcess {get; set;}
 public bool IsCompleted {get; set;}
 public abstract bool Execute();
}

public class AwaitingState : State
{

}


public class AwaitingProcess : Process
{
 public override bool Execute()
 {
    //do something

    if(this.NextProcess != null)
    {
        return this.NextProcess.Execute();
    }

    return true;
 }
}

Keep in mind this is a rough plan I'm working out. I'm thinking each Container has a State and each State must go through a series of steps in order to complete it's purpose as a State. This would work well if the steps were consecutive and didn't require human input; however, all of these steps are real world steps along a "receiving line". The two problems I'm having difficulty with are the facts that these steps must occur in between web requests and each step might have a different input parameter. For example, one step could involve scanning a barcode while the next step might be a simple true/false input from the user to guide the system into selecting the next step. Then there is also the problem of persisting this data and rebuilding the domain objects back each time on each request for subsequent steps.

So my question is 2 fold:

How can I bend these 2 patterns taking into account: deferred process executions with different parameter types.

Or

What other design patterns would be good for this scenario?

1

About parameters for Execute()... you could try the generics.

public abstract class Process<T> 
{ 
    public Process<T> NextProcess {get; set;} 
    public bool IsCompleted {get; set;} 
    public abstract bool Execute(T data); 
}

If you want more control, you should go with queues like RabbitMQ or similar tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.