OO Design, pass parameters between private methods or access member variable? : <p>Say I have the following class:</p>

<pre><code>class MyClass
{
    private int memberVar;

    public MyClass(int passedInVar)
    {
        memberVar = passedInVar;       
    }
}
</code></pre>

<p>In the constructor you pass in an int and assign it to a private member variable.</p>

<p>My question is, is it better to pass that int variable around between private methods of the class, or to not pass the int variable as a parameter and instead have each private method directly access the private membervar?</p>

<p>i.e. Is this (Example A):</p>

<pre><code>class MyClass
{
    private int memberVar;

    public MyClass(int passedInVar)
    {
        memberVar = passedInVar;       
    }

    public MyPublicMethod()
    {
        MyPrivateMethod(memberVar);
    }

    public MyPrivateMethod(int variable)
    {
        // Do something with passed in variable...
    }
}
</code></pre>

<p>better than this (Example B):</p>

<pre><code>class MyClass
{
    private int memberVar;

    public MyClass(int passedInVar)
    {
        memberVar = passedInVar;       
    }

    public MyPublicMethod()
    {
        MyPrivateMethod();
    }

    public MyPrivateMethod()
    {
        // Do something with memberVar...
    }
}
</code></pre>

<p>The reason I ask is that I find myself switching between the two styles.</p>

<p>I find that example the style of example A shows more intent for the code. You can see what is being passed between private methods so it's more obvious what is being affected by that method.</p>

<p>Whereas Example B is cleaner because the memberVar isn't being passed between private methods. However the code feels more "side-effecty" because it's not always obvious which private member variables the method is acting on.</p>

<p>I'd appreciate your opinions on which approach you consider best.</p>
