References#

Lecture 7

ENPM605 – L7: Object-Oriented Programming II

Covers class methods (@classmethod, factory methods), static methods (@staticmethod), object relationships (association, aggregation, composition), inheritance (super(), generalization, specialization, MRO, isinstance(), issubclass()), polymorphism, duck typing, operator overloading, abstract base classes (ABC, @abstractmethod), data classes (@dataclass, field(), __post_init__, frozen=True), __slots__, and typing.Protocol.

Python Language References
Python Tutorial: Classes

Python Tutorial

Official tutorial covering classes, inheritance, MRO, and Python’s object model.

https://docs.python.org/3/tutorial/classes.html
Built-in: classmethod

Built-in Functions

Documentation for the @classmethod and @staticmethod decorators.

https://docs.python.org/3/library/functions.html#classmethod
abc – Abstract Base Classes

Standard Library – abc

The abc module for defining abstract base classes and abstract methods.

https://docs.python.org/3/library/abc.html
dataclasses module

Standard Library – dataclasses

Full reference for @dataclass, field(), __post_init__, and frozen=True.

https://docs.python.org/3/library/dataclasses.html
typing.Protocol

Standard Library – typing

Documentation for Protocol and structural subtyping.

https://docs.python.org/3/library/typing.html#typing.Protocol
Python Data Model: __slots__

Python Data Model

Reference for __slots__, its memory implications, and behavior in inheritance hierarchies.

https://docs.python.org/3/reference/datamodel.html#slots
UML and Design Resources
PlantUML Class Diagrams

PlantUML

Syntax reference for class diagrams including association, aggregation, composition, and inheritance notation.

https://plantuml.com/class-diagram
Mermaid

Mermaid

JavaScript-based diagramming tool with Markdown integration for class and relationship diagrams.

https://mermaid.js.org/
External Tutorials
Real Python: Inheritance and Composition

Real Python

In-depth guide to inheritance and composition with practical examples and trade-off analysis.

https://realpython.com/inheritance-composition-python/
Real Python: super()

Real Python

Detailed walkthrough of super(), the MRO, and cooperative multiple inheritance.

https://realpython.com/python-super/
Real Python: Abstract Base Classes

Real Python

Guide to defining interfaces in Python using ABCs and Protocols.

https://realpython.com/python-interface/
Real Python: Data Classes

Real Python

Comprehensive guide to @dataclass, field(), __post_init__, frozen instances, and comparison with named tuples and regular classes.

https://realpython.com/python-data-classes/
Real Python: Instance, Class, and Static Methods

Real Python

Side-by-side comparison of the three method types with practical use cases.

https://realpython.com/instance-class-and-static-methods-demystified/
Real Python: __slots__

Real Python

Deep dive into __slots__, memory profiling, and inheritance considerations.

https://realpython.com/python-slots/
Real Python: Protocols in Python

Real Python

Guide to typing.Protocol, structural subtyping, and @runtime_checkable.

https://realpython.com/python-protocol/
Python Glossary: Duck Typing

Python Glossary

Official definition of duck typing and its role in Python’s object model.

https://docs.python.org/3/glossary.html#term-duck-typing
Style and Best Practices
PEP 8 – Style Guide

Coding Conventions

Guidelines for class naming, method organization, and inheritance patterns.

https://peps.python.org/pep-0008/
Google Python Style Guide

Google Style Guide

Style conventions used in this course for docstrings and code organization.

https://google.github.io/styleguide/pyguide.html
Recommended Reading
Luciano Ramalho

Fluent Python (2nd Edition)

Chapters 11-14 cover the Python data model, special methods, interfaces, protocols, and ABCs. Chapters 22-24 cover dynamic attributes and descriptors. Essential reading for a deep understanding of Python’s object model.

Mark Lutz

Learning Python (5th Edition)

Chapters 29-32 cover advanced OOP topics: class design, advanced inheritance, operator overloading, and class decorators.

Brett Slatkin

Effective Python (2nd Edition)

Items 37-44 cover classes and inheritance, including super(), @classmethod, @staticmethod, @property, descriptors, and metaclasses.

Gamma et al.

Design Patterns (Gang of Four)

The foundational reference for object-oriented design patterns. Factory Method, Composite, and Strategy are directly relevant to the patterns introduced in this lecture.