Should I defend walls?

Hello,
N00b here,
the question is in the title. When I am walling, should I see it as a temporary measure to gain time or as a long-term investment?

In other words, when walls are attacked, should I rush to defend them, or rather focus on making a bigger army waiting for the ennemy to break in?