The First and Second Laws of Programming
The First Law of Programming
Don’t.
Instead, see if someone has already written a version of the program that you can adapt. If not, see if someone has written a program like what you need that you can adapt.
The Second Law of Programming
If you do, do it right.
If no one has ever written a program like what you need, and you really must write it fresh, then spend a lot of time and effort on it so that your program can be adopted or adapted by people who come along later trying to follow the First Law.
-Adapted from the writings of Jim Hefferon, author of my favorite Linear Algebra text.