Python Refactoring: From Functions to Classes for Efficient Coding

preview_player
Показать описание
---

Welcome back to another Pybites refactoring video!

In today's video, we show you how to transform a set of functions into a class. This example will demonstrate when and how to use classes effectively.

We'll explore how a class maintains state, encapsulates data + behavior, reduces code repetition and can even improve the performance of your code.

By the end of this video, you'll have a clear understanding of refactoring techniques that can make your Python code cleaner and more maintainable.

Chapters:
00:00 Intro
00:23 Functions with repetition and using global scope
01:21 Writing a class and distinguishing config and user data
02:15 Make the functions methods
02:43 Using the instance variables in the methods
05:02 Fix the method calls
05:31 Making an instance to test this + IDE autocomplete
06:30 Calling the methods
07:01 Removing the setup repetition = less code + could be more performant
07:50 Wrap up

Resources:

Check out our dedicated refactoring playlist for similar videos:

---
Liked this video? Please give it a Like and subscribe to not miss any future videos. 📈 🙏

Рекомендации по теме
Комментарии
Автор

Thank you, this helped me better understand classes and functions. I'm been solely using functions for a couple of years putting off learning classes and this has helped as i'm learning classes. Cheers

PaulHarrison-fe
Автор

Great example for class refactoring! ❤

robinbeer
Автор

more refactoring videos please
btw I'm curious about your vim setup

phatboislym