How I saved thousands of lines of code - Functional Hook Composition for Everything
Zhenyu Lin
Posted on March 11, 2020
https://github.com/opbi/toolchain
There're a large amount of semi-automatable codes in most production codebases, especially around input validation/null check, error/exception handling, observability anchors(log, metrics, tracing) and various other elements to thread functions together to achieve business goals stably. All those are essential for production code, while they are slowly corrupting the readability/maintainability of the codebase, incurring huge communication cost between teams due to a lack of common standards. Fortunately, without AI, it is still possible to automate some of those common programming actions with a standard.
With the power of function composition in Javascript, it becomes very simple to modularize those control mechanisms in the form of well-tested reusable decorators. This makes the core business logic functions extremely concise and easy to read/test/migrate.
I'm working on a new library to standardise a pattern to add reusable hooks to functions to configure their behaviour so that functions can be precisely about the core business logic. This would greatly improve the readability, testability and maintainability of a codebase.
It is currently at its very early stage while have been proofed in a production server. Any feedback or contributions would be welcomed.
Posted on March 11, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
March 11, 2020