It is in the interest of the customer to define and specify what it wants as much as possible.
In more formal environments it is normal to have a requirements specification as a point of entry for developing the SW, and the first output by the contractor should be not code, but technical documents describing how this requirements are going to be met, how they are going to be tested, the technology used...
Of course this is a process that require additional effort and time, not only on part of the contractors but from the customer as well (in terms of requirement definition and review).
What I'm saying is that there are well known processes and methodologies to deliver SW products, and it's up to the customer to define what it wants, and to what detail, and up to the contractor making sure that he has a clear idea of what he is going to get.
In more formal environments it is normal to have a requirements specification as a point of entry for developing the SW, and the first output by the contractor should be not code, but technical documents describing how this requirements are going to be met, how they are going to be tested, the technology used...
Of course this is a process that require additional effort and time, not only on part of the contractors but from the customer as well (in terms of requirement definition and review).
What I'm saying is that there are well known processes and methodologies to deliver SW products, and it's up to the customer to define what it wants, and to what detail, and up to the contractor making sure that he has a clear idea of what he is going to get.