The idea dates from Simula 67 and was named and spread by Smalltalk in the nineteen-seventies; Java, C++, C#, Python, Ruby and JavaScript in its class syntax all descend from it. MDN's three core concepts cover most of what a course teaches. A class is a template that describes what an object has and does; an instance is one object made from it, so a class called Order describes orders and each customer's purchase is an instance. Inheritance lets a class extend another, so a RefundedOrder can share everything Order defines and add the refund. Encapsulation keeps an object's internal state private behind a public set of operations, so the only way to change an order's total is through a method that also updates the tax.
Polymorphism is the fourth word on every syllabus: a method name that behaves differently depending on which class the object belongs to, so that a list of shapes can be told to draw themselves and each one knows how. In Python the whole model is lightweight, a class statement, methods that receive the instance as their first argument, and no enforced privacy beyond a naming convention; in Java every file is a class and the compiler enforces what is public. The difference matters for learners: the Python version can be learned in a day, the Java version takes considerably longer, and both teach the same four ideas.
- Class: the description. Order has an id, a list of lines, a status and a method that computes the total.
- Instance: one order with its own id and lines. Two instances do not share state.
- Inheritance: SubscriptionOrder extends Order with a renewal date and overrides the total to add the period.
- Encapsulation: nothing outside the class sets the status directly; a method named cancel checks the rules first.
- Polymorphism: code that calls total on any order gets the right answer without knowing which kind it holds.
Where the style goes wrong is in overuse of hierarchy. Modelling a business as a tree of classes feels natural and produces the inheritance ladders that make a change to a base class ripple into every descendant. The design advice that has held since the nineteen-nineties is to favour composition over inheritance: an Order holds a PaymentMethod and a ShippingRule rather than being a PaidShippedOrder. Most modern codebases mix styles, with objects for the things that have state and plain functions for everything else, and the programming fundamentals courses teach object orientation as one tool in that mix rather than as the whole of programming. Google's automation certificate, IT Automation with Python, introduces classes in its first course at the depth an automation script needs.
