"if you program and want any longevity to your work, make a game. all else recycles, but people rewrite architectures to keep games alive." - _why
I think the key is to make it as abstract from the system and algorithmic as possible. For example, with image processing, you have a small GUI component and you have a small image type to RGB converter, and the majority of the code is algorithmic RGB array to processed RGB array code. Algorithms don't decay much, but GUIs and file types do, so software that is very tool like and algorithmic has much more longevity as long as the small non algorithmic components are updated occasionally.
I'll add games to enterprise software as the two places where you'll have the most longevity for your code.