|
-
August 29th, 2011, 10:10 AM
#1
What's your preference on writing functions: ByRef manipulation or returning values?
Hi guys,
I was wondering about this and thought I'd ask this here.
Personally I find that code readability is really important, if not the most important part of software development.
So given the following examples, which one do you think is more readable?
Code:
// example 1 (return result)
public function doSomething1(String someString):String{
/* some manipulation on someString */
return someString;
}
public function doSomething2(String someString):String{
/* some manipulation on someString */
return someString;
}
//example 2 (ByRef)
public function doEverything(String someString1, String someString2):void{
someString1 = doSomething1(someString1);
someString2 = doSomething2(someString2);
}
Which function would you call if you needed to apply the actions doSomething1 and doSomething2 to strings? Does it make sense to group the actions into a wrapper which manipulates the strings accordingly? Is there a magic number at which you would start wrapping your functions?
Does the Single-Responsability-Pattern still apply assuming that the actions doSomething1 and doSomething2 are strongly related?
Discuss 
Laurent
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|