What Is and Is Not a Package
A good p4o package is a small, cohesive, reusable unit with:
- a clear API
- no app-specific assumptions
A package should have
- High cohesion: one clear purpose
- Low coupling: minimal knowledge of host app internals
- Stable API surface: documented and versioned
- Deterministic behavior: predictable inputs/outputs and test coverage
- Portability: usable by multiple projects without modifications
Good candidates
- Shared utilities: parsing, formatting, validation
- Integration clients with stable contracts
- Cross-cutting primitives: logging, caching, retry/backoff
Not good candidates
- App-specific routing/page logic
- Code tightly bound to one environment or one product
- Thin wrappers with no additional value
- Hidden mutable singletons with implicit side effects