D
Duncan
Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Duncan said:Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Duncan said:Hello
Can a single method with 1300 lines of code in it ever be justified.
Madness, sheer madness.
Most the time it is someone who is rather junior or never learned
not to do that sort of thing.
By the way, I think the largest I have seen is just over 2600 lines
for one method. This was in a utility program and not the main
application. It was created by a co-op student who oddly enough the
company hired full time when he graduated.
Andrew McDonagh said:As a guide my teams and I use - 7 lines of code per method (cause 7 is
an amount that is memorable apparently).
Andrew McDonagh said:No, never in an OO language, and hardly ever in most other paradigm
languages.
Large methods in the name of 'performance' is a complete mis-conception &
red-herring.
If performance is so critical that multiple private or virtual method
calls is a problem, then you'd usually swap into assembler code.
Because the actual sum cost of these method calls is far less than the
processing done within the large method.
VisionSet said:Was the pre or post 1.5?
If it was before, then perhaps now it should be 4 or 5
1.5 has made a massive impact on my method size, that 'for each' construct
is superb!
I think 7 is perhaps a little UTT though if I were to pick some magic number
I'd say max of about 10
Can a single method with 1300 lines of code in it ever be justified.
Andrew McDonagh said:As a guide my teams and I use - 7 lines of code per method (cause 7 is
an amount that is memorable apparently).
Its a guide not a rule, but once going over that limit we start to look
for hidden helper methods or classes. The majority of the time, our
methods are around 3 or 5 lines of code.
(a) there is an obvious SHORT
name for the new method
.... snip ....Monique said:I'm sure someone could come up with a pathological example.
The hard part, often, is figuring out the appropriate descriptive
method name.
Roedy Green said:long. When you start to code with tiny methods, a whole new world of
reusability and encapsulation opens up.
Jakob Bieling said:Only one question arose in my mind: When having many /many/ tiny
methods, you need the big picture of the project, or else you might end
up writing duplicate tiny functions. Or you keep spending time trying to
find out, if a function for a small task exists or not .. until you do
have the big picture, which, if the number of tiny methods is just high
enough, might never happen.
HalcyonWild said:Alas, How True. I really looked up a thesaurus once.
Jakob Bieling said:Only one question arose in my mind: When having many /many/ tiny
methods, you need the big picture of the project, or else you might end
up writing duplicate tiny functions. Or you keep spending time trying to
find out, if a function for a small task exists or not .. until you do
have the big picture, which, if the number of tiny methods is just high
enough, might never happen.
Chris said:As a side note, if you're really interested in promoting reuse within a
project, you could work in Eclipse, where there are several plugins that
claim to track duplicated code and let you know about it. Google for
"SimScan" and "Duplication Management Framework". I looked at SimScan a
while back, and it was interesting... but I ended up deciding that it
interfered too much with the normal development process if used
regularly... and if not used regularly, it's just a pain.
I was guilty of this sort of behavior when I got my first internship.
People do learn, especially if someone gives them a chance by telling
them how to do better.
Most of my deeper understanding of OO, software engineering, and
coding for maintainability happened after I graduated, not before.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.