First off, when you say "better code" I'm going to assume that you mean that the general software quality of the project is better as opposed to any measure of the aesthetics of the code itself, although code that is easier to read generally results in better quality software.
One of the big area'sareas of study in software engineering research has been to see if there is a correlation between known requirements and defects, these. These studies shownshow that adding requirements or changing requirements of a system generally results in more defects. This tends to be boreborn out by other studies that show a link between changing requirements and schedule and cost overrun.
The core reasoning for most of these findingfindings boils down to knowing what is needed before handbeforehand allows for the system to be built to meet those needs and the system can be verified against those needs. This tends to work well in environments wellwhere the requirementrequirements can be explicitly defined, and tested, and failure is not an option.
So for at least some segments of software development it can easily be established that specifications result in better code. However, what
What about environments where the needs can change on a regular basis based upon business needs? In these cases it is important to note that Agile methodologies tend to be used more for internet development than for real-time, control, or systems development. Thus, Agile methodologies tend to target a different development space and we can speculate address different needs. Advocates for Agile development generally call for simple designs and refactoring as a means of ensuring that the code base does not become too complex which has been tied to software defects.
Overall, yes, foreknowledge of fixed requirements results in better code. However, but when the requirements cannot be fixed due to changing business requirements, that advantage is largely irrelevant as you may not be able to fix the system requirements long enough to code a major system.