Skip to content

nanw1103/context-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

Context Programming

Background

A functional program is a program that consists of multiple functional steps, with certain execution orders, to complete a task. To be distinguished from daemon-like programs. A run-and-exit script or a workflow are typical examples of a functional program.

What is Context Programming

Like a typical computer that consists of input, output, control unit, compute unit, and memory, a functional program could be structured as profile, context, steps, and orchestrator. As Context Programming pattern.

Concepts Explained

  • Profile: The input of the entire module. The one-piece concept of profile simplifies the interface and helps integration. Profile is read-only. Similar to configuration file.
  • Context: Runtime generated states, shared between Steps, normally persisted. The context depicts a unified path for data interchange between steps. Context is persisted to help retrive and replay Steps.
  • Steps: fine-grained operations that read from the profile and read from/write to the context. Ideally, each step is executable individually.
  • Orchestrator: streamline the execution of multiple steps according to workflow or condition, generally as the unified entry for the entire module.

The Context Programming Pattern

The Core of Context Programming

Context Programming helps to achieve a shallow learning curve and low maintenance cost via unit operability.

  • Unit-operability: Every unit (step) is executable because all required inputs are from profile and context, which is available anytime if persisted. The unit-operability enables single-unit execution, so minimize the testing and debugging effort, by shifting bug discovery from integration verification to unit verification. The more complex the integration is, the more value this point holds. Identifying an issue during integration is more costly than identifying it earlier in the unit verification phase.

  • Shallow learning curve: By separating the whole task into isolated steps, each part will be more straightforward to understand, change, and add. Steps are normally organized intuitively.

  • Low maintenance cost: In many cases, development and maintenance are vital parts of the program lifecycle. An easy-to-understand program is likely easy to maintain. The pattern by its nature leads people away from overwhelming abstraction or wrapping.

  • Integration matters: As a functional unit in the manner of a black box, it's easy to be integrated with other systems.

Example

WIP

About

A pattern for resumable script module.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published