Closed iandanforth closed 6 years ago
What kind of information will the user provide?
Setup
Runtime
What kind of information will the API provide?
What are the logical divisions in the functionality?
Outer class
How does a user write a plugin for this library? If they can't how do they extend it?
They should be able to swap in alternative motor neuron models and fiber models.
motor_neuron_intrinsics = gen_motor_neuron_intrinsics(
motor_neuron_model_prop_1,
...,
motor_neuron_model_prop_n,
motor_neuron_count
)
fiber_intrinsics = gen_fiber_intrinsics(
fiber_model_prop_1,
...,
fiber_model_prop_n,
motor_neuron_count
)
motor_neuron_output = calc_motor_neuron_output(
step_size,
motor_neuron_intrinsics,
motor_neuron_fatigue,
motor_neuron_input
)
motor_neuron_output_history = update_motor_neuron_output_history(
motor_neuron_output_history,
motor_neuron_output
)
motor_neuron_fatigue = calc_motor_neuron_fatigue(
step_size,
motor_neuron_intrinsics,
motor_neuron_fatigue,
motor_neuron_output_history
)
fiber_output = calc_fiber_output(
step_size,
fiber_intrinsics,
fiber_fatigue,
motor_neuron_output
)
fiber_output_history = update_fiber_output_history(
fiber_output_history,
fiber_output
)
fiber_fatigue = calc_fiber_fatigue(
step_size,
fiber_intrinsics,
fiber_fatigue,
fiber_output_history
)
fiber_fatigue = calc_fiber_recovery(
step_size,
fiber_intrinsics,
fiber_fatigue,
fiber_output_history
)
This mocks out three classes:
It also has a pseudo-code implementation for what calling step() on a muscle does to advance the state of the simulation.
Design Guidelines
The most important thing is to have empathy with your primary target audience and constantly ask yourself what makes most sense for them in their perspective. This applies to everything, from the first moments reading the README.md examples to the corner-case use cases of the API. The Principle of Least Surprise applies strongly here.
What problem does it solve?
It enables a more accurate and dynamic model of the relationship between control signals and force output. It manages the stateful, time-dependent relationship between control signals and changes to motor units. This can be coupled with a simulation of the muscle body to capture the full control signal to force output relationship.
What is the level of abstraction?
The collection of motor units which form a muscle.
What problems does it not solve?
What are the major tradeoffs?
Accuracy vs Speed.
The goal is to capture the complexity of the problem that biological creatures are faced with, while being fast enough that useful interesting research can be done quickly.
Pros
More accurate. More dynamic.
Cons
Slower than a purely linear relationship. Complexity might not be needed.
Keep the library user comfortable in using your library in the right way, while making him cautious in using the library in the wrong way.
4.1. Short names
4.2. Common words
4.3. Long names for 'incorrect' way of doing things.
e.g. dangerouslySetInnerHTML
Be always mindful of the types
So, write the type signatures.
What kind of composability strategy you are using?
OOP
a.k.a. stay Pythonic
Guidelines by Andre Statlz