YoVDO

When to Refactor Your Code into Generators and How

Offered By: PyCon US via YouTube

Tags

PyCon US Courses Fibonacci Sequence Courses

Course Description

Overview

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore techniques for refactoring code into generators in this 27-minute PyCon US talk by Jan-Hein Bührman. Learn how to identify common loop patterns and transform them into more maintainable and Pythonic code using generator functions. Discover how to combine custom generators with standard library tools and third-party packages to create efficient code pipelines. Follow along with a practical example using the Fibonacci sequence to understand the before-and-after effects of generator-based refactoring. Gain insights into recognizing opportunities for this refactoring pattern and improving code maintainability. Access accompanying slides for visual reference and additional details on the concepts presented.

Syllabus

Intro
GOALS
TOPICS
VARIATIONS ON FIBONACCI NUMBER SELECTIONS
FIBONACCI NUMBER (DEFINITION)
FIBS LESS THAN N (PYTHON)
SMALLEST FIB GREATER/EQUALN(PYTHON)
THE PATTERN
TIME TO START REFACTORING YOUR CODE
CODE REFACTORING
EXTRACTING COMMON PARTS NOT DOABLE!
EXPERIMENT: COMBINE THE FIRST TWO FUNCTIONS
REFACTORING THE RIGHT WAY: SINGLE RESPONSIBILITY
CONTEXT SWITCH: GENERATOR FUNCTIONS
THE FIBONACCI NUMBER GENERATOR
EXAMPLE USAGE OF THE FIBONACCI GENERATOR
THE SMALLEST FIB GREATER/EQUAL N (PYTHON, REFACTORED)
RECAP


Taught by

PyCon US

Related Courses

Intro to Python for Brand New Programmers
PyCon US via YouTube
Comprehending Comprehensions
PyCon US via YouTube
Data Analysis with SQLite and Python
PyCon US via YouTube
Build a Production Ready GraphQL API Using Python
PyCon US via YouTube
Web Development With A Python-backed Frontend - Featuring HTMX and Tailwind
PyCon US via YouTube