Removing Code

I promise I’m not stealing the subject matter for today’s posts from Hacker News. This story got mentioned there today, but it’s something that I’ve kept in the back of my mind when coding for years.

It was this story that lead to the latest Woopsi changes. I’ve been trawling through the code trying to get rid of things that no longer serve any purpose or just clutter things up.

The first change is the removal of the FixedWidthFontBase class. It was needed by the Font and MonoFont classes, which were themselves removed in the last release. Other than in those two classes the FixedWidthFontBase class wasn’t used anywhere. It’s now in the “extras” folder in the SVN repository.

I’ve tidied up some of the Graphics class. The drawHorizLine() and drawVertLine() methods are now protected, and the drawLine() method will automatically detect if a horizontal or vertical line is being drawn and will call the faster method appropriately. All the benefits of the faster routines remain, but Woopsi now handles calling the right method without any developer intervention. The drawCircle() and drawFilledCircle() are similarly called automatically by the drawEllipse() and drawFilledEllipse() methods. These changes meant that the drawVertLine(), drawHorizLine(), drawCircle() and drawFilledCircle() methods in the GraphicsPort class were unnecessary and have been removed.

The putSDLPixel() and getSDLPixel() methods have been moved into the FrameBuffer class as they aren’t used anywhere else.

Finally, the TinyFont class is broken in Woopsi 0.99.2. That has been fixed.