Graph Oriented Programming(面向圖形編程)
Workflow is mostly related to the management of tasks for people. The core focus of a workflow process specifies tasks performed by humans are related to achieve a certain process goal.
工作流主要是與人們?nèi)蝿?wù)的管理相關(guān)。一個(gè)工作流過(guò)程限定被人任務(wù)執(zhí)行的核心焦點(diǎn)是與完成一個(gè)確定的流程目標(biāo)。
Suspending an execution in java is not possible. Actually, it is possible to suspend and resume a thread in java (with e.g. Object.wait() and Object.notify()). But this does not match the needs for the process wait states because of persistence. Workflow, BPM and orchestration solutions need to persist(持久層) their execution during wait states. In fact, state changes in a process should correspond to transactions on a server. Inbetween those transactions the suspended(暫停的) execution should be persistable in e.g. a database or on the file system.
Actually, it is not so surprising that java does not have a built-in(內(nèi)置的) mechansim for suspending and persisting executions. That is because java is built on top of the Von Neumann architecture. This essentially(本質(zhì)上) comes down to an environment for executing a sequence(序列) of instructions(指令). This article presents a technique for extending the Von Neumann architecture for supporting the suspension and persistence of executions.
Products in the three fields(領(lǐng)域) have all solved this problem in their own way, from their own perspective(觀點(diǎn)). As a consequence(推理), each solution combined a technique for suspending an execution with a whole lot of other functionalities. This is the fundamental reason why these topics are perceived(察覺(jué)、感知到) as confusing(混淆的) and unclear(不清楚的) by the development community.
圖形表現(xiàn)和開(kāi)發(fā)流程
The technical ability to suspend an execution creates a very interesting opportunity(機(jī)會(huì)、時(shí)機(jī)) : a direct link between the business process and the technical implementation(商業(yè)流程和技術(shù)實(shí)現(xiàn)). The business process is a central part of the requirements specified by the business analyst. Without a mechansim for suspending executions, the implementation of the business process requires a complex translation into a software design. In that case(如果是那樣的話), the developer will have to store the executional state(執(zhí)行狀態(tài)) in some form in the database during wait states. This complexity(復(fù)雜性) is added and combined(被結(jié)合) with the functional requirements of the business process(商業(yè)流程的功能需求).
The conclusion(結(jié)論) is that it would be great if we could find a solution for suspending an execution that is related to the graphical representation of a business process. Many (probably all) of the graphical representations of business processes are based upon a directed graph. Some of the process languages are limited to a tree which is a subset of a directed graph. Those languages are called block structured languages(塊結(jié)構(gòu)語(yǔ)言).
An important consideration is that the proposed(建議) solution should embrace(包含) iterative(迭代的) development. With UML class diagrams, this is an established(確定的) practice. The analyst(分析家) can draw an analysis model in an UML class diagram. Then the developer takes this model as a starting point and transforms it into a design model. Adding more technical details will result(以...為) in an implementation. Too many proposed solutions ended up in being visual programming environments.
What is Graph Oriented Programming?(什么是面向圖形編程?)
Graph oriented programming is a technique for solving problem of suspending and persisting an execution. Because of its limited scope, this technique, is easy to understand and serves as the building block for other functionalities targeted by workflow, BPM and orchestration solutions.
面向圖表編程是為解決暫?;虺志没瘓?zhí)行的問(wèn)題的一種技術(shù)。因?yàn)樗薅ǖ姆秶?,這種技術(shù),是容易理解并且服務(wù)于為其他功能性目標(biāo)、BPM和orchestration解決方案建造模塊。
The central idea of Graph Oriented Programming is that a we complement plain imperative(命令) programming with a runtime model for executing graphs. So a graph is specified as part of the software and at runtime, executions of the graph are coupled to the execution of the imperative programmed software.
面向圖表編程的主要概念是,我們使用運(yùn)行模式為執(zhí)行圖表完成清晰的命令程序。所以一個(gè)圖表是被限定為軟件的一部分,并且圖表的執(zhí)行是連接到命令程序軟件的執(zhí)行。
A process graph is made up of Nodes and Transitions. Transitions have a direction and connect two nodes in the graph.
一個(gè)流程圖表是由節(jié)點(diǎn)和轉(zhuǎn)變(transitions)組成的.轉(zhuǎn)變有一個(gè)方向并且連接圖表中的兩個(gè)節(jié)點(diǎn)。
The graph can be seen as a state machine. Although, the executional model that we will explain here is concrete and has better support for concurrent paths of execution.
這個(gè)圖表可以看做是一個(gè)狀態(tài)機(jī)器。雖然我們這里解釋的執(zhí)行模式是具體的且更好的為并發(fā)路徑執(zhí)行提供更好的支持。
The following UML class diagram sketches(大略) how the process elements can be modelled in an UML class diagram. This also shows that a process graph can be represented(表現(xiàn)) as data. The process graph data can be expressed in different formats : XML, java objects, records in a database,...
The next part is the most difficult part to understand for programmers and technical people. That is because we are specifying an executional model that differs from the well known Von Neumann architecture.
We define a Token as a path of execution. It's a path of execution within one system.
我們定義了一個(gè)令牌作為執(zhí)行路徑。它是一個(gè)系統(tǒng)中的一個(gè)執(zhí)行路徑。
Note that an execution of a process can involve multiple concurrent paths of execution. We now define an execution of a process as a tree of tokens. A token has a pointer to a node in the process graph.
注意:一個(gè)流程的執(zhí)行可以包括多個(gè)并發(fā)的執(zhí)行路徑。我們現(xiàn)在定義一個(gè)流程的執(zhí)行作為一個(gè)令牌樹(shù)。一個(gè)令牌做為流程圖表中的一個(gè)節(jié)點(diǎn)的一個(gè)指針。
The following UML class diagram shows the tree of tokens modelled as a UML class diagram(UML 類(lèi)圖). This is included to show that an execution of a process can be represented as data. This is actually the crucial(至關(guān)重要的) part of making an execution persistable.
Now, we'll explain how the execution of java can be coupled to the execution of the graph. The next image shows the methods in Node and Transition that are involved in graph execution. To calculate the next state of an execution, we propose(計(jì)劃) a modified version of the chain of responsibility pattern(責(zé)任鏈模式) as described by the GOF 'Design Patterns' book.
The Nodes in the graph can represent wait states. During a wait state, a Token points to that Node. Each Token that is in a Node can receive a signal. A Signal can be send to a Token to resume execution after a wait state is finished. This will cause the graph execution to start.
在圖表中的節(jié)點(diǎn)可以表現(xiàn)為等待狀態(tài)。在一個(gè)等待狀態(tài),一個(gè)令牌指向那個(gè)節(jié)點(diǎn)。在節(jié)點(diǎn)中每一個(gè)令牌可以接受一個(gè)信號(hào)。一個(gè)信號(hào)可以在等待狀態(tài)完成后,可以發(fā)送一個(gè)令牌來(lái)重新執(zhí)行。這將導(dǎo)致圖表執(zhí)行開(kāi)始。
A Signal is the trigger that resumes graph execution. 信號(hào)是再繼續(xù)圖表執(zhí)行的觸發(fā)器。
The effect(結(jié)果) of this signal is that the Token will leave the node. In case(萬(wàn)一) the node has more then one leaving transition, the leaving transition has to be specified as part of the signal. Transitions just take a Token to the destination(目的) Node. When a token arrives in a Node, the Node is executed. Each node in the graph is of a specific type that determines(確定) its runtime behaviour. Each node type corresponds to a subclass of Node and the behaviour is implemented in the execute-method.
The node's execute-method has 2 responsibilities.[節(jié)點(diǎn)的執(zhí)行方法有兩個(gè)責(zé)任] First, it can perform some business logic, related to the type of the node. [首先,它可以運(yùn)行一些商業(yè)邏輯,關(guān)系到節(jié)點(diǎn)的類(lèi)型]E.g. sending a message, updating a database, creating a task for a user,...[例如發(fā)送消息,更新數(shù)據(jù)庫(kù),為用戶(hù)創(chuàng)建一個(gè)任務(wù),......] And the second responsibility of the node's execute-method is the propagation of the graph execution.[節(jié)點(diǎn)執(zhí)行方法的第二個(gè)責(zé)任是傳遞圖表的執(zhí)行] If the node does not propagate the execution, it behaves as a wait state.[如果這個(gè)節(jié)點(diǎn)沒(méi)有傳遞執(zhí)行,它將作為一個(gè)等待狀態(tài)。] It can propagate the token that arrived in the node down(沿著) one of the leaving transitions. Or it can create new Tokens and propagate those down the leaving transitions.
Graph execution ends when all tokens have entered a wait state.[當(dāng)所有的令牌都進(jìn)入等待狀態(tài),圖表執(zhí)行結(jié)束] At that time, the signal has been completely processed and the complete process execution (that is made up of a tree of tokens) enters a new overall(全面的) wait state. At this time, the tree of tokens can be persisted. Each token is now waiting to receive another signal.
One crucial(至關(guān)緊要的) refinement(精要) of this model is necessary : Actions(行為 動(dòng)作). Actions are pieces of java code that are executed upon events in the process.[actions是在進(jìn)程中事件之上執(zhí)行的java代碼片段] Examples of events are 'leaving a node', 'entering a node' and 'taking a transition'.[示例事件包括“離開(kāi)一個(gè)節(jié)點(diǎn)”,"進(jìn)入一個(gè)節(jié)點(diǎn)"、“接受一個(gè)轉(zhuǎn)變”] These are all instantanious events that cannot span(跨越) wait states.
The refinement of the graph execution model with actions is necessary because this allows the technical developer to add implementation details to the business process, without having to change the graph that was originally(最初) created by the business analyst.
Now we can summarize how this model solves the traditional problems of workflow, BPM and orchestration solutions.
Simple API + chain of responsibility: replaces monolithic systems. 簡(jiǎn)單API+責(zé)任鏈
Inheriting from Node: gives ultimate(最終) process language power. 從節(jié)點(diǎn)中繼承
Adding ‘invisible’ Actions: gives modelling freedom to the business analysts. 加入不視行為
Process development cycle: replaces visual programming. 過(guò)程開(kāi)發(fā)周期