Thread: Reasons for keeping functions small

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    54

    Reasons for keeping functions small

    Does the amount of work performed to place a function on the stack change significantly as the size of the function increases? I'm interested in reasons other than appearance and organization, more related to efficiency, that make writing smaller functions a good idea.

    Example: A function containing 400 lines of code, 350 of which are contained within conditional statements. Those 350 can obviously be broken down into smaller functions, and would make an improvement, since the work inside one conditional, in this example, is independent of the work inside the others. The only extra overhead would be calling the function within the conditional. How much of a performance gain is there in putting each conditional statement's code in separate functions, if any.
    Last edited by maththeorylvr; 03-25-2006 at 09:46 PM. Reason: none

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to split long programe in small files
    By umeshjaviya in forum C Programming
    Replies: 11
    Last Post: 04-15-2008, 02:45 AM
  2. Attaching functions to a class/struct
    By VirtualAce in forum Tech Board
    Replies: 2
    Last Post: 08-04-2003, 10:56 AM
  3. DLL class member functions
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2003, 06:59 AM
  4. Borland, libraries, and template member functions
    By roktsyntst in forum C++ Programming
    Replies: 0
    Last Post: 06-01-2003, 09:52 PM
  5. Expression Manipulator v0.2 (bug fixes, functions)
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-26-2003, 04:52 PM