{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch10-title",
   "metadata": {},
   "source": [
    "# OOP"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch10-overview",
   "metadata": {},
   "source": [
    "Object-oriented programming is a paradigm for organizing data and behavior together in reusable types.\n",
    "\n",
    "- Classes as blueprints for objects\n",
    "- Instances as concrete objects with their own state\n",
    "- Methods as behavior attached to objects\n",
    "- Encapsulation, inheritance, polymorphism, and abstraction\n",
    "- Advanced class features for Pythonic designs\n",
    "\n",
    "This chapter starts with foundational ideas, works through practical examples, and builds toward more advanced OOP techniques.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1000-video",
   "metadata": {},
   "source": [
    "<h2>Chapter Video</h2>\n",
    "\n",
    "This overview introduces classes, instances, attributes, and methods in Python.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/ZDa-Z5JzLYM\" title=\"Python OOP Tutorial 1: Classes and Instances\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "```\n",
    "\n",
    "> *[Python OOP Tutorial 1: Classes and Instances (15:24)](https://youtube.com/watch?v=ZDa-Z5JzLYM) by Corey Schafer*\n",
    ">\n",
    "> Hosted on YouTube; property of its original creator, embedded here for educational reference only."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch10-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Objectives</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Explain what object-oriented programming is, distinguish a class from an instance, and recognize built-in values as instances of classes\n",
    "2. Define a class with `__init__`, attributes, and methods, and give its objects readable `__str__` and `__repr__` representations\n",
    "3. Protect an object's state with naming conventions and `@property`\n",
    "4. Build a class hierarchy with inheritance, `super()`, and method overriding, and use polymorphism to call the same method on different classes\n",
    "5. Define an abstract base class with `abc` that requires its subclasses to implement certain methods\n",
    "6. Implement comparison and arithmetic special methods, and choose among `@dataclass`, `namedtuple`, `@staticmethod`, and `@classmethod` for records and class-level behavior\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch10-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{container} chapter-flow\n",
    "1. {doc}`0901-oop-design`\n",
    "2. {doc}`0902-oop-pillars`\n",
    "3. {doc}`0903-oop-advanced`\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch09-glossary",
   "metadata": {},
   "source": [
    "<h2>Glossary</h2>\n",
    "\n",
    "| # | Term | Explanation |\n",
    "|---:|---|---|\n",
    "| 1 | Object-oriented programming | A programming style that organizes data and behavior into objects. |\n",
    "| 2 | Class | A blueprint for creating objects with shared attributes and methods. |\n",
    "| 3 | Instance | A specific object created from a class. |\n",
    "| 4 | Attribute | Data stored on an object or class. |\n",
    "| 5 | Method | A function defined inside a class and called on an object or class. |\n",
    "| 6 | `self` | The conventional name for the current instance inside an instance method. |\n",
    "| 7 | Constructor | Code that initializes a new object, commonly written with `__init__`. |\n",
    "| 8 | Dunder method | A special method with double underscores, such as `__str__` or `__lt__`. |\n",
    "| 9 | Encapsulation | Keeping related data and behavior together behind a clear interface. |\n",
    "| 10 | Inheritance | Defining a class from another class to reuse or specialize behavior. |\n",
    "| 11 | Polymorphism | Using a shared interface with objects of different types. |\n",
    "| 12 | Abstraction | Focusing on what an object does while hiding unnecessary implementation details. |\n",
    "| 13 | Method overriding | Redefining an inherited method in a child class. |\n",
    "| 14 | `super` | A function used to call behavior from a parent class. |\n",
    "| 15 | Dataclass | A class created with `@dataclass` to reduce boilerplate for data objects. |\n",
    "| 16 | `namedtuple` | An immutable tuple-like object whose fields can be accessed by name. |\n",
    "| 17 | Class variable | A variable stored on the class and shared by its instances. |\n",
    "| 18 | Instance variable | A variable stored separately on each instance. |\n",
    "| 19 | Static method | A method placed in a class namespace that does not receive `self` or `cls`. |\n",
    "| 20 | Class method | A method that receives the class as its first argument, conventionally named `cls`. |\n",
    "| 21 | Abstract base class | A class that cannot be instantiated and declares methods its subclasses must implement, created with the `abc` module. |\n",
    "| 22 | `@property` | A decorator that lets a method be read like an attribute, used to control access to an object's state. |\n",
    "| 23 | Name mangling | Python renames an attribute that starts with two underscores, such as `__pin`, to `_ClassName__pin`, which discourages access from outside the class. |\n",
    "| 24 | Operator overloading | Defining special methods such as `__add__` or `__lt__` so that operators like `+` and `<` work with your objects. |\n",
    "| 25 | Frozen dataclass | A dataclass created with `frozen=True`, whose fields cannot be changed after the object is created. |\n",
    "| 26 | Bound method | A method accessed through an object without calling it, which remembers that object and can be stored in a variable and called later. |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1000-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
