Large C++ function

Discussion in 'C++' started by nilavya, Dec 6, 2005.

  1. nilavya

    nilavya Guest

    Hi,

    I have an application for GUI.
    I have got too many functions for display and one main and really huge
    function for maintaining the state of the GUI. Now I dont know about
    how the size of the function will affect the execution. The function
    incorporates a nested switch case logic i.e. based on one state and the
    event from GUI, I display accordingly on the gUI. can anyone help me to
    know if a C++ function of around 3000Lines really affects the
    execution.

    Thanks,
    With Regards,
    Bhagat Nirav K.
     
    nilavya, Dec 6, 2005
    #1
    1. Advertisements

  2. * nilavya:
    > can anyone help me to
    > know if a C++ function of around 3000Lines really affects the
    > execution.


    The size of a function does not affect the program's execution, but it
    does mean the code is unmaintenable.

    Split it up.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Dec 6, 2005
    #2
    1. Advertisements

  3. nilavya

    Guest

    I don't think the size of a function has any performance implications,
    however, it has huge (literally...) maintenance implications, and even
    worst, it makes your function untestable.
    In other words, the probability of creating bugs while modifying the
    function is high, and the probability of discovering them is low.
    I suggest you take a look in the "State Machine" DP (GOF book, or any
    other), its one of the more usefull ones.

    Yuval.
     
    , Dec 6, 2005
    #3
  4. nilavya

    nilavya Guest

    wrote:
    > I don't think the size of a function has any performance implications,
    > however, it has huge (literally...) maintenance implications, and even
    > worst, it makes your function untestable.
    > In other words, the probability of creating bugs while modifying the
    > function is high, and the probability of discovering them is low.
    > I suggest you take a look in the "State Machine" DP (GOF book, or any
    > other), its one of the more usefull ones.
    >
    > Yuval.



    HI,

    thanks for the reply.
    Can you tell me where can i find "State machine" DP ?? is it an e-book
    or some other link. ?

    Thanks,
    With Regards,
    Bhagat Nirav K.
     
    nilavya, Dec 6, 2005
    #4
  5. nilavya

    Guest

    State Machine is a Design Pattern (DP). I don't know of any online DP
    book, but the most classic one is: "Design Patterns: Elements of
    Reusable Object-Oriented Software/Erich Gamma" written by four people,
    hence, called GOF (Gang Of Four).

    Yuval.
     
    , Dec 6, 2005
    #5
  6. nilavya

    nilavya Guest

    Okey...

    Got it and I have got that Book.
    I thought about that ..but then...
    Anyways..
    Thanks for pointing out..

    With Regards,
    Bhagat Nirav K.
     
    nilavya, Dec 6, 2005
    #6
  7. nilavya

    Csaba Guest

    "nilavya" <> wrote in news:1133856483.673056.293090
    @z14g2000cwz.googlegroups.com:

    > Hi,
    >
    > I have an application for GUI.
    > I have got too many functions for display and one main and really huge
    > function for maintaining the state of the GUI. Now I dont know about
    > how the size of the function will affect the execution. The function
    > incorporates a nested switch case logic i.e. based on one state and the
    > event from GUI, I display accordingly on the gUI. can anyone help me to
    > know if a C++ function of around 3000Lines really affects the
    > execution.
    >


    It may not affect execution, but it sure affects maintainability (and not
    in a positve way, I can assure you!).


    --
    Life is complex, with real and imaginary parts.
     
    Csaba, Dec 13, 2005
    #7
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Vanns
    Replies:
    7
    Views:
    7,605
    Evan Carew
    Jan 21, 2004
  2. komal
    Replies:
    6
    Views:
    1,679
    msalters
    Jan 25, 2005
  3. Replies:
    2
    Views:
    1,116
    Bengt Richter
    Aug 1, 2005
  4. Giannis Papadopoulos

    Function pointer to void function and int function

    Giannis Papadopoulos, Sep 5, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,489
    Barry Schwarz
    Sep 5, 2005
  5. weafon
    Replies:
    1
    Views:
    509
    Diez B. Roggisch
    Jul 14, 2009
  6. Alf P. Steinbach
    Replies:
    10
    Views:
    3,912
    Alf P. Steinbach
    Jul 27, 2011
  7. Ketchup
    Replies:
    1
    Views:
    417
    Jan Tielens
    May 25, 2004
  8. Replies:
    5
    Views:
    1,610
    Xho Jingleheimerschmidt
    Apr 2, 2009
Loading...