I often found myself when writing a new class that inside a class I pass a parameter inside of many private methods. On the other side I also create sometime private members and just use them in one method.
So my question is "After which rules do you create a private member and when you don't and pass the variable from private method to private method"?
Can you give me some simple tips or hints, so that the design will get better?
If a parameter is part of the 'state' of the class, then use a private member. If on the other hand the parameter is just a temporary object, just pass it as a parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With