How to write code like graphics? Or should I use something like the Windows Workflow Foundation?

I am learning how best to develop / code a flowchart similar to a scenario.

For example, given the following diagram, I could write pseudo-code under it to satisfy the requirements. However, as the flowchart changes, it will be difficult to maintain. In addition, there is a sufficient amount of duplication, which, again, will only worsen when the flowchart becomes more complex.

Is the problem I'm trying to solve exactly what Windows Workflow is for? Or will it be too difficult an approach to the task?

Perhaps there is an obvious solution that I am missing? Thank you for your help!

(PS I must mention that I am looking for a solution based on .NET)

alt text

.. and pseudo code ...

Public Function Inbox() as Result If IsItImportant() Then If IsItUrgent() Then If IsItBestUseOfMyTime() Then If WillItTakeMoreThan15Mins() Then Return Result.ProjectList Else If CanDoItNow() Then Return Result.Now Else If DoesItHaveDeadline() Then Return Result.Calendar Else Return Result.NextAction End If End If End If Else Return Result.Delegate End If Else If IsItActionable() Then If IsItBestUseOfMyTime() Then If WillItTakeMoreThan15Mins() Then Return Result.ProjectList Else If CanDoItNow() Then Return Result.Now Else If DoesItHaveDeadline() Then Return Result.Calendar Else Return Result.NextAction End If End If End If Else Return Result.Delegate End If Else If IsItReferenceMaterial() Then Return Result.File Else Return Result.Trash End If End If End If Else If IsItWant() Then Return Result.Someday Else Return Result.Trash End If End If End Function 
+4
source share
3 answers

It looks very good for WF4. WF4 is much easier than you expected. I have quite complex workflows containing user actions that are executed in milliseconds. In addition, it is very easy to create custom actions that simplify the creation of workflows. And the design surface, being WPF, makes creating custom designers a breeze.

+2
source

Workflow Foundation is designed for lengthy processes (days, weeks, months) that can "sleep" on one computer and "wake up" on another. An example is the query system, where the workflow starts at the workstation of the person reporting the problem, can wake up inside the server somewhere that decides which department processes it, wakes up again in this department system and can be additionally processed by managers, quality departments, billing departments, etc.

Without additional information about your problem, what you are looking for is not like what WWF is for, and if you try to use WWF, you will probably find yourself in a system too complex to maintain.

The problem of writing code in such a way that it remains supported is old, and that is what most CS keywords try to solve: top-down programming, object-oriented programming, CASE, UML, dependency injection and soon.

In your case, it may happen that you just need a combination of programming from top to bottom (start with your flowchart, then write it as pseudo-code, and then convert it to executable code) plus Refactoring.

In other words, write it in the first way that comes to you, and then go to the code to find opportunities to improve it, combine duplicate code in abstraction and libraries, delete lost code, etc. Regular refactoring can contain a code base in a form that is easy to maintain without requiring a lot of abstraction, such as WWF and all the difficulties they bring with them.

0
source

I am not sure if WF is the right tool for this job. What I do not see in the description of the problem is the need for integration between modules and systems. This is where the sweetness for using WF is, trying to combine various external systems to attack one process ("Workflow / Flow Schedule") in an organized and controlled manner, which allows you to see the current state of the process and able to "stay alive", waiting for the reaction of external systems non-blocking manner. I'm just not sure what is being described is worth the overhead that WF will bring.

0
source

Source: https://habr.com/ru/post/1336179/


All Articles