Re: Holy boop: goto for Java
On 6/5/12 9:15 AM, Gene Wirchenko wrote:
NO! Pulling some code out to make it a method that is called
ONLY ONCE is what I object to. (I might do it if there is
clearly-delineated functionality that could be useful again (but just
happens to be needed but once when it written)). I will not do it for
some manifesto.
Code re-usability is the great lie that has become the manifesto, not
pulling out a once-used method.
You don't create a method, or a class, or any other abstraction just so
that it is reusable. You create abstractions so that it is easier to
manipulate the software without breaking it. Yes, if you have the same
code in 3 places, pulling it into a method creates "reuse", but the
reason you reuse the code is so that changes to it appear *everywhere*
they should. Otherwise copy and paste would be an acceptable method of
code reuse. And its not.
My philosophy on designing software is make it correct, make it simple,
make it pretty, make it fast. Usually (but granted not always) if you
start from the left, you'll end up at the right much easier than
starting at the right and going left.
If making it simple or pretty involves pulling out a simple one-line
method that isn't used but once, then so be it. If pulling that method
out makes it uglier, then I don't do it.