Add section on inappropriate intimacy between classes
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- documentation
Research direction
Start by locating the course documentation section covering class design or plotting, since the issue does not name a file or entry point. Add the provided explanation and MIKE IO examples there, preserving the guidance on public APIs and data manipulation; done means the new section is published in the appropriate course material.
Written by the indexing model from the issue text.
Description
Classes should interact through public APIs, not by reaching into each other's private attributes.
Example from MIKE IO plotting refactor:
Before (inappropriate intimacy):
# Plotter reaches into geometry internals for subsetting
values = values[self.da.geometry.top_elements]
geometry = self.da.geometry.geometry2d
# Plotter uses private attribute to check for time axis
if self.da._has_time_axis:
return self.da.values[0]
After (using public API):
# Use sel/isel for subsetting
da = da.sel(layers="top")
geometry = da.geometry
# Use public dims property
da = self.da.isel(time=0) if "time" in self.da.dims else self.da
Key principles:
- Never access private attributes (prefixed with
_) of another class - Use public methods like
sel,isel, and public properties likedims - If you need to access private state, that's a signal the class is missing a public API
- Plotters should plot, not subset — keep data manipulation in the data layer
- Dominant language
- Jupyter Notebook
- Stars
- 8
- Forks
- 1
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DHI/python-package-development
-
Difficulty 2/5 1-2 days Newbie friendliness 88/100
-
Difficulty 2/5 1-2 days Newbie friendliness 72/100
DHI/python-package-development#37 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
All issues in DHI/python-package-development
Similar issues
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
feature pydanty:is-working
Difficulty 1/5 Under an hour Newbie friendliness 88/100
pydantic/pydantic-ai#8647 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
:watch: Not Triaged dotnet-fsharp/svc
Difficulty 1/5 Under an hour Newbie friendliness 90/100