Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:18:08+00:00 2026-06-07T05:18:08+00:00

As far as I’ve learnt already, a method containing a long sequence of operations

  • 0

As far as I’ve learnt already, a method containing a long sequence of operations is considered a bad thing and needs to be redesigned. More than that, I heard an opinion that the method should not be bigger than the screen (i.e. all method code should be visible in IDE screen at once, without need of scrolling).

Are there any general rules about this? For example, “if method is more than 15 lines long, it should be refactored”? And if so, how do you refactor it? Just use the extract method way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:18:09+00:00Added an answer on June 7, 2026 at 5:18 am

    It depends on who you ask. Robert Martin will tell you that there are two rules:

    1. A method should be small.
    2. A method should be smaller than that.

    Don’t think of it in terms of line count. Line count is an arbitrary and unimportant metric. Think of it in terms of what the method logically does. The best rule would be:

    • A method should do one thing.

    Or, to put it a better way:

    • A method should have only one reason to change.

    (Still channeling Uncle Bob here, I’ve been hitting the Clean Code pretty hard lately.)

    Combine this with other logical rules, such as:

    • A method should have only one level of abstraction.
    • A method should follow the Law Of Demeter.

    And, in general, you end up with very small methods. There are exceptions to that, however. In many cases the “one thing” is expressed in one line of code, maybe two or three. But it’s simple and expressive code and it’s clear what that “one thing” is. (And the name of the method should, of course, clearly reflect that one thing.)

    Sometimes, however, “one thing” is a longer sequence of steps. Perhaps you have a method encapsulating a single atomic process in your domain, but that process happens to be composed of a dozen or more steps. Each step would be its own “one thing” and it will probably internally have other “one things” in other methods and so on.

    Each individual method does “one thing.” But the higher-level encapsulating methods which aggregate the smaller steps into larger atomic processes get a little longer because their “one thing” is made up of many smaller “one things.” It’s rare, but it happens. And the usual result when it happens is one method which is nothing more than a sequence of method calls. (This isn’t to say that this is an excuse for long methods. Carefully examine the logic of the code to determine if re-factoring the larger methods actually would make sense.)

    This larger encapsulating method is often a result of applying the Transaction Script Pattern to business logic. There’s a single step, responding to a single request, which consists of a multi-step process within the business logic.

    Methods should be small. They should be even smaller than that. If they’re not, examine them closely to determine why. If there’s more than one level of indentation, that’s usually a sign that it should be re-factored. If there are multiple checks and balances from the inputs, it probably could use some re-factoring. If the method is doing more than one thing or has more than one reason to change, it should definitely be re-factored.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know, C2DM is per app per device thing..but my question
As far as I can understand, the linq method FirstOrDefault() returns null if a
Far as best practices are concerned, which is better: public void SomeMethod(string str) {
as far as I know both 2012-07-04T17:30:52+00:00 and 2012-07-04T17:30:52Z are dates in iso8601 format
As far as i remember while installing ubuntu,the installer didn't ask me for the
So far I've been setting up redirects for single pages on my ASP.NET site
So far I have only been updated a view from within its controller. I
As far as I can see this is not the case, however, I thought
So far I know that FileSystemWatcher can look into a folder and if any
As far as my understanding after reading and researching, the purpose of using salt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.