📔
intro-to-python
  • An Introduction to Programming in Python (for Business Students)
  • exercises
    • Data Flow Diagramming Exercise
    • Developer Collaboration Exercise
    • README
    • "Web App" Exercise
      • checkpoints
        • Checkpoint 5: Bootstrap Layout
        • Checkpoint 4: Submitting Data from Web Forms
        • Checkpoint 3: Rendering HTML Pages
        • Checkpoint 1: Routing
        • Checkpoint 2: Modular Organization
      • "Web App" Exercise - Further Exploration
    • hello-world
      • "Hello World (Local)" Exercise
      • "Hello World (Local w/ Version Control)" Exercise
      • "Hello World (Colab)" Exercise
    • "Interface Capabilities" Exercise
    • "Continuous Integration 1, 2, 3" Exercise
    • "Web Service" Exercise
      • "Web Service" Exercise - Further Exploration
    • "Testing 1, 2, 3" Exercise
    • "Command-line Computing" Exercise
      • "Command-line Computing" Exercise
      • Professor Rossetti's Mac Terminal Configuration
      • Command-line Computing Exercise
    • "Codebase Cleanup" Assignment
    • "List Comprehensions" Exercise
    • "Groceries" Exercise
      • Python Datatypes (a.k.a. "Groceries") Exercise
      • Python Datatypes (a.k.a. "Groceries") Exercise
    • "Rock, Paper, Scissors" Exercise
      • "Rock, Paper, Scissors" Exercise
    • README
    • "Monthly Sales Predictions" Exercise
    • Setting up your Local Development Environment
    • "Chart Gallery" Exercise
    • "Run the App" Exercise
    • "Web Requests" Exercise
    • "API Client" Exercise
    • "Custom Functions" Exercise
    • Process Diagramming Exercise
  • notes
    • python
      • packages
        • The bigquery Package
        • The PySimpleGUI Package
        • The dotenv Package
        • The matplotlib Package
        • The requests Package
        • The altair Package
        • The gspread Package
        • The PyMySQL Package
        • The psycopg2 Package
        • The selenium Package
        • The seaborn Package
        • The pytest Package
        • The SpeechRecognition Package
        • The flask Package
        • The pandas Package
        • The spotipy Package
        • The pipenv Package
        • The nltk Package
        • The sqlalchemy Package
        • The pymongo Package
        • The plotly Package
        • The BeautifulSoup Package
        • The sendgrid Package
        • The fpdf Package
        • The autopep8 Package
        • The tweepy Package
        • The twilio Package
        • The tkinter Package
      • Python Datatypes Overview
        • Numbers
        • Classes
        • Dates and Times
        • Strings
        • None
        • Dictionaries
        • Booleans
        • Lists
        • Class Inheritance
      • Control Flow
      • Python Modules
        • The webbrowser Module
        • The time Module
        • The csv Module
        • The sqlite3 Module
        • The itertools Module
        • The json Module
        • The math Module
        • The os Module
        • The statistics Module
        • The random Module
        • The pprint Module
        • The datetime Module
        • The collections Module
      • Printing and Logging
      • Comments
      • Syntax and Style
      • Functions
      • Variables
      • Errors
      • Docstrings
      • File Management
      • User Inputs
      • Debugging
    • clis
      • The git Utility
      • Heroku, and the heroku Utility
      • Anaconda
      • The chromedriver Utility
      • The brew Utility (Mac OS)
      • The pdftotext Utility
      • The python Utility
      • The pip Utility
    • Software
      • Software Licensing
      • Software Documentation
      • Software Ethics
      • Software Testing Overview
      • Application Programming Interfaces (APIs)
      • Software Version Control
      • Software Refactoring Overview
    • devtools
      • The VS Code Text Editor
      • Code Climate
      • Travis CI
      • GitHub Desktop Software
      • Git Bash
      • Google Colab
    • Information Systems
      • Computer Networks
      • Processes
      • Datastores
      • Information Security and Privacy
      • People
    • Technology Project Management
      • Project Management Tools and Techniques
      • The Systems Development Lifecycle (SDLC)
    • hardware
      • Servers
    • Environment Variables
  • projects
    • "Executive Dashboard" Project
      • testing
      • "Exec Dash" Further Exploration Challenges
    • The Self-Directed (a.k.a "Freestyle") Project
      • "Freestyle" Project - Demonstration
      • "Freestyle" Project - Implementation (TECH 2335 Version)
      • "Freestyle" Project - Implementation
      • "Freestyle" Project Proposal
      • plan
    • "Robo Advisor" Project
      • Robo Advisor Project - Automated Testing Challenges
      • "Robo Advisor" Further Exploration Challenges
    • "Shopping Cart" Project
      • "Shopping Cart" Project - Automated Testing Challenges
      • "Shopping Cart" Further Exploration Challenges
      • "Shopping Cart" Project Checkpoints
  • License
  • Exam Prep
  • units
    • Unit 4B: User Interfaces and Experiences (Bonus Material)
    • Unit 5b: Databases and Datastores
    • Module 1 Review
    • Unit 7b: Processing Data from the Internet (Bonus Material)
    • Unit 9: Software Products and Services
    • Unit 8: Software Maintenance and Quality Control
    • Unit 7: Processing Data from the Internet
    • Unit 6: Data Visualization
    • Unit 5: Processing CSV Data
    • Unit 4: User Interfaces and Experiences
    • Unit 3: Python Datatypes
    • Unit 12: Project Presentations
    • Unit 2: Python Language Overview
    • Unit 11: Project Implementation Sprint
    • Unit 1: The Python Development Environment
    • Unit 10: Software Planning, Analysis, and Design
    • Unit 0: Onboarding
    • Unit 5B: Advanced Data Analytics
  • Contributor's Guide
