jsapers/SoftwareDesign — pull request #2 by abekim (2014-02-27 06:11:04+00:00)
Title: Graded Homework 4

**Grade 4.5/5**

Well done, Josh! I have a few comments about the homework (and Python in general).
- I'm personally not convinced that a global variable should ever be used. It breaks the handling of different responsibilities among different layers of your code, and it doesn't make sense to use it. The way you used it, it would have made a ton more sense if you added `current_depth` as a third parameter to your `build_random_function`:

```
def build_random_function(min_depth, max_depth, current_depth):
if current_depth < max_depth:
current_depth += 1
...
if s == "prod":
return [s,build_random_function(min_depth, max_depth, current_depth),build_random_function(min_depth, max_depth, current_depth)]
...
...
```

This is also a concept known as "tail-end recursion". Feel free to read up on it :-)

- Try to always use a main script or a function for anything and everything. My advice is to make the last section of your code a function `generate_random_image` and run it from a `__main__` script.

Other than that, I'm very impressed by your code. Good work, Josh!

Once you've read the comments (both on the PR and under files changed), make a comment to the pull request or send me/Diana an email, letting us know that you've checked them out. Afterwards, close the PR (and optionally delete the graded branch)

#### REMEMBER NOT TO MERGE THESE PRs!