I am saying this since I am working on some code now and was making it poorly. Trying to make things "just work" mostly ends up with bad code.
Don't leave things up to rewrites. Write it well the first time (but at the same time don't be paralysed by trying to make it perfect, just make sure it is easily changed and well documented and tested).
@MOTT And don't rely on clever programming tricks.