Rob Cook


Home | GitHub | Dev.to | Donate | Contact

Abstraction


2025-11-05

We programmers have a tendency to abstract everything. I found myself writing a few little Java programs recently, and in each I needed to parse some command line arguments. Nothing crazy, just some simple commands and positional arguments. Ordinarily I'd reach for a library to do this. Yet another dependency in the program, doing more than is necessary for the task at hand.

Instead I decided to write the code myself. Rather than create an abstract thing to be reused, I wrote just the code needed to parse the arguments expected in each program. There was a little duplication of code between the programs, but honestly it didn't warrant a shared library to remove it.

Often times we don't solve the specific problem at hand, and instead solve a more general case of the problem. It is after all fun to tackle such tasks. Next time you feel the urge to do this, stop and ask yourself if it's really necessary. Is it really such a hardship to write the code for the more specific case and just call it a day?

end