Elektrine lite

← Feed

@stuartl@mastodon.longlandclan.id.au

Post #2391485

2025-11-22 05:06 UTC

@deech@mastodon.social @Routhinator@tenforward.social Lucrative, but maddening. I had a Python project landed on my desk written by a dynamic duo of non-programmer power engineers that thought they could write a comms driver with no design spec and minimal programming experience. The lack of experience makes me wonder if an early ChatGPT also had a "hand" in it. - The driver spoke to a Siemens S7 PLC system - It received RFID data from a number of RFID readers - It married the data up between the two then stuffed it into a database They decided that threads were the solution, big 1000-line functions that run a `while True:` loop in separate threads. To talk to the Siemens S7 PLC, they used the open-source `snap7` library. Did they check whether said library was thread safe? Of course not! I managed to get things to the point where it didn't corrupt memory and worked most of the time, and for a while it became "my" (very much unwanted) baby. I managed to break the monster functions into classes, with some common logic in a base class that meant I could unit test things, and got the code coverage up to something respectable… but to this day, there are things none of us understand about how that monolith of code actually works.

Replies (1)

  • @stuartl@mastodon.longlandclan.id.au @deech@mastodon.social that sounds like the ultimate "spaghetti" code, but in this case the noodles are threads.

    Open ##2391486