We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Refactoring a Large Legacy Elixir Module for Readability and Testability
209
clicks
Source: youtube.com
Arnaldo Cesco's talk at Code BEAM Europe 2023 centered on the process of tackling a substantial legacy Elixir module that was originally part of a larger product. Cesco described the challenges of refactoring this 'behemoth' of a file known as 'imp.ex,' famously difficult to work with due to its complexity and length. The module in question draws parallels to a mythical creature from the Old Testament, symbolizing its monstrous nature within their codebase. The refactoring strategy employed by Cesco involved the application of the 'functional core, imperative shell' design pattern to separate domain and machinery complexities. His approach focused on isolating small, pure functions that form the core logic, thereby facilitating testing and improving code readability. Cesco also put emphasis on clarifying types within the code, potentially paving the way for future type inferences. Additional strategies included using the command pattern to manage state and make it more distributed, aiming to crash early in case of missing record values. The talk highlighted the importance of having small, tested core functions, making the tests readable and repeatable, and setting default fixtures to clearly define tested values. Overall, Cesco's effort aims to make the codebase more maintainable and scalable.
Related posts
© HashMerge 2024