Powered by GitBook
On this page
  • Learning Objectives
  • Instructions
  • Instructions
  • Game Improvements
  • Shopping Improvements
  • Robo Improvements (Further Exploration)
  • Evaluation

Was this helpful?

  1. exercises

"Codebase Cleanup" Assignment

PreviousCommand-line Computing ExerciseNext"List Comprehensions" Exercise

Last updated 4 years ago

Was this helpful?

Learning Objectives

  • Develop new features in a controlled manner, by adopting Git branch operations and a Pull Request workflow.

  • Practice collaborating with other developers and conducting Peer Reviews.

  • Simplify an existing codebase to decrease future maintenance costs, and reduce errors.

  • Write and execute automated tests to verify code is functioning as expected.

  • Incorporate automated checks (like running tests on a Continuous Integration server), to determine whether code updates are ready to be merged / adopted.

Instructions

The contains some abbreviated example code related to some projects we have worked on. But there are few opportunities for us to improve the quality of this code.

First, fork the repo under your own control. Then integrate your forked repo with the platform, and the platform.

Use a Pull Request workflow to complete each of the challenges below. Optionally invite a friend to collaborate on your repo, and perform a code review on at least one of your Pull Requests.

NOTE: for Pull Requests, create them against your fork ("origin" repo), NOT the professor's "upstream" repo.

Instructions

For Basic Requirements, do the "Game" and "Shopping" challenges. For further exploration, also do the "Robo" challenges.

Game Improvements

User Feedback: "Sometimes it gets the winner wrong!"

Developer Maintenance Steps:

  1. Refactor duplicate code related to the valid options ("rock", "paper", and "scissors").

  2. Notice Code Climate says the existing winner determination logic is "complex". Refactor the complex logic to use less computational steps and also make it easier to read. Also notice the existing logic produces some inaccurate outcomes, and update the logic to produce accurate outcomes.

  3. Test that the winner determination logic produces accurate outcomes. Move the logic into a stand-alone function called determine_winner() that can be invoked and tested in isolation, separate from any user inputs.

Shopping Improvements

User Feedback: "The receipt file has the wrong total amount due!"

Developer Maintenance Steps:

  1. Refactor duplicate code related to the price-formatting logic. Notice and fix any discrepancies in this logic.

  2. Refactor duplicate code related to the receipt contents. Ensure the printed receipt has the same contents as the receipt file.

  3. Test the program's price-formatting logic produces desired results. Move the logic into a stand-alone function called format_usd() that can be invoked and tested in isolation, separate from any user inputs.

  4. Test the program's ability to lookup matching products. Move the product lookup logic into a stand-alone function called find_product() that can be invoked and tested in isolation, separate from any user inputs. Use the mock products CSV file data to perform this test.

Robo Improvements (Further Exploration)

User Feedback: "The chart shows prices in reverse!"

Developer Maintenance Steps:

  1. Test the program's ability to request data for a given stock symbol, and that the resulting response data is structured in the expected format. HINT: since the response data will be dynamic, we can focus on some consistent parts of the response data, like ensuring certain keys like "Meta Data" and "Time Series (Daily)" exist, and checking the symbol we requested is contained in the "Meta Data".

  2. Test the program's ability to convert the response data into a more usable format (for example a list of dictionaries or Pandas DataFrame). Use one or more valid mock responses to perform this test, without making any network requests.

  3. Test the program's chart displays prices in the proper order. HINT: we can just do a test about some aspects of the DataFrame that gets charted.

  4. Ensure any tests that make web requests are skipped from being run on the CI server.

  5. Refactor the format_usd() function from the shopping script, moving it into the init file or a separate "app/number_decorators.py" module, and importing it into both the shopping and robo scripts from there.

FYI: our goal is to minimize the number of web requests that need to be made when testing. We can use mock data and/or pytest fixtures for this.

Evaluation

When you submit this project, you'll submit links to your repository on GitHub, Code Climate, and Travis CI. And evaluators will look at all these services when grading your project.

The project will be evaluated according to the instructions above, as summarized in the table below:

Category

Description

Weight

Pull Request Workflow

At least one or two Pull Requests used during development.

20%

Simplification

Code is reasonably well organized and simplified.

20%

Documentation

At least a few functions are documented via "docstring" comments, as appropriate.

20%

Automated Testing

Tests directly invoke functions from the source code to verify the program behaves as expected.

25%

Continuous Integration

Tests have been run and passed on a CI server at least once, ideally as part of the Pull Request workflow.

7.5%

Code Quality

The Code Climate service has been integrated into the Pull Request workflow to provide automated code quality checks.

7.5%

Peer Reviews

A peer has provided an unofficial comment or official review as part of the Pull Request workflow

0% (OPTIONAL)

NOTE: for this project, evaluators will be reading your code and inspecting your repo across the various platforms (Github, Code Climate Travis CI), but not necessarily running or testing your application code directly.

Codebase Cleanup Repo
Code Climate
Travis CI