Click here to Skip to main content
15,915,164 members
Home / Discussions / C#
   

C#

 
AnswerRe: AppDomain + Reflection Pin
S. Senthil Kumar11-Mar-07 14:11
S. Senthil Kumar11-Mar-07 14:11 
QuestionDataGridView IDENTITY column binding problem Pin
Deian11-Mar-07 9:13
Deian11-Mar-07 9:13 
AnswerRe: DataGridView IDENTITY column binding problem Pin
Deian11-Mar-07 11:31
Deian11-Mar-07 11:31 
Questionsimple 2d graphics with c# Pin
liquidfluid11-Mar-07 8:35
liquidfluid11-Mar-07 8:35 
AnswerRe: simple 2d graphics with c# Pin
Ed.Poore11-Mar-07 8:50
Ed.Poore11-Mar-07 8:50 
Questionmarshaling of the const char * Pin
MinaFawzi11-Mar-07 6:21
MinaFawzi11-Mar-07 6:21 
AnswerRe: marshaling of the const char * Pin
Ed.Poore11-Mar-07 7:52
Ed.Poore11-Mar-07 7:52 
QuestionPassing member variables as private method arguments? Pin
David Veeneman11-Mar-07 5:38
David Veeneman11-Mar-07 5:38 
Should a member variable be passed to a private method in the same class as a method argument, or should the method simply call the member variable?

For years, I have passed member variables to private methods in the same class as method arguments. For example, if Public method Foo() calls private method Bar(), and if Bar() uses member variable m_MyVariable, I declare the private method with the signature:

private void Bar(SomeType myVariable)<br />
{<br />
     ...<br />
}


Foo() calls Bar() as:

this.Bar(m_MyVariable);

In other words, even though Bar() could call m_MyVariable directly, I don't do it. Instead, I create a local variable within Bar() to hold the value.

I've done this to keep my private methods as self-contained as possible, and to make it obvious from the method signature just what the method needs in order to do its job. Arguably, this approach makes it easier to follow the flow of control within the program.

But now I'm not so sure it's such a good idea. I often end up with long method signatures with a half-dozen or more arguments, and I find that I'm passing the same member variables (typically helper objects) to every private method in a class.

So, what do you think? Am I better off passing member variables to private methods as arguments, or should I simply let the methods call member variables directly? Thanks for your input.

David Veeneman
Foresight Systems

David Veeneman
www.veeneman.com

AnswerRe: Passing member variables as private method arguments? Pin
S. Senthil Kumar11-Mar-07 5:55
S. Senthil Kumar11-Mar-07 5:55 
GeneralRe: Passing member variables as private method arguments? Pin
David Veeneman11-Mar-07 7:32
David Veeneman11-Mar-07 7:32 
AnswerRe: Passing member variables as private method arguments? Pin
Christian Graus11-Mar-07 4:55
protectorChristian Graus11-Mar-07 4:55 
AnswerRe: Passing member variables as private method arguments? Pin
Leslie Sanford11-Mar-07 16:52
Leslie Sanford11-Mar-07 16:52 
GeneralRe: Passing member variables as private method arguments? Pin
David Veeneman11-Mar-07 7:36
David Veeneman11-Mar-07 7:36 
GeneralRe: Passing member variables as private method arguments? Pin
David Veeneman12-Mar-07 4:14
David Veeneman12-Mar-07 4:14 
QuestionGenerate Panel Pin
shamsteady11-Mar-07 5:35
shamsteady11-Mar-07 5:35 
AnswerRe: Generate Panel Pin
Dave Kreskowiak11-Mar-07 6:48
mveDave Kreskowiak11-Mar-07 6:48 
QuestionAutomatically paste into active window from my code Pin
Cedric_NewUser11-Mar-07 5:19
Cedric_NewUser11-Mar-07 5:19 
QuestionHow to create a control panel for my DVD Playback Windows Application Pin
Khoramdin11-Mar-07 4:04
Khoramdin11-Mar-07 4:04 
AnswerRe: How to create a control panel for my DVD Playback Windows Application Pin
Christian Graus11-Mar-07 4:51
protectorChristian Graus11-Mar-07 4:51 
GeneralRe: How to create a control panel for my DVD Playback Windows Application Pin
Khoramdin11-Mar-07 6:16
Khoramdin11-Mar-07 6:16 
QuestionData Adaptor parameter in Sub Pin
moali7211-Mar-07 0:36
moali7211-Mar-07 0:36 
GeneralALREADY POSTED Pin
CPallini11-Mar-07 0:55
mveCPallini11-Mar-07 0:55 
QuestionAdd panel Pin
shamsteady10-Mar-07 23:21
shamsteady10-Mar-07 23:21 
AnswerRe: Add panel Pin
Dawid Mazuruk10-Mar-07 23:27
Dawid Mazuruk10-Mar-07 23:27 
GeneralRe: Add panel Pin
shamsteady10-Mar-07 23:32
shamsteady10-Mar-07 23:32 

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.