I don't get what people dislike about a 100+ line method/function/subroutine if it has no reason to be split and it the chuncks in the sub have been well separated and commented.
I agree that long subroutines aren't necessarily evil. It depends on the case: You have listed some conditions... which quite often aren't met in old code. Subroutines grow, because, let's just add a small feature here, because of why not, only one source file to be changed, and then there's another edge case to be covered, let's just copy that check from the other file where it works just fine. So in my experience long subroutines are often due to "maintenance with small commits", so to minimize the effort for code/patch review, and not because the subroutines were designed that way.
BTW: My most recent bugfix was in a 1120-line sub, mostly written in the previous century, and guess what: Now it has 1123 lines. And I'm not going to split it anytime soon.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|