Skip to main content
typo
Source Link
Deiwin
  • 497
  • 2
  • 11

No, long methods are not alwayalways bad.

In the book Code Complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long methods are not alway bad.

In the book Code Complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long methods are not always bad.

In the book Code Complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

Altered formatting to show that, for those who don't know, code complete is actually the title of a book.
Source Link
JW01
  • 3.6k
  • 4
  • 24
  • 22

No, long methods are not alway bad.

In code completethe book Code Complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long methods are not alway bad.

In code complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long methods are not alway bad.

In the book Code Complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

Post Made Community Wiki by Aniket Inge

No, long methodmethods are not alway bad.

In code complete, it is measured that long methodmethods are sometimesometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long method is amethods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As commentcomments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checkchecking such metrics on long functionfunctions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long method are not alway bad.

In code complete, it is measured that long method are sometime faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact long method is a easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comment are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not check such metrics on long function, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

No, long methods are not alway bad.

In code complete, it is measured that long methods are sometimes faster and easier to write, and don't lead to maintenance problems.

In fact, what is really important is to stay DRY and respect separation of concerns. Sometime, the computation is just long to write, but really won't cause issue in the future.

However, from my personal experience, most long methods tend to lack separation of concern. In fact, long methods are an easy way to detect that something MAY be wrong in the code, and that special care is required here when doing code review.

EDIT: As comments are made, I add an interesting point to the answer. I would in fact also check complexity metrics for the function (NPATH, cyclomatic complexity or even better CRAP).

In fact, I recommend to not checking such metrics on long functions, but to include alert on them with automated tools (such as checkstyle for java for instance) ON EVERY FUNCTION.

add relevant details from comments.
Source Link
deadalnix
  • 6k
  • 2
  • 32
  • 27
Loading
Source Link
deadalnix
  • 6k
  • 2
  • 32
  • 27
Loading