Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
What Is Clean Code? Readability, Cost of Change and the 2025 Second Edition
Clean code is code that works and is also cheap to read and change: in Bookstore's legacy OrderService the same cart yields four different totals because of the Turkish I trap, a drifted copy of the pricing logic and DateTime.Now. The 2025 second edition rewrote the book into Code, Design, Architecture and Craftsmanship parts; this series cleans the 609-line file step by step.
Classes in Clean Code: Small Classes, Cohesion and Organizing for Change
A class's size is measured by the number of actors who ask it to change, not by lines; methods that share no fields and CA1822 "make it static" warnings signal low cohesion. In the legacy OrderService two price calculations in the same class had drifted apart, quoting 731.50 TRY and charging 690.52 TRY; we gather pricing into a single OrderPricing class and build modern C# classes with primary constructors, sealed and required.
A Code Smell Catalog: Recognizing Smells in C# Code
A code smell is a surface indication that usually points to a deeper design problem; 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.
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.