Classes · Lesson 47 of 76
When to use classes
Classes are powerful, but you don't need them for everything. A simple guide:
Reach for a class when you have a "thing" that bundles data and actions on that data, and you'll make several of them — students, accounts, products, game characters.
A plain function (or dict) is enough when you just need to transform some values once. Don't wrap a single calculation in a class for no reason.
Python
Rule of thumb: start simple with functions. Reach for a class when you notice yourself passing the same group of values around together again and again.
You’re reading for free. Sign in to save your progress, ask questions on any lesson, and earn a certificate when you finish.Sign in to keep my progress →