It's only obsolete when it hampers your productivity.
If what bothers you with your current computer is something that would be provably solved with a newer one (battery life, heavy CPU/GPU tasks...), then it's time for a replacement. I've also quickly replaced computers I hated keyboards or screens on.
Some things related to modern environment can not be helped though (no matter how fast your computer, docker-based dev envs will be slow to start up, where slow is contrasted with instantaneous).
When running a company and looking to replace computing equipment, a number of other variables come into play (due to amortising costs and such).
Am averaging 4-5 years with MacBook Pros though I made an exception and got an M1 MacBook Air when that came out. Have an array of MacMinis still in use dating back to 2012. Debating whether or not to upgrade the sole Windows laptop I have (2017 Thinkpad X1). Most of the programming I do is run on servers, I rarely compile on my systems except for personal use toys.
https://hn.algolia.com/?dateRange=pastYear&query=x220&type=c...