AI / Apache Burr Interview questions
When should you use the class-based Action API instead of the function-based one?
Reach for the class-based API, subclassing Action, when you need inheritance (sharing behavior across a family of related actions) or want to parameterize an action in ways richer than a simple bound value — for example, holding configuration on self and using it across run and update.
It also gives you finer control: run and update are separate methods, so you can add logic between computing a result and committing it to state, and you can declare optional inputs with a (required, optional) tuple, which the function-based API can’t express as cleanly.
The function-based @action decorator remains the better default for something quick and terse that reads a fixed set of state variables and doesn’t need to be subclassed — it is more concise because run and update collapse into a single function.
More Related questions...