The half-life of a software engineer

As a software developer, staying at the same company too long can be fatal.  It's easy for your skills to stagnate working with the same people and technologies, year after year.  On the other hand, a track record as a job hopper can be a red flag indicating a developer who can't fit well on teams and who doesn't have any experience maintaining the systems they worked on.   No company wants to invest in a new hire who will jump ship in 6 months.

From my own experience, I find that it takes about 2 years to complete a full cycle on a project.  At first, you come in and are just learning the domain and the code base.  Then there's period of developing fluency until you've completely mastered the codebase.  At that point, you'll be in a position to be able to contribute to project at an architectural level, leaving plenty of time to hang around and learn the lessons from these larger-scale efforts.  

Sometimes this cycle is faster, sometimes it's slower, but a couple years seems to be about right.  After that, something needs to change.  In a larger company, there may be opportunities on teams that are very different from what you are working on.  I've always worked for smaller companies, and often times this change comes in the form of an acquisition, which brings new challenges.  At one company, I transfered to the advanced research division of the acquiring organization.  In another, I tried my hand at evangelism/product management, making a transition back into engineering when I felt I really needed to spend more time coding.  In both of these cases, I ended up staying for 4-5 years.

I'm curious how this compares to other people's experience.