Large C++ function

N

nilavya

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.
 
A

Alf P. Steinbach

* 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.
 
Y

yuvalif

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.
 
N

nilavya

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.
 
Y

yuvalif

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.
 
N

nilavya

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.
 
C

Csaba

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!).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top