Skip to content

Commit e39e5a1

Browse files
author
Joseph Luce
authored
Update good_coding_style_tips.md
1 parent 216f073 commit e39e5a1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: good_coding_style_tips.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ Ideal, we want to write functions that always return something back.
33
It gets confusing when you have a list of functions and there isn't a clear distinction on whether if passing an object into that function modifies your object or not.
44
So that is why its generally a good rule of thumb to instead return an object versus passing an object to modify it.
55

6-
There are some exception during interviews, it tends to deal with recursion. Sometimes there can be a problem where you are storing a temporary result and until some thing like reaching the end of the index, do you save it into the global result.
7-
In this scenario, you will have to pass in a global_result object list for each recursion because you won't know when the save trigger occurs.
6+
There are some exception during interviews, it tends to deal with recursion.
7+
Sometimes there can be a problem where you are storing a temporary result and until reaching a base case like the end of a list, do you save your temporary result into the final result.
8+
In this scenario, you will have to pass in a mutable for each recursion because you won't know when the save trigger occurs.
89

9-
However, outside of recursion, I would recommend to always return an object over passing in an object and modifying it.
10+
However, outside of recursion, I would recommend to always return an object instead of passing in an object and modifying it.
11+
There are some times exceptions to this depending on the question.
1012

1113
# SOLID Principles
1214
### Single Responsiblity Principle

0 commit comments

Comments
 (0)