This Gist was automatically created by Carbide, a free online programming environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use test-driven development to write a method that: | |
# * Takes an array of numbers. | |
# * Returns the sum of the numbers in the array. | |
# * e.g. | |
# * Input: [1, 2, 3, 4, 5] | |
# * Return: 15 | |
# * Make sure to create a separate project directory for your code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use test-driven development to write a method that: | |
# * Takes an array of numbers. | |
# * Returns an array of the same numbers, except each number has had 1 added to it. | |
# * e.g. | |
# * Input: [1, 2, 3, 4, 5] | |
# * Return: [2, 3, 4, 5, 6] | |
# * Make sure to create a separate project directory for your code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OVERVIEW OF THE WEEK | |
- Encapsulating Single Responsibilities (rather than just common behaviour) into classes | |
- makes code easy to reuse | |
- makes code easy to change | |
- makes code easy to understand | |
- Refactoring code for SRP | |
- Adopt this code writing process |
-
Map the student's request for help to one of the underlying problems listed below.
-
Apply one of the suggested solutions.
-
Ask the student for feedback on your help.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to_dos = {"Haircut": False} | |
def print_to_dos(to_dos): | |
for to_do in to_dos: | |
if to_dos[to_do] == False: | |
print("- %s" % to_do) | |
else: | |
print("x %s" % to_do) | |
def new_to_do(to_dos): | |
to_do = raw_input("What else do you need to do? ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . | |
"http://marmalade-repo.org/packages/")) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(package-initialize) | |
;; load paths | |
(add-to-list 'load-path "~/.emacs.d/src/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to_dos = ["Haircut"] | |
def print_to_dos(to_dos): | |
for to_do in to_dos: | |
print("- %s" % to_do) | |
def new_to_do(to_dos): | |
to_do = raw_input("What else do you need to do? ") | |
to_dos.append(to_do) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bands = [{'name': 'sunset rubdown', 'country': 'UK', 'active': False}, | |
{'name': 'women', 'country': 'Germany', 'active': False}, | |
{'name': 'a silver mt. zion', 'country': 'Spain', 'active': True}] | |
def assoc(_d, key, value): | |
from copy import deepcopy | |
d = deepcopy(_d) | |
d[key] = value | |
return d | |
NewerOlder