C# 9 Records were reference types (classes). C# 10 introduces `record struct`, bringing immutability features to value types, eliminating heap allocations for small DTOs. Syntax Performance Benefit Since it’s a struct, `Point` lives on the stack. No GC pressure for creating thousands of them in a loop. Key Takeaways Use `readonly record struct` for small, […]
Read more →Month: August 2021
Docker Init Process: The Zombie Reaper
If your container spawns child processes (e.g., shell scripts), those children can become zombies when terminated. Docker defaults to PID 1 being your app, but PID 1 in Linux has special responsibilities—reaping orphaned children. Your app probably doesn’t do that. The Solution: `tini` Or simpler with Docker’s built-in: Key Takeaways Zombies consume PIDs. Too many […]
Read more →Svelte vs React: A 2021 Perspective
React involves shipping a runtime (Virtual DOM) to the browser. Svelte is a compiler that generates vanilla JS. The difference is profound. Reactivity Models React (Pull) React re-renders the component tree when state changes. You must use `useMemo` and `useCallback` to prevent unnecessary work. Svelte (Push) Svelte uses topological ordering during compilation. Assignments *are* the […]
Read more →Azure Service Bus: Messaging Patterns
Service Bus is Azure’s fully managed enterprise message broker. It supports Queues (point-to-point) and Topics/Subscriptions (pub/sub). Choosing the right pattern prevents architectural headaches. Queues vs Topics Dead-Letter Queue Messages that fail processing N times go to a special DLQ for inspection and replay. Key Takeaways Use **Sessions** for ordered processing (FIFO for a specific session […]
Read more →Managing Terraform State in Azure
Terraform’s `.tfstate` file is gold. If it’s lost or corrupted, Terraform cannot track what resources exist. You **must** store state remotely with locking. Azure Backend Configuration State Locking Azure Blob’s native lease mechanism prevents concurrent writes. Key Takeaways Never commit `.tfstate` to Git. Enable **soft delete** on the storage account to recover corrupted state. Use […]
Read more →Testing .NET 6 Applications: Integration Testing with WebApplicationFactory
Unit tests are not enough. Integration tests verify your app works end-to-end, including middleware, dependency injection, and database logic. `WebApplicationFactory` spins up an in-memory test host. Setup Customizing Services Replace the real database with an in-memory one. Key Takeaways Use **Testcontainers** (covered earlier) for real SQL testing. Check HTTP status codes, response bodies, and headers.
Read more →