cfgr separates logic from data
Project description
cfgr
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cfgr-0.0.2.7.tar.gz
.
File metadata
- Download URL: cfgr-0.0.2.7.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62e2b47c5c0218fab49c5aed0fa867afd01cc7a9ecac54d62936172e5bec1597 |
|
MD5 | f3e00e383fa28734d425ddba52f6e895 |
|
BLAKE2b-256 | 46068823ef3c5883676660da6ac5e90c753c6c21424e652d2b92a566b462a540 |