Redowan's Reflections — Page 7
Recent writing
Longer articles, short notes, and things I'll probably need to look up again.
Browse the archiveUnderstand TypeIs vs TypeGuard in Python: TypeIs provides more intuitive type narrowing by narrowing both positive and negative branches.
Implement client-side HTTP caching with ETag headers. Learn If-None-Match, 304 Not Modified responses, and weak validation in Go servers.
Troubleshoot CORS errors with this practical guide. Learn Access-Control-Allow-Origin headers, preflight requests, and domain allowlisting in Go.
Discover a simpler alternative to functional options: method chaining with builder-style configuration that's 76x faster and easier to understand.
Why accumulated knowledge can prevent learning new paradigms, and how past expertise becomes the barrier to future growth.
Replace inheritance with the Strategy pattern in Go using interfaces. Achieve composable, testable code without class hierarchies.
Learn how to build custom error types in Go to create stack traces without runtime overhead, inspired by Rob Pike's Upspin error handling.
Build retry logic in Go without reflection using generics. Implement exponential backoff and configurable retry strategies with type safety.
Master Go type assertions with i.(T) syntax and type switches. Extract concrete types from interfaces safely with ok idiom examples.
Mock pydantic_settings in pytest tests by patching the settings class to prevent flaky tests from environment variable dependencies.
Track dev dependencies like golangci-lint in go.mod with a tools.go file and build tags to exclude them from production binaries.
Why you should define API response structures explicitly. Compare approaches in Python, JavaScript, and Go with Pydantic, Zod, and structs.
Properly annotate Python *args and **kwargs with heterogeneous types using Unpack, TypedDict, and modern type hints from PEP-692.
Implement rate limiting at the infrastructure layer with Nginx reverse proxy. Protect Go services from DDoS with leaky bucket algorithm.
Enforce immutable dataclasses at type-check time with @final decorator to catch mutations before runtime without frozen=True performance cost.