There are two ways to make yourself indispensable for your employer (as a programmer):
- Write code so obscure and undocumented as possible, making it impossible to fire you since no one knows how to do the things you do
- Write code so clean and easy to understand that anyone can work on it, by making yourself disposable
The first option is good for the lazy ones and those with no ambition. They will be stuck at the same job for years, doing the same thing every day and waiting for retirement. The second option is for those who need challenges and variety in their work. You won't be stuck maintaining code you wrote 5 years ago and your time will be spent solving new problems. It is clearly the more satisfying choice. You will be so useful for the company that firing you would be a huge mistake.