A major idea of agile software development is that developers use techniques like TDD and Pair Programming together with design principles like the SOLID principles to create high quality, clean, easy and fast to change code. There is actually a deal between developers and management:
Management doesn't put stupid rules on the way developers work (like every 'public method has to have a comment'), for that the developers produce awesome code fast.
I don't know about you but that deal seams to be tough on the developers. Anyway in many cases the developers appreciate the trust, try their best ... and screw up.
As a reaction management looks at what went wrong, only sees some symptoms, like methods that are in bad need of a comment and create rules for the developers. Due to the rules developers are even less able to create awesome code, triggering another failure, triggering more rules and so on.
Obviously there is something wrong in the beginning. Why are the developers tasked with a job that is obviously to difficult for them, why don't they have help? Lots of questions, lots of possible answers.
Lets look at it from the point of view of one of the developers, possibly a junior one. What can he do in order not to loose the trust of his manager?
In theory there is the option of rejecting the task. But would a junior developer do that? It is certainly difficult, and it might not be wise because you can't be sure about the reaction of the manager. She should be happy to learn about a problem early on but that doesn't mean she will.
But what you can do, even as a very junior developer is: Ask!
Ask if you understood the requirements correctly.
Ask if somebody with more experience can do pair programming with your.
Ask if the code you wrote so far is ok, or even better: How you can improve it.
Ask early ask often.
Don't write 20 classes before asking if this is the correct approach.
Don't stop asking because you think you know what you are doing.
Asking is a powerful way of learning.
If you grow better and more experienced asking is also a great way to lead. So there is hardly a reason to stop asking.
If your manager is worth her money she will listen and she will learn if you are on the right track and she will be able to trust you that you don't make stupid stuff but do your very best to produce good or even great results.