Home
Blog
Sharing More Code
Updated
Dot Net Perls

Sharing More Code

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:

It reduces program size.
It uses more well-tested code that already exists (as from a framework like .NET or a crate in Rust).
It has a lower maintenance burden, as the existing code is already being maintained.

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.

Dot Net Perls is a collection of pages with code examples, which are updated to stay current. Programming is an art, and it can be learned from examples.
Donate to this site to help offset the costs of running the server. Sites like this will cease to exist if there is no financial support for them.
Sam Allen is passionate about computer languages, and he maintains 100% of the material available on this website. He hopes it makes the world a nicer place.
An RSS feed is available for this blog.
Home
Changes
© 2007-2025 Sam Allen