Design principles and architectural decisions behind DazzleLib
DazzleLib libraries are designed as composable building blocks, not monolithic frameworks. This fundamental principle guides every architectural decision.
Libraries are composable primitives that can work independently or together. Each library solves a specific problem domain without requiring the entire ecosystem.
Work seamlessly on Windows, Linux, and macOS. Platform-specific features are clearly marked and gracefully degrade on unsupported platforms.
Maximum compatibility for both open source and commercial use. No licensing barriers to adoption.
Clear, predictable APIs with explicit behavior. No hidden side effects, no automatic configuration, no surprises.
Test coverage ensures reliability. All libraries maintain minimum 80% code coverage with comprehensive test suites.
Principle: Libraries have minimal external dependencies to reduce installation complexity and potential conflicts.
Why:
- Reduces dependency hell for users
- Faster installation times
- Lower risk of version conflicts
- Easier to audit and maintain
In Practice:
- Prefer standard library when possible
- Optional dependencies for advanced features
- Clear documentation of all dependencies
Principle: All APIs work consistently across Windows, Linux, and macOS. Platform-specific features are clearly marked and gracefully degrade.
Why:
- Users shouldn't need to worry about platform differences
- Code written once should run anywhere
- Platform-specific code is a maintenance burden
In Practice:
- Test on all three major platforms
- Platform-specific features return safe defaults on unsupported platforms
- Clear documentation of platform limitations
Example:
# UNCtools on Windows: Full UNC path parsing
from unctools import is_unc_path
is_unc_path(r"\\server\share") # Returns True
# UNCtools on Linux/macOS: Safe no-op
from unctools import is_unc_path
is_unc_path(r"\\server\share") # Returns False (no exception)Principle: Function behavior is predictable and well-documented. No magic, no surprises.
Why:
- Reduces cognitive load for users
- Makes debugging easier
- Prevents unexpected side effects
- Code is self-documenting
In Practice:
- Require explicit parameters instead of defaults when behavior is ambiguous
- No automatic file system modifications without explicit permission
- Clear error messages that explain what went wrong
- Type hints for all public APIs
Example:
# GOOD: Explicit behavior
copy_file("source.txt", "dest.txt", preserve_metadata=True, overwrite=False)
# BAD: Implicit magic
copy_file("source.txt", "dest.txt") # What happens? Overwrite? Preserve metadata?Principle: Libraries are designed to work together but don't require each other. Use what you need.
Why:
- Users only install what they need
- Libraries can evolve independently
- No vendor lock-in to entire ecosystem
- Easier to understand and maintain smaller libraries
In Practice:
- No circular dependencies between libraries
- Optional integration points between libraries
- Each library has a clear, focused purpose
Principle: We follow semantic versioning strictly. Breaking changes are rare and well-documented.
Why:
- Users can upgrade with confidence
- Reduces maintenance burden for dependent projects
- Builds trust in the ecosystem
In Practice:
- Semantic versioning (MAJOR.MINOR.PATCH)
- Deprecation warnings before removal
- Migration guides for breaking changes
- Long-term support for stable APIs
DazzleLib libraries form a directed acyclic graph - no circular dependencies.
UNCtools (standalone)
↓ (optional)
dazzle-filekit (uses UNCtools for Windows paths)
↓
dazzle-tree-lib (standalone, but often used with filekit)
Libraries form a directed acyclic graph. If Library A depends on Library B, Library B cannot depend on Library A.
Why: Circular dependencies make libraries impossible to install or upgrade independently.
Advanced features can require additional installs using extras syntax.
Example:
# Basic installation
pip install dazzle-filekit
# With UNC path support
pip install dazzle-filekit[unctools]Import exactly what you need. No import *, no automatic namespace pollution.
Example:
# GOOD: Explicit imports
from dazzle_filekit import copy_file, calculate_file_hash
# BAD: Namespace pollution
from dazzle_filekit import *All DazzleLib libraries maintain these quality standards:
Use type annotations for all public APIs to enable static analysis and IDE support.
def copy_file(source: str, dest: str, preserve_metadata: bool = True) -> None:
"""Copy file with optional metadata preservation."""
...Google-style docstrings for all public functions and classes.
def calculate_file_hash(filepath: str, algorithm: str = "sha256") -> str:
"""Calculate hash of file contents.
Args:
filepath: Path to file to hash
algorithm: Hash algorithm (sha256, md5, sha1, sha512)
Returns:
Hex digest string of file hash
Raises:
FileNotFoundError: If filepath does not exist
ValueError: If algorithm is not supported
"""
...Minimum 80% code coverage with comprehensive test suites.
Black + Flake8 compliant for consistent code style.
Prefer calculate_file_hash() over hash() - clarity over brevity.
Functions should return what users expect. No surprising tuple unpacking.
Error messages should explain what went wrong and how to fix it:
# GOOD
raise ValueError(
f"Algorithm '{algorithm}' not supported. "
f"Choose from: sha256, md5, sha1, sha512"
)
# BAD
raise ValueError("Invalid algorithm")When in doubt, choose the safest default behavior:
overwrite=False(don't destroy data by default)preserve_metadata=True(preserve information by default)verify=True(verify operations when possible)
As DazzleLib grows, we're considering additional principles:
Optimize common operations without sacrificing clarity.
Consider async variants for I/O-heavy operations.
Provide hook points for users to extend behavior without forking.
These principles are not set in stone. If you have ideas for improving DazzleLib's design philosophy, we'd love to hear them:
- GitHub Discussions: DazzleLib Discussions
- Philosophy Issues: Tag issues with
philosophylabel for architectural discussions
Part of DazzleProj - The Dazzle Ecosystem