If you can’t explain how your code works, how can somebody else maintain it? Do you want to get stuck with the job of maintaining your old code? Every time a change is needed, do you want to figure it out over again well enough to get the change to work?
I once had a student who asked me to help him debug some of his code. I looked at it.
“Why do you need these variables here?”
“I like them. They make the code look more like Pascal.”
“Why do you use this pointer when you never change it?”
“I might want to change it someday.”
“This routine is 16 lines long. Why not divide it up into a bunch of simple routines, none of them more than two lines?”
“If it looked simple, anybody could understand it. I want to write it so that everybody can see I’m real smart.”
“Then simplify it until it works, and then add an the complications later.”
His career has been far more successful than mine. Maybe he was doing the right thing.
If you can’t explain how your code works, how can somebody else maintain it? Do you want to get stuck with the job of maintaining your old code? Every time a change is needed, do you want to figure it out over again well enough to get the change to work?
I once had a student who asked me to help him debug some of his code. I looked at it. “Why do you need these variables here?” “I like them. They make the code look more like Pascal.” “Why do you use this pointer when you never change it?” “I might want to change it someday.” “This routine is 16 lines long. Why not divide it up into a bunch of simple routines, none of them more than two lines?” “If it looked simple, anybody could understand it. I want to write it so that everybody can see I’m real smart.” “Then simplify it until it works, and then add an the complications later.”
His career has been far more successful than mine. Maybe he was doing the right thing.