Canvas offers three generic blocks, which are multi-purpose and can be used in an any workflow:
The Join, Mapper, and Code blocks.
...
The Code block is a generic, all-purpose block for writing code that will run as part of your workflow. It is useful if you quickly need to add some extra code on a one-off basisto a workflow.
...
Even though the Code block can technically be used for pretty much any purpose, we recommend creating non-generic block templates if the code you are writing is specific to an application that will be reused in different workflows.
Block templates have the benefit of being a version controlled, more modular, easier to map (by defining data models), and they enable you to create user options that can be easily changed in the block options.