GithubHelp home page GithubHelp logo

workflowmanagement's Introduction

Context

Business logic in Sms Assist LLC is around work order, proposal, and invoice. there are lot of if...else becuase of the dozens of status for work orders, which is difficult to maintain.

StatesPattern

Status Pattern For ReactiveWorkOrder, SMSInvoice, AffiliateInvoice, and Proposal in Sms Assist LLC

Pros and Cons for the state pattern

Pros

  • The single responsibility principle places code related to a particular state in a seperate class.
  • Open-Close principle. No need to change the existing status and context to add a new state.
  • Clean the redundent "if ... else..."
  • reduce the maintenance cost for the life cycle
  • Lowering the learning curve for new Software Developer

Cons

  • If there aren't not enough status, the state pattern is not necessary

Design

UMLDesign ProposalWorkFlow

Problem to resolve

StatusA + ActionB = StatusC(???)

Steps to Use

Install-Package WorkFlowManagementLibrary -Version 1.0.0

Sample Code

[TestMethod]
public void TestMethod_ClientQuoteApproved_Should_Work()
{
    // Arrange
    var context = new ReactiveWOContext(new ReactiveWorkOrderPendingDispatch());

    // Act
    context.State.Dispatch();
    context.State.Schedule();
    context.State.CheckIn();
    context.State.CheckOut(WorkOrderStatus.PendingVendorQuote);
    context.State.AffiliateEntersQuote();
    context.State.ApprovePendingClientQuote();
    context.State.RejectClientQuote();
    context.State.RejectVendorQuote();
    context.State.AffiliateEntersQuote();
    context.State.ApprovePendingClientQuote();
    context.State.ApproveClientQuote();

    // Assert
    Assert.AreEqual(WorkOrderStatus.QuoteApproved, context.State.Status);
}


[TestMethod]
public void TestMethodWholeWorkflowShouldWork()
{
    // Arrange
    var context = new RecurrentWOContext(new RecurrentWorkOrderConcretePendingSchedule());

    // Act
    context.State.Schedule();
    context.State.CheckIn();
    context.State.CheckOut();
    context.State.BatchInvoice();
    context.State.PaytoAffiliate();

    // Assert
    Assert.AreEqual(WorkOrderStatus.PaytoAffiliate, context.State.Status);
}

UnitTests

UnitTestForSmsInvoice

workflowmanagement's People

Contributors

memoryfraction avatar

Watchers

 avatar  avatar

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.