Intro to Class Attributes and Class Methods: Software Engineering Full time 13 Phase 3 Hybrid

Close

Learning Goals


Key Vocab


Introduction

Classes are like the blueprint from which individual objects are created. When you make use of classes you can reuse code rather than writing similar code over and over again. This makes code more readable, and follows the principle of "DRY" (Don't Repeat Yourself).

So far, we've primarily created instance methods and instance attributes for our individual objects to use. However, we can also create class methods and class attributes. Class attributes are used to store values related to a class in general rather than a particular instance. Class methods are similarly used for implementing behavior that is related to a class in general rather than an instance.

In the next several lessons we'll be taking a look at:

At a glance, you might assume class attributes work like instance attributes; however, this is not the case. In this section, we'll distinguish the difference between class methods and attributes and when to use them.


Resources