But even this is not fail-proof. Remember the aphorism
there is no such thing as a portable program, there are only programs which have been successfully ported (to some particular platform)
With practice, discipline and a lot of experience, porting a program to another platform could usually be done quickly. But experience and know-how matters a lot.