DEV Community

Discussion on: What’s your favorite piece of code that you had to throw away?

Collapse
 
cjbrooks12 profile image
Casey Brooks

I'm right on the cusp of deleting thousands of lines of code and templates from my documentation engine, Orchid. It's some of the oldest code in the project, focused around calling external documentation tools like Javadoc so that it can make much nicer code documentation. And I can't wait to finally go live with this and remove all that old cruft!

I have abstracted those portions of code into a separate library, and the process for adding new languages now involves modifying that library and writing a tiny adapter from it to Orchid. That's it! Previously, each language needed its own set of HTML templates and a lot of boilerplate to call to these external tools, but now they are all the same code underneath, just going through these adapters.

Moving forward, it will be significantly easier to support new languages since I don't need to write nearly as much boilerplate, and don't have to worry about new templates at all. Plus, since the documentation-formatter no longer needs to know about Orchid, it is easier to maintain since it's just pure data now. A very clear separation of concerns makes this whole process much better, but it has been quite thr journey to get to this point!

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Yes! You nailed the point. Old code needs to go so new code can live! :)