Ugly Hacks (Feb 24)

In 1971, I dropped out of Cornell and built a very low-budget house. If you could call it that. It was pentagonal, with five trees as corner posts. 2x4s and plywood in between, with plastic for windows. Freshly-cut maple poles supporting plywood and 15# felt paper on the roof.

Then came a few years of ugly hacks to keep it livable, while building a better house next to it. The rafters sagged dangerously at the first heavy snow. Add a cross beam and post. Trees aren’t great for corner support because they sway in the wind. The tops had to go.  Soon, roll roofing to fix the leaks. Chipmunks, mice and squirrels kept living in the insulation, or they stole it. Many vain attempts to make walls rodent-proof. Etc.

The current Goldenseal accounting software also has some ugly hacks inside. In theory, one should thoroughly think out each problem, do the research, then come up with a robust solution. In practice, sometimes people just git ‘er done with the software equivalent of duct tape.

I mentioned refactoring recently. That’s what happens when you get tired of dealing with ugly hacks, and remodel the code to be clearer. Our staff has already refactored most of the really bad hack zones in the Goldenseal code.

But sometimes, the code isn’t important enough to deserve that much attention. So, more hacks join the pile. Getting screen and print layouts to look good is one of them.

For future use, we already rewrote layouts so they save data in text format. It’s easier to debug, and able to handle font names and file paths for images. That code is hack-free, and we can keep it that way.

Problem is, there are several hundred layouts in the old binary format. Modern fonts, buttons and fields are a little bit different, so fields and captions don’t line up very well. Nothing is terrible, but they aren’t great either. Our life will be easier if we can tweak them to look better before saving them into text. It’s temporary lipstick on a pig, and very hack-worthy. In a few years we can dump that code completely.

What makes it worse is that binary layouts are the last vestige of big-endian data. These days, every common OS is little-endian: it’s a technical detail for how bytes are ordered inside a 4-byte or 8-byte number. Pre-Intel Macs had bytes in a different order. The binary layouts can go either way, so there is rather hacky code to read them. It’s easy to get funky data because it’s backwards.

Meanwhile, I’m healthy and still testing negative. Still a Covid virgin.

Dennis Kolva
Programming Director
TurtleSoft.com

 

Author: Dennis Kolva

Programming Director for Turtle Creek Software. Design & planning of accounting and estimating software.