In programming you may need to apply multiple operation one after the other. Using a pipeline is one way to to this. (See Linux/Unix pipes.)
Any one of the operations could fail. The error needs to be recognized and dealt with.
To see an example of a pipeline of functions (operations) click HERE .
Maintain an inventory of product for a store in a CSV file. One item per line.
To see an example of a inventory CSV file click HERE . Use the file for testing.
In this project we are going to create a pipeline of functions. Each function performs a single task on the inventory and passes it to the next function.
The pipeline functions will ...
Use a @dataobject to contain the inventory information.
To see example code to get you started click HERE .
Inventory file are prefixed with their creation data (yyyymmdd). (i.e. 20231011_inventory.csv)
I suggest
Use JOSON data structure?
Each function that detects an error should
When a shortage detected, print shortages
each function should report what is doing and and other statistics (i.e. counts).
Create a pipeline and functions that can perform all of the above one at a time in any order.
This is a very artificial problem, but the purpose is to work with a pipeline of functions. If you would rather do a different pipeline project, talk to the instructor. They are always open to new projects.
Recode Project #1. Instead of each function testing for an
input of None,
use a try ... catch
block around the pipeline.
This could simplify the work functions and error checking.
The system's defined exceptions may not work well for your project. Define your own exception(s).
Create a menu to let the user decide the order of operations.
A GUI? Allow the user to drag-and-drop the functions they want and in the order they want? How do you execute code you create inside your program?
Note, This can be heavy computer science stuff.
What is a Monad?
What is a Functor?
Monad (functional programming)
(Wikipedia)
Functor
(Wikipedia)
Functional Programming
(Wikipedia)
Note, you don't need to know the computer science to use the concepts.