Table of Contents

Parameterize low-level Performables

When writing low-level Performables, these classes should expose parameters which allow the consumer to provide as many of the variables as make sense. This is especially important for Actions and/or Questions but also relevant for lower-level/reusable Tasks.

Parameters should be accepted via the class' public constructor, the values to these parameters should then be held readonly. Accept as many parameters as are reasonable, although avoid going so far that parameterisation makes a Performable unclear as to what it does.

Performances are written a lot like scripts. They very rarely (and should not) contain a lot of branching or looping logic, which means that a performable which changes behaviour based upon a parameter value is of very little use. It is better to separate the logic into individual performables and to just use the one which is needed at the time.

An example

Imagine we are writing a Task which makes a cup of coffee, ready to serve. It would make sense to include parameters which decide the strength of the coffee, how much milk and sweetener to add and similar.

It would usually be a mistake to create a Task which can make any hot drink, where the parameters provided decide which hot drink to make. The processes for making various hot drinks are often fundamentally different; consider the process for making coffee and then that for brewing tea.

In the most extreme case, where such a Task is required, separate the logic of making of each hot drink into Tasks of their own, and consume/execute the relevant one of these from the any hot drink Task.