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
Adapter Pattern: Fitting a Third-Party SDK to Your Own Interface
Software Design PART 07

Adapter Pattern: Fitting a Third-Party SDK to Your Own Interface

Adapter fits a class you can't change to the interface the client expects; in C# that is almost always an object adapter, built with composition. Connecting two imaginary payment SDKs to a single IPaymentGateway, turning a callback into a Task with TaskCompletionSource, mapping error codes to domain exceptions and verifying both adapters with the same contract test.

7 Nov 2026 14 min 58
Prototype Pattern: record and with, Shallow vs Deep Copy and Why ICloneable Is Discouraged
Software Design PART 06

Prototype Pattern: record and with, Shallow vs Deep Copy and Why ICloneable Is Discouraged

Prototype creates a new object by copying a configured sample instead of building it from scratch; in C#, the with expression on records does this while preserving the runtime type, but the copy is shallow. A prototype registry, controlled deep copies with a copy constructor, ICloneable's vague contract, the measured cost of copying through JSON and the with traps that skip validation.

7 Nov 2026 16 min 79
Builder Pattern: Fluent Builders, WebApplicationBuilder and Where Object Initializers and required Fall Short
Software Design PART 05

Builder Pattern: Fluent Builders, WebApplicationBuilder and Where Object Initializers and required Fall Short

required, init and object initializers make a many-parameter constructor readable, but they do not solve cross-field rules, step order or an immutable result that accumulates piece by piece; Builder enforces those rules at a single Build() moment. How with skips a record's rule, the GoF Builder with a director versus the fluent builder, UriBuilder, connection string builders, the ImmutableArray builder, HostApplicationBuilder and the step builder, with real output.

7 Nov 2026 16 min 67
Abstract Factory: Creating Families of Compatible Objects Together
Software Design PART 04

Abstract Factory: Creating Families of Compatible Objects Together

Abstract Factory makes invalid combinations impossible by creating products that must fit together (such as blob storage, queue and secret store) from a single factory; the price is that adding a new product changes every factory. Choosing the family through configuration, ADO.NET's DbProviderFactory and CanCreateBatch, and a factory per tenant with keyed services, with real output.

7 Nov 2026 15 min 61
Factory Method and Static Factories: Delegating Creation to Subclasses or a Single Method
Software Design PART 03

Factory Method and Static Factories: Delegating Creation to Subclasses or a Single Method

The GoF Factory Method leaves the choice of product to a subclass; a static factory method is a single named method that replaces a constructor, can cache and can return a hidden subtype. The factory-method-in-constructor bug and CA2214, DbConnection.CreateDbCommand, ILoggerFactory and IHttpClientFactory, Func<T>, ActivatorUtilities and keyed services in DI, and ownership of IDisposable products, with real output.

7 Nov 2026 16 min 64
Singleton Pattern: Thread-Safe Lazy<T>, Static Fields and Why the DI Singleton Lifetime Is Better
Software Design PART 02

Singleton Pattern: Thread-Safe Lazy<T>, Static Fields and Why the DI Singleton Lifetime Is Better

If you need a single instance, the cleanest route is not the classic Singleton but registering with AddSingleton in the DI container: the single-instance guarantee stays, while global access and hidden dependencies go away. The race in a naive Singleton, the history of double-checked locking, static readonly and beforefieldinit, Lazy<T>'s exception caching, captive dependencies and shared state inside a singleton, with real output.

7 Nov 2026 14 min 95
What Is a Design Pattern? The GoF Catalog, Pattern Anatomy and Patterns That Vanish in Modern Languages
Software Design PART 01

What Is a Design Pattern? The GoF Catalog, Pattern Anatomy and Patterns That Vanish in Modern Languages

A design pattern is a named solution to a design problem that recurs in a given context, with defined roles and a known price (its consequences); it is not a diagram to memorise. The idea from Alexander to the GoF, the GoF's 13-section template, the purpose × scope map, and Norvig's observation on patterns that turn invisible in C# as yield, event and lambdas.

7 Nov 2026 14 min 79
Clean Code in Practice: Cleaning Up a Legacy OrderService Step by Step
Software Design PART 14

Clean Code in Practice: Cleaning Up a Legacy OrderService Step by Step

The safe way to clean up legacy code is to first pin the current behavior with a small seam and characterization tests, then make every step a separate commit and keep behavior changes in their own fix commits. The post cleans up the 609-line OrderService in 16 commits with green tests at every commit; the highest Cognitive Complexity drops from 92 to 10, and the smells left on purpose are listed with their reasons.

7 Nov 2026 14 min 54
The Clean Code Debate: Ousterhout, Muratori and the Limits of the Rules
Software Design PART 13

The Clean Code Debate: Ousterhout, Muratori and the Limits of the Rules

Ousterhout and Martin agree on the goal, reducing the reader's load; they part on how far to split methods, the value of comments and TDD. The post summarizes the 2024–25 debate, Muratori's performance critique (repeated in C# with BenchmarkDotNet) and qntm's critique of the book from each side's own sources.

7 Nov 2026 13 min 83
A Code Smell Catalog: Recognizing Smells in C# Code
Software Design PART 12

A Code Smell Catalog: Recognizing Smells in C# Code

A code smell is a quick, visible hint that something deeper in the design may be wrong; it's not a diagnosis but a sign of where to look. The post maps Fowler's 24 second-edition smells onto Mäntylä's five groups, looks for each one in the legacy OrderService.cs and shows with real output which ones SonarAnalyzer catches and which it misses.

7 Nov 2026 12 min 60
The Four Rules of Simple Design: Passes Tests, Reveals Intent, No Duplication, Fewest Elements
Software Design PART 11

The Four Rules of Simple Design: Passes Tests, Reveals Intent, No Duplication, Fewest Elements

Kent Beck's simple design rules, in priority order, are: passes the tests, reveals intention, no duplication, fewest elements. The post grows a coupon discount calculation step by step with these four questions, separates coincidental similarity from real duplication and shows the cost of an over-generalized version that passes the same tests.

7 Nov 2026 13 min 68
Clean Test Code: F.I.R.S.T., Readable Asserts and Test Data Builders
Software Design PART 10

Clean Test Code: F.I.R.S.T., Readable Asserts and Test Data Builders

A clean test is fast, independent, repeatable, self-validating and timely (F.I.R.S.T.); the legacy OrderService tests break on Saturdays because of DateTime.Now and depending on run order because of the static Db. With TimeProvider and FakeTimeProvider, a test data builder, test names that read like sentences and asserts that state the reason when they fail, we turn the same rules into clean tests.

7 Nov 2026 11 min 61
Blog Map