QamoosTech
Programming FundamentalsObject-oriented programmingBeginner

Class

PronunciationKLAS

Definition

A blueprint that groups data and the functions that work on that data. Each object created from a class holds its own copy of the data.

Where you hear it

Object-oriented programming in Java, Python, TypeScript, and C#.

Examples

  • Create a Invoice class with a calculateTotal method.
  • This class is doing too much. Let's split it.
  • The Invoice class has a method that calculates the total from its items.

Common mistake

Putting everything in one giant class. Small classes with one responsibility are easier to test.

Don't confuse with

Class defines the blueprint and structure for creating objects, while an object is the actual instance of that class living in memory.

Say it at work

  • In a meeting or chatLet's create a new class for the payment processing logic to keep things modular.
  • In an email or ticketPlease ensure this class handles only single-responsibility tasks before we merge the pull request.