Results 1 to 2 of 2
  1. #1
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Blog Entries
    Rep Power

    Default Question to experienced users on methods. How many lines should a method be ?


    A fine method consists between # to # number of lines..

    I know, it depends on the application and everything else just like there are cars that have engines that are only 60 horsepower and some cars are like 1000... But I am asking for something general.

    Like to some Alien you would say, a novel is usually somewhere from 400 pages to 600. That does not mean there are no novels with 100 pages or 1000 pages.

    I am asking this because I feel like I am putting so much in one method.

    Thank you..

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Question to experienced users on methods. How many lines should a method be ?

    My rule of thumb is: a method should do just do one thing and what a method does should be described in one (not too long) sentence. This sort of implies that the sentence doesn't contain 'and's. It also limits the size (number of non-empty) lines of a method.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 8
    Last Post: 01-21-2012, 01:14 AM
  2. Replies: 3
    Last Post: 10-25-2011, 06:29 PM
  3. Question about some lines of code arrays
    By silverglade in forum New To Java
    Replies: 9
    Last Post: 06-09-2011, 04:59 AM
  4. Question concerning methods
    By jim01 in forum New To Java
    Replies: 6
    Last Post: 05-18-2011, 02:46 PM
  5. 2 methods with same name Question
    By dienesh77 in forum New To Java
    Replies: 4
    Last Post: 03-22-2011, 01:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts