TrueBlocks / trueblocks-core

The main repository for the TrueBlocks system
https://trueblocks.io
GNU General Public License v3.0
1.05k stars 194 forks source link

Over abstraction removes ability to auto generate code #3708

Closed tjayrush closed 1 month ago

tjayrush commented 1 month ago

This is just a reminder that to the extent that we abstract code (as we did in the chifra slurp code, we make it much more difficult to auto-generate the code.

It's not by accident that every command has a Handler by the name of HandleX (where X is an --option) and that the structure is called XOptions (such as BlocksOptions). This is because that allows for much easier auto-code generation.

It's also not by accident that each Handler has an area near the start of the function for setup, then the fetchData function, then the StreamMany call. To the extent we can make this code structure the same in every case, we can make auto-code-generation much, much easier. This leads to much more consistent code.

Having nearly identical code in every Handler also allows for copying and pasting from one handler to another and then looking at the code diffs.

Another consideration is cognitive load. If each Handler has its own structure, then a reader of the code must adjust each time a different Handler is encountered. If they are all identically shaped, the reader quickly learns to ignore the boilerplate.

The general idea is to preserve the ability to auto-code generate even if the code looks less elegant. The elegance comes from the auto-code generation.