Hi,
I suppose rather than continuing this discussion on the no of lines a method could/should have.
We could list the pros & cons of having a method with too many lines or having too many methods do the same task.
This would leave the judgment in the hands of the individual & stop him/her worrying over the metrics.
|
regards,
Bala |
From: parlezuml@yahoogroups.com [mailto:parlezuml@yahoogroups.com] On Behalf Of Pradeep (Gmail)
Sent: Monday, February 23, 2009 5:48 PM
To: parlezuml@yahoogroups.com
Subject: Re: [parlezuml] Re: Method Length - How Long Is Too Long?
Oppsss....
Good debate!
Seems, the bench mark depends of the organization policies or the coding practice it follows.
What I have benched mark is a mix of many things.
Action points (do one thing of its own, but can call other members for performing its own action)
Restrict the line of code, basically try to set a boundary which fits in a one pan of your computer screen, + 10 lines max (now don't tell what about 19 inch monitors comparing 14 inch ones, take the current screen as the base)
It works fine on my organization level.
Regards
Ps
On Mon, Feb 23, 2009 at 4:49 PM, Bayley, Alistair <Alistair_Bayley@invescoperpetual.co.uk > wrote:
> From: parlezuml@yahoogrou
ps.com > [mailto:parlezuml@yahoogrou> Sent: 22 February 2009 18:00ps.com ] On Behalf Of jasongorman_uk What's your evidence? Earlier I think you suggested 5-10 lines as your
>
> Sorry to labour the point, but if I made the following statement:
>
> "Any method containing more than 5,000 lines of executable code and
> that will potentially need to be maintained by a human being is too
> long and needs to be broken down into smaller methods."
>
> During a court case for professional software development
> malpractice, who here would argue against that?
>
> Jason Gorman
preferred upper limit.
See the 2nd-last paragraph on this page (a summary of Code Complete,
which I do not have):
http://c2.com/cgi/wiki? LongFunctions
Looks like 50-200 lines per method is optimal.
"These are not the figures you're looking for."
I asked a similar question a while ago on the refactoring list; here's
the start of the thread:
http://tech.groups.yahoo. com/group/ refactoring/ message/1959
This is perhaps the most useful response:
http://tech.groups.yahoo. com/group/ refactoring/ message/1982
... where Jonas speculates that long methods are more likely to contain
duplicated code. Martin Fowler states, in Refactoring, that Duplicated
Code is the no.1 code smell (followed by Long Method :-) ), but he
doesn't say why, merely that "you can be sure your program will be
better if you find a way to unify them". At least Fowler gives arguments
against long methods, with the primary being that longer procedures are
more difficult to understand, but the actual studies seem to contradict
the very short methods advocated by XP & TDD exponents.
I'm wondering if the cost of duplicated code isn't as great as TDD'ers
think. If you assume that in long methods (>20 lines?) there will be
some duplication, then you could infer from the studies that said
duplication doesn't cost much.
Alistair
********************* ********* ********* ********* ********* ********
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
********************* ********* ********* ********* ********* ********
--
Pradeep Sen
India
Cell: +91-9701256663
------------
Its so Simple to be Happy, but, so difficult to be Simple! :)
To the question of your life, you are the only ANSWER
To the problems of your life, you are the only SOLUTION
Team work is all about, More of WE and lesser ME
------------
Sent from: Hyderabad Andhra Pradesh India.