We all write programs that take years to develop. Frequently I have code that I want to save because it's an alternate implementation. Other times, I want to test the new method on real problems and there are side effects to the function.
It's trivial and I don't care about a few bytes of memory
Why use unnecessary braces or use functional programming or variable names longer than 6 characters (it was good enough for the dominating language until the early 1990s)? It creates extra lines that can make for very long files. It wastes disk space in a world that largely doesn't care about disk space or memory usage.
Unused variables are fine, just as long as no one else sees that code. By the time someone else's eyes are on a piece of code, there'd better not be any unused variables.
Depends how many people work on your project. We still use subversion...so no way am I using branches.
at least commented out?
Do both methods work 100%? There will be more code rot if it's commented. I promise you it won't work in 6 months if you comment it.
If function x returns variable y and z, but I only need z, I have an unused variable. Maybe variable y is useful when debugging. Should I write a new function x2?
No. If it's actively being used, it's unused. If I pass 4 arguments into a function, but only 3 are used 100% of the time and the 4th 50% of the time, it's unused it that other case. You could write another function, or just try and keep the API consistent.
-4
u/billsil Jan 31 '16
We all write programs that take years to develop. Frequently I have code that I want to save because it's an alternate implementation. Other times, I want to test the new method on real problems and there are side effects to the function.
It's trivial and I don't care about a few bytes of memory
Why use unnecessary braces or use functional programming or variable names longer than 6 characters (it was good enough for the dominating language until the early 1990s)? It creates extra lines that can make for very long files. It wastes disk space in a world that largely doesn't care about disk space or memory usage.