Skip to content

Instantly share code, notes, and snippets.

View jbrucker's full-sized avatar

James Brucker jbrucker

  • Kasetsart University
  • Honolulu, Hawaii
View GitHub Profile

Problem 1. Extract Method or Property to eliminate duplicate code

class Student:
    def credits(self):
        return sum(c.credits for c in self.courses)

and use it in two places:

    def add_course(self, course_id):
@jbrucker
jbrucker / README.md
Last active October 24, 2023 03:01
Example MovieCatalog code to refactor

Before and After Refactoring of MovieCatalog

  1. blah blah
  2. blah blah
@jbrucker
jbrucker / gist:8a650cbf643231a3478100bbab7edcf9
Created November 3, 2022 14:31
Bash script to configure a typical student KU Polls project
# Source (don't execute) this script in bash
# to configure a ku-polls application.
# name of your python and pip commands
PYTHON=python
PIP=pip
# preferred editor to edit .env file
EDIT=edit
# where to create the virtual environment
ENVDIR="env"