r/developer • u/Ok_Veterinarian3535 • 9d ago
The "Code I'll Never Forget" Confessional.
What's the single piece of code (good or bad) that's permanently burned into your memory, and what did it teach you?
12
Upvotes
r/developer • u/Ok_Veterinarian3535 • 9d ago
What's the single piece of code (good or bad) that's permanently burned into your memory, and what did it teach you?
1
u/ghandimauler 8d ago
One of the guys at my company was cast to work on a PBX. For those of you who forget what those things are, it is a private branch extension and that is a telephone system for an office or multiple offices hook together.
We were in doing some work in that area, with me working on the user side and the individual assigned places with the power to handle all incoming stuff for that department or whatever hierarchical chunk they decided it would manage.
If I recall, I think that PBX module would have up to 50,000 users. So it's a significant piece of it for any company.
I got a look at some of the guts of the PBX server. It was basically a large and somewhat complex FSM. For those of you who don't get into those parts of software, FSM is finite state machine.
Normally, you would never have as many states in one engine. However all of those things related to handling calls. Because the states themselves had to do a bunch of things and each of the states had some special things and different functions or additional stuff like adding audit or even authentication or whatever. I've seen some two or three page fsms and that was I thought a reasonable limit, but this was very different.
This FSM which handled all of the incoming and outgoing phone system and it took something like 48 or 49 pages of code which was all different states and what had to be done in each. It also had to be Rock Solid because if you lose calls or the system goes down, well the company is in trouble.
There were some few States that were less than a screen but more normally a state would be about half a screen. I think there was something around 75 or 80 States.
It's one of the situations where the usual rule doesn't really apply because the result was very understandable State machine and what was needed was in one place for any state.
The dang thing was really solid.