2 ms·
I've refactored monolithic code several times in my career. It starts with a thorough going-over, making notes, identifying the state machines and drawing what
by JoeAltmaier 5y ago
I've refactored monolithic code several times in my career. It starts with a thorough going-over, making notes, identifying the state machines and drawing what was handled and what was not.
Then, reimplement as a simple state machine but this time, fill in all the transitions (event+state => new state + action)
One was an Infiniband code base from the vendor - a 'computer scientist' had written several layers to do what one or two could accomplish. Another, the Windows CE DHCP client (went from seconds to choose an address to milliseconds). Then there was an HDLC modem protocol - I got done, that was sped up a multiple and no longer crashed.
I can't understand them by just reading. I had to make a road-map of all the states, events, actions and interfaces. Design a new code. Then make sure every function of the 'old' code was represented in the new code - line by line. So nothing got dropped.
Satisfying. But more like turning the crank and making sausages than design or architecture.
- mbrodersen 5y agoI like your approach. Having a clear understanding that all software is just state machines is a great way to solve hard problems.