That is why it's important not anchor your identity in the transient. The world is full of people who do and it invariably hits them hard when things inevitably change: Mothers with empty nest syndrome, ageing people clinging desperately to their youthful good looks, jobless and retired people who find their self-esteem smashed and consider themselves useless.
It helps if you clearly define the roles you play in your life: a husband, a father, a brother, a friend, a software dev, a jogger, a cyclist, a member of the local club, an avid collector of y and, above all, a person who can create new roles and find new places for yourself.