The implementation of SilClient in firmware/validation/sil/sil_client.cc is very repetitive. The Register___ and Read___ and Set___ methods are all almost identical with a few small differences.
This task is to abstract out the commonalities.
Tasks
Abstract out common logic. Look at the functions listed above. Move any repeated code into a new private function. For example, you might have RegisterDigitalOutput and RegisterAnalogInput call the same private function RegisterIO to handle the common logic.
IMPORTANT the public interface of SilClient must not change! We should not need to rewrite the projects which use SilClient.
Make PR with your changes.
We may take this effort further after you complete this task. I could see us defining peripheral classes which all implement Register() and Read() or Set(), allowing us to use polymorphism instead of defining multiple handler functions.
SIL Polymorphism
Description
The implementation of
SilClient
infirmware/validation/sil/sil_client.cc
is very repetitive. TheRegister___
andRead___
andSet___
methods are all almost identical with a few small differences.This task is to abstract out the commonalities.
Tasks
Abstract out common logic. Look at the functions listed above. Move any repeated code into a new private function. For example, you might have
RegisterDigitalOutput
andRegisterAnalogInput
call the same private functionRegisterIO
to handle the common logic.IMPORTANT the public interface of
SilClient
must not change! We should not need to rewrite the projects which use SilClient.Make PR with your changes.
We may take this effort further after you complete this task. I could see us defining peripheral classes which all implement
Register()
andRead()
orSet()
, allowing us to use polymorphism instead of defining multiple handler functions.