Writing bad codes is how someone improves. I feel that with time people realise that what they are doing is wrong and change it for better.
Having a mentor to guide you when you are working on a project is the best way to improve the architecture of the project.