Hi all,
When implementing a class, is it better practice to return a value for methods (interrogative) or to simply manipulate class attributes directly within the method (imperative).
For example, I have a class which builds a string to be output to a CSV file. I might do it this way:
String output = ""
String records[] = //list of record strings
void extract()
extractHeader()
extractRecords()
void extractHeader()
output += "FirstName,LastName,PhoneNumber"
void extractRecords()
For Each record In Records
output += records.toString()
Or, I might do it this way:
void extract()
output += extractHeader()
output += extractRecords()
string extractHeader()
// return header string
string extractRecords()
// return records as string
Is it simply a matter of personal preference, or is there a generally accepted best practice guideline?
Cheers,
Andrew