Tagged Questions
7
votes
6answers
1k views
Prefer class members or passing arguments between internal methods?
Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...
4
votes
2answers
390 views
Should I expose a “computed” value as a property or a method?
I have a C# class that represents a content type in a web content management system.
We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
1
vote
1answer
88 views
When should I pass value as class variable and when as a method argument?
Is there a general rule of thumb, when we should pass a value as as class variable and when as a method argument? Or is it just a choice of the developer?
For example -- are there any reasons, why ...
4
votes
6answers
312 views
Fields vs method arguments [closed]
I just started writing some new class and it occurred to me that I was adding a lot of method arguments that are not strictly needed. This is following a habit to avoid having state in classes that is ...
5
votes
4answers
546 views
Method flags as arguments or as member variables?
I think the title "Method flags as arguments or as member variables?" may be suboptimal, but as I'm missing any better terminology atm., here goes:
I'm currently trying to get my head around the ...
10
votes
2answers
702 views
Design: Object method vs separate class's method which takes Object as parameter?
For example, is it better to do:
Pdf pdf = new Pdf();
pdf.Print();
or:
Pdf pdf = new Pdf();
PdfPrinter printer = new PdfPrinter();
printer.Print(pdf);
Another example:
Country m = new ...