Long method or long method is a term for a method that has too many lines. In general, methods that have more than ten lines of code indicate the possibility of code that is too long, so it needs further analysis whether it needs to be broken down into several methods. Creating a method is considered more difficult than adding a few lines of code to an existing method. Especially if only a few lines of code are added. But this is the main cause of bloating a method when another line is added later on. Adding comments in a method to clarify the use of variables, logic, or other lines in a method can also be an indication that lines that should be described separately should be declared in a separate method. A good method has a name that describes the usefulness of the method itself, so the use of comments inside the method should be avoided.   Mention some ways that can be done to improve the condition of the method that is too long!

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

Long method or long method is a term for a method that has too many lines. In general, methods that have more than ten lines of code indicate the possibility of code that is too long, so it needs further analysis whether it needs to be broken down into several methods. Creating a method is considered more difficult than adding a few lines of code to an existing method. Especially if only a few lines of code are added. But this is the main cause of bloating a method when another line is added later on.

Adding comments in a method to clarify the use of variables, logic, or other lines in a method can also be an indication that lines that should be described separately should be declared in a separate method. A good method has a name that describes the usefulness of the method itself, so the use of comments inside the method should be avoided.

 

Mention some ways that can be done to improve the condition of the method that is too long!

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Calling
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT