Click here to Skip to main content
15,917,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Max # of variables passed before using struct Pin
Paul M Watt30-Apr-02 5:35
mentorPaul M Watt30-Apr-02 5:35 
GeneralRe: Max # of variables passed before using struct Pin
Paul M Watt30-Apr-02 10:04
mentorPaul M Watt30-Apr-02 10:04 
GeneralRe: Max # of variables passed before using struct Pin
Mike Nordell1-May-02 8:54
Mike Nordell1-May-02 8:54 
GeneralRe: Max # of variables passed before using struct Pin
Tim Smith30-Apr-02 6:01
Tim Smith30-Apr-02 6:01 
GeneralRe: Max # of variables passed before using struct Pin
Codin' Carlos30-Apr-02 9:05
Codin' Carlos30-Apr-02 9:05 
GeneralRe: Max # of variables passed before using struct Pin
Ravi Bhavnani30-Apr-02 9:11
professionalRavi Bhavnani30-Apr-02 9:11 
GeneralRe: Max # of variables passed before using struct Pin
Chris Losinger30-Apr-02 9:30
professionalChris Losinger30-Apr-02 9:30 
GeneralRe: Max # of variables passed before using struct Pin
Philippe Mori30-Apr-02 13:47
Philippe Mori30-Apr-02 13:47 
In fact, for readability a structure will be preferable particulary if there are no hint about what each parameters are:

f(true, false, true, true, true);

Looking at this code it's hard to know what the third parameter means (and it is easy to swap parameters by errors).

As mentionned in another answer, 7 parameters are generally what is considered as a maximum for readability...

Structures or classes also allows to set parameters to default values. If everything is inline and a good compiler is used, the compiler should be able to remove useless initialisation.

Structures or classes (I prefer classes with private members), also allows to easily add a parameter, have default options or compute parameters.

Also if most parameters are optional and different subset are used depending on the context, different constructors can be provided.

Finally as someone else said, if the function is called only from a few places it will be simpler (faster) to pass all those parameters than to define a structure (or a class). But if the code is often used, a better design is in order. The best solution is to make a class with all the data private and inline accessor as this will greatly simplify maintenance if you need additional parameters (or you want to remove obsolete parameters).






Philippe Mori
Generaluser input to var name Pin
jimNLX30-Apr-02 3:51
jimNLX30-Apr-02 3:51 
GeneralRe: user input to var name Pin
Konrad Rotuski30-Apr-02 3:58
Konrad Rotuski30-Apr-02 3:58 
GeneralRe: user input to var name Pin
Ravi Bhavnani30-Apr-02 9:12
professionalRavi Bhavnani30-Apr-02 9:12 
GeneralRe: user input to var name Pin
jimNLX1-May-02 5:48
jimNLX1-May-02 5:48 
GeneralLooking for sample code to put a minimize to tray button in the caption of a window. Pin
Kurt _B30-Apr-02 3:45
Kurt _B30-Apr-02 3:45 
GeneralRe: Looking for sample code to put a minimize to tray button in the caption of a window. Pin
-Dy30-Apr-02 4:53
-Dy30-Apr-02 4:53 
GeneralRe: Looking for sample code to put a minimize to tray button in the caption of a window. Pin
Thomas Freudenberg30-Apr-02 4:56
Thomas Freudenberg30-Apr-02 4:56 
GeneralRe: Looking for sample code to put a minimize to tray button in the caption of a window. Pin
Kurt _B30-Apr-02 5:09
Kurt _B30-Apr-02 5:09 
GeneralShowing MDI Childwnd maximized Pin
Konrad Rotuski30-Apr-02 3:42
Konrad Rotuski30-Apr-02 3:42 
GeneralRe: Showing MDI Childwnd maximized Pin
Mazdak30-Apr-02 3:48
Mazdak30-Apr-02 3:48 
GeneralWhy the drawed rectangle disappeared Pin
chen30-Apr-02 2:48
chen30-Apr-02 2:48 
GeneralRe: Why the drawed rectangle disappeared Pin
Chris Losinger30-Apr-02 6:12
professionalChris Losinger30-Apr-02 6:12 
Generalprofiling with vc++ Pin
Maximilien30-Apr-02 2:35
Maximilien30-Apr-02 2:35 
GeneralRe: profiling with vc++ Pin
Chen Venkataraman30-Apr-02 11:24
Chen Venkataraman30-Apr-02 11:24 
GeneralToolbar positioning problem Pin
Konrad Rotuski30-Apr-02 2:26
Konrad Rotuski30-Apr-02 2:26 
GeneralRe: Toolbar positioning problem Pin
Thomas Ascher30-Apr-02 2:42
Thomas Ascher30-Apr-02 2:42 
GeneralSplit Table during PowerPoint Automation Pin
vmf30-Apr-02 2:07
vmf30-Apr-02 2:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.