[New Concept Docs]: Class Composition in Python
This issue describes how to implement the class-composition concept docs.
You can find the related concept exercise issue here
If you have not yet contributed to concept documents, this issue will require some upfront reading to give you the needed background knowledge.
â Getting started
Please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time.
General Contributing Docs:
- Contributing to Exercism | Exercism and GitHub | - Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Documents on Language Tracks and Concepts:
đ¯ Goal
These concept docs are meant to teach an understanding/use of class-composition in Python.
đĄ Learning objectives
- more fully understand the uses (and possible abuses) of
classesin Python - understand what
compositionis vsinheritanceandmultiple-inheritanceinclasses - learn a bit about the pros and cons of using
compositionvsinheritanceormixinsinclasses - learn about the "Composition over inheritance" principle
- learn a bit about
dependency injection/inversion of controlas acompositiondesign pattern
đĢ Out of scope
Concepts and Subjects that are Out of Scope (click to expand)
-
metaclasses -
dataclasses -
decoratorsoutside of@property,@staticmethod, and@classmethod(the student should already be exposed to these in the prerequisite exercise) -
generators -
coroutines -
descriptors(these will get their own exercise) - using a
classas a decorator - performance considerations
đ¤ Concepts
Concepts & Related Concepts Under This Topic (click to expand)
-
classes -
compositioninOOP -
encapsulationinOOP -
inheritanceinOOP -
dependency injection
âŠī¸ Prerequisites
These are the concepts/concept exercises the student should be familiar with before taking on/learning this concept.
Prereqs (click to expand)
-
basics -
booleans -
classes -
class-customization -
class-inheritance -
comparisons -
decorators -
dicts -
functions -
higher-order functions -
iteration -
lists -
numbers -
sequences -
sets -
strings -
tuples
đ Resources to refer to
Resources (click to expand)
- classes (Python tutorial)
- Real Python: Object-Oriented Programming in Python 3
- Real Python: Inheritance and Composition: A Python OOP Guide
- What is Composition (OOP in Python)
- What is Composition -- good explanation, but it uses Java
- Inheritance, Composition, and Aggregation in Python
- The Composition over Inheritance Principle
- Pythonic Dependency Injection: A Practical Guide
- Method Delegation in Python
- Python Data Model - Python Docs
- Stack Overflow: Composition and Aggregation in Python
đ Files to Be Created
File Detail for this Exercise
|
Please see the following for more details on these files: concepts
|
đļ Implementation Notes
- Example code should only use syntax & concepts introduced within these docs or one of the prerequisite concept exercises or documents. Where possible, please use REPL formatting, unless you are demonstrating pseudo code or a long code block. Please do not use syntax not previously covered in prerequisite topics or exercises. Please also follow PEP8 guidelines.
- Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.
đ Next Steps & Getting Help
-
If you'd like to work on this issue, comment saying "I'd like to work on this"(there is no real need to wait for a response, just go ahead, we'll assign you and put a[claimed]label on the issue). - If you have any questions while implementing, please post the questions as comments in here, or contact one of the maintainers on our Slack channel.