AI engineering glossary · Python advanced
What is composition?
Composition: A design approach where an object holds other objects as attributes and delegates work to them, instead of inheriting from them. It expresses a 'has-a' relationship and is often more flexible than deep class hierarchies.
Composition: an example
A Pipeline object stores a Tokenizer and a Model as attributes and calls them in order, rather than inheriting from either.
Related terms
More Python advanced terms
Where you learn it
Composition is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.