Skip to main content

cfgr separates logic from data

Project description

cfgr

Build Status

Install

pip install cfgr

What is it?

pycfgr is part of a cross-language exploration in search of new ways to create software systems.

Other repositories that perform similar (but not -yet- compatible) research;

Cfgr provides a set of APIs that encourage separation of configuration from logic. It helps organising the application logic in small, modular components and lets you put those together through configuration (json) files to create complex systems.

The approach borrows concepts from Visual Programming Languages (VPLs) which generally let you create instances of pre-built building blocks and connect them together to perform complex tasks. These concepts are translated back into a text-based workflow.

MaxMSP Blueprints TouchDesigner

three famous examples of VPLs (from left to right); Cyling '74's Max, Unreal Engine's Blueprints and Derivative's TouchDesigner

Why?

  • A text-based workflow using standard formats (like JSON) allows for the most flexible/customizable development pipelines and benefit of massive set of available tools (version control systems, text-editors, IDEs, command-line, ssh, etc.).
  • Separating configuration from the logic provides possiblity to make and actuate changes at runtime (from minor properties to major application structures).
  • Removing configuration (as much as possible) from your application code keeps the code clear and concise.
  • Enforcing a modular component structure encourages best practices like the single responsibility principle and writing modular code that is truly reusable.

Some history

Motivation for this exploration came from many years of experience in professional software development, specifically non web-based UI software development in C++ and Java using frameworks like OpenFrameworks, Cinder and Processing and noticing patterns of repetition, both in code and in general workflow. This experience lead to, initially, the JavaLibUiBuilder which builds on top of a UI framework (JavaLibUi, inspired by the ofxInterface library for OpenFrameworks/C++), which started the concept of building and configuring application logic from json config files (which feels a bit like writing CSS from a web-page).

This concept was translated into C++ using in the ciCMS package for the Cinder framework and extended to provide "native" events and states to further reduce the amount of custom application code that needs to be written to make the different components communicate.

Examples

Hello World

Below is an example of what an Hello World implementation could look like. Obviously this level of abstraction doesn't make much sense in a HelloWorld scenario, but it demonstrates the concepts of configuration, logic, components and events.

cfgr.json (config)

{
  "App": {"started":"#appstarted", "stop":"#stopapp"},
  "App.String": {"value": "Hello World!", "in-emit":"#appstarted", "out-emit":"#sayhello,#stopapp"},
  "App.Print": {"on": "#sayhello"}
}

Invoke the above configuration using the default cfgr.app:

python -m cfgr.app --data ./cfgr.json # uses the default cfgr.app runner

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfgr-0.0.2.6.tar.gz (15.9 kB view details)

Uploaded Source

File details

Details for the file cfgr-0.0.2.6.tar.gz.

File metadata

  • Download URL: cfgr-0.0.2.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

File hashes

Hashes for cfgr-0.0.2.6.tar.gz
Algorithm Hash digest
SHA256 455ec42f8565d89e2285d5bf5c0fa13a18ea8fcbfd46dfddd3bc349ba5fff086
MD5 9537056449fa0827b05fd2d2397eb8cd
BLAKE2b-256 c8dda8e02ed0c440530ee4864cec29c9e41a06cc511302f2ed385b8696709ec2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page