Probably my favorite thing about programming is making a program better. It is a process of constant improvement. Getting a new program to work for the first time is exciting, but perhaps even more fun is sharing more code within a program.
Recently I had two features in a program, and they both had the same basic concept behind them—generate output files from source files. I realized that the two features could share a lot of the underlying infrastructure. Code reuse has many benefits in programming:
As for my program, by rewriting one feature to use existing code from another, I reduced code size from 1000 to 300 lines of Rust code. Having to maintain code is not necessarily a bad thing, but having less to maintain is easier.