## Programming by Formula for Python
## As easy as a spreadsheetYoopf for Python is an open-source module that enables object-orientedprogramming by formula within Python, dramatically accelerating the development of the model in the Model-View-Controller architecture. Models written in Yoopf are considerably shorter than their equivalent written in Python. Also, Yoopf formulas can be stated in any order, reducing the risk of error. When the formula calculator is called, it updates all impacted objects by applying the formulas in the right order. Yoopf can be compared to business rule engine (e.g. Versata); declarative, dataflow or reactive programming; spreadsheets (e.g. Quantrix); stored procedures and database triggers. ## What it doesThis formula can be fed to Yoopf to define the total amount of each Order object as the sum of the amount of its order lines: `Order.amount = sum(Order.order_lines.amount)` Yoopf will then monitor these objects thanks to the introspection capability of Python. Based on input from the User via the View part of the application, the Controller part of the application will insert new order lines or modify the amount of a line. It then asks Yoopf to run the model : Yoopf will then calculate the total amount only for the Order objects that need recalculation (i.e. because one of their order line has been added or deleted, or the amount of a line has been changed) . So, after the model is run, Yoopf guarantees that the total amount of all orders will be correct. The controller can then access these objects to create the response to the user. A model consists of several such formulas, of various types: - Calculation within one instance
- Relations formula, e.g. to determine the order lines of an order
- Error formula, e.g. to check that the quantity on an order line is positive
- Lookup formula, e.g. to find the sales tax applicable to an order
- Aggregation formula, e.g. to calculate the total amount of the order
- Creation formula, e.g. to insert accounting entries when the order is confirmed
- Deletion formula, e.g. to delete an order if not confirmed after 30 days
- Call of object methods, e.g. to send an e-mail when the order is confirmed
- Workflow formula, e.g. to define the approval workflow
To probe further, see Why Yoopf ? "
" - Johan Zwiekhorst, Data NewsIn our opinion, this is a brilliant idea |