Mert Özen Go Beyond the Code

Blog

Posts and series that take software and IT from the basics to advanced topics: from programming languages and databases to architecture and AI.

Series
1990 posts found
Idempotency Keys: Not Creating the Same Order Twice on Double Clicks and Retries
Software Design PART 19

Idempotency Keys: Not Creating the Same Order Twice on Double Clicks and Retries

The reliable way to stop the same order from being created twice on double clicks and retries is for the server to store a client-generated Idempotency-Key per user together with a request hash, and to write the work and the 'completed' record in the same transaction. This post covers the current status of the IETF draft (draft-08, not an RFC), the 400/409/422 rules and an ASP.NET Core endpoint filter + SQL Server implementation with real output.

7 Nov 2026 18 min 77
Time and Time Zones: UTC Instants, Local Business Dates, DateOnly and TimeProvider
Software Design PART 18

Time and Time Zones: UTC Instants, Local Business Dates, DateOnly and TimeProvider

Storing time correctly means separating three concepts: event moments are UTC instants (DateTimeOffset), calendar days are DateOnly, and future local events are wall-clock time plus an IANA zone id. This post shows, with real output, how to turn a tenant's day into a UTC range, a testable clock with TimeProvider, the AT TIME ZONE traps in SQL Server and the date shift in Angular.

7 Nov 2026 15 min 103
Money and Rounding: decimal, a Money Value Object, VAT and Distributing Cents
Software Design PART 17

Money and Rounding: decimal, a Money Value Object, VAT and Distributing Cents

Modeling money correctly takes a Money value object that carries the amount with its currency, the same explicit rounding rule in C# and SQL, and Allocate instead of division so no cent is lost. The post shows Math.Round and SQL ROUND disagreeing on half a cent (11.225), the 1-cent difference between per-line and total VAT, an effective-dated VAT rate table (20%, 10%, 1% as of November 2026), EF Core complex type mapping and string amounts in JSON, with real output.

7 Nov 2026 14 min 93
Numbering: Invoice and Order Numbers, Gapless Sequences and Yearly Resets
Software Design PART 16

Numbering: Invoice and Order Numbers, Gapless Sequences and Yearly Resets

An invoice number that must be consecutive shouldn't come from an identity, MAX + 1 or a SEQUENCE, but from a locked UPDATE on a counter table keyed by (Series, Year) inside the approval transaction; for order numbers where gaps are acceptable, a SEQUENCE is enough. The post shows GİB's 16-character document number format, gapless numbering under 50 concurrent approvals, the effect of lock duration on throughput and yearly resets by invoice date, with real output.

7 Nov 2026 13 min 76
Designing Feature Flags in Code: Toggle Types, Microsoft.FeatureManagement and Flag Debt
Software Design PART 15

Designing Feature Flags in Code: Toggle Types, Microsoft.FeatureManagement and Flag Debt

Designing a feature flag well means identifying its type first (release, experiment, ops, permission), keeping the decision in a single toggle router and giving every flag an owner and an expiration date. The post shows a tenant filter with Microsoft.FeatureManagement 4.8.0, in-request consistency with snapshots, a kill switch with WithFeatureGate and a test that catches expired flags, with real output.

7 Nov 2026 12 min 69
Settings Tables: A Global → Tenant → User Override Hierarchy
Software Design PART 14

Settings Tables: A Global → Tenant → User Override Hierarchy

For settings that change at runtime and are overridden per tenant and per user, the most robust approach is a definition per setting (type, default, range and lowest override level) plus typed key-value rows tied to it, with the precedence rule in one service and validated, audited writes. The post compares this with EAV, typed columns, a JSON document and an external store, and shows the hidden IS NOT NULL filter EF Core adds to unique indexes on nullable columns.

7 Nov 2026 14 min 71
Data Isolation in Multi-Tenancy: Database per Tenant, Shared Schema and Row-Level Security
Software Design PART 13

Data Isolation in Multi-Tenancy: Database per Tenant, Shared Schema and Row-Level Security

For most SaaS products the best balance is shared tables with a tenant column, a named tenant query filter in EF Core and, behind it, SQL Server row-level security fed by SESSION_CONTEXT. The post compares database per tenant, schema per tenant and shared tables, and shows tenant resolution, background jobs and automated isolation tests with real output.

7 Nov 2026 14 min 93
Multilingual Data: Storing Names in Turkish and English — Translation Tables, JSON Columns and Fallback
Software Design PART 12

Multilingual Data: Storing Names in Turkish and English — Translation Tables, JSON Columns and Fallback

For multilingual data managed by users, the most flexible option is a translation table keyed by (EntityId, Culture, Name) plus a fallback chain such as en-GB → en → tr built in one place. The post compares one column per language, translation tables, SQL Server 2025 json columns and a separate translation service, and shows the fallback with EF Core 10 LeftJoin and collation choice for the Turkish I with real output.

7 Nov 2026 14 min 79
Polymorphic Associations: Attaching Comments and Files to Multiple Tables
Software Design PART 11

Polymorphic Associations: Attaching Comments and Files to Multiple Tables

Linking attachments to several tables with an EntityType/EntityId pair loses FKs, cascade delete and safe authorization; when owner types are few and stable, use an exclusive arc with one nullable FK per owner and a check constraint requiring exactly one. Derive authorization from the owner's policy, not from the attachment itself.

7 Nov 2026 12 min 64
Hierarchical Data in SQL: Adjacency List, Recursive CTE, Closure Table and hierarchyid
Software Design PART 10

Hierarchical Data in SQL: Adjacency List, Recursive CTE, Closure Table and hierarchyid

When subtree queries on an institution unit tree are frequent and moves are rare, SQL Server's hierarchyid (with LINQ support since EF Core 8) plus a ParentId for FK integrity is a good choice; use a closure table if you need database independence. Walking the tree node by node in the application causes N+1, and cycles should be blocked at move time with IsDescendantOf.

7 Nov 2026 14 min 112
When the Status Column Is Updated from Everywhere: Transition Tables, State Machines and Status History
Software Design PART 09

When the Status Column Is Updated from Everywhere: Transition Tables, State Machines and Status History

Stop treating the status column as a field any endpoint can write: let the client send an action instead of a status, keep allowed transitions in one place (a transition table, domain methods or Stateless), write every transition with its reason to a status history in the same transaction, and use a rowversion to stop double approvals.

7 Nov 2026 12 min 66
Temporal Data: Effective-Dated Records, Price History and the Bitemporal Model
Software Design PART 08

Temporal Data: Effective-Dated Records, Price History and the Bitemporal Model

Data with retroactive corrections needs two time axes: valid time (which date the fact is true for) and transaction time (when it was recorded). A SQL Server temporal table only gives transaction time; make a table with half-open [ValidFrom, ValidTo) intervals system-versioned and you can write bitemporal queries with EF Core 10.

7 Nov 2026 12 min 94
Blog Map