30 Eylül 2026 Çarşamba

Type-state Pattern - Phantom Types

Giriş
Type safe Java içindir

Örnek
Şöyle bir kod olsun
sealed interface OrderState
        permits Unpaid, Paid, Shipped {
}
record Unpaid() implements OrderState {}
record Paid() implements OrderState {}
record Shipped() implements OrderState {}

Order şöyle olsun
record Order<S extends OrderState>(
        String id
) {
}

Factory ve transition şöyle olsun
static Order<Unpaid> newOrder(String id) {
    return new Order<>(id);
}

static Order<Paid> pay(Order<Unpaid> order) {
    return new Order<>(order.id());
}

static Order<Shipped> ship(Order<Paid> order) {
    return new Order<>(order.id());
}

Artık API şöyle
Order<Shipped> ship(Order<Paid> order)


2 Temmuz 2026 Perşembe

async-profiler Aracı

Giriş
Flame graph üretir, grafiği nasıl yorumlayacağımızı anlatan bir yazı burada. Kullanım şöyle
asprof -d 30 -f flamegraph.html <PID>

3 Şubat 2026 Salı

Eventual Immutability

Giriş
Bu konuyu ilk defa burada gördüm. Nesneyi mutable olarak yarattıktan sonra belli bir noktada freeze() metodunu çağırıyoruz ve bundan sonra nesne immutable oluyor.

14 Mart 2025 Cuma

JEP 491 - Synchronize Virtual Threads without Pinning.

Giriş
Açıklaması şöyle
Improve the scalability of Java code that uses synchronized methods and statements by arranging for virtual threads that block in such constructs to release their underlying platform threads for use by other virtual threads. This will eliminate nearly all cases of virtual threads being pinned to platform threads, which severely restricts the number of virtual threads available to handle an application's workload.
synchronized block kullanıyorsak Virtual Thread pinned oluyor. Bu JEP ile artık olmuyor

20 Ocak 2025 Pazartesi

IntelliJ Idea Comment İçin Code Style

Comment At Firt Column
Cevap burada
  • Settings | Editor | Code Style | Java | Code Generation | Comment Code | Line comment at first column -> Uncheck
  • Settings | Editor | Code Style | Java | Code Generation | Comment Code | Block comment at first column -> Uncheck
  • Settings | Editor | Code Style | Java | Wrapping and Braces | Keep when reformatting | Comment at first column -> Uncheck

Ayrıca Method Call Argument uzunsa ayrı satıra gelsin diye
  • Settings | Editor | Code Style | Java | Wrapping and Braces | Method Call Arguments | -> Wrap if long
Ayrıca Chained method calls her biri ayrı satıra gelsin diye
  • Settings | Editor | Code Style | Java | Wrapping and Braces | Chanied Method Calls | -> Wrap always

14 Ocak 2025 Salı

javadoc komutu

Örnek
Şöyle yaparız. docs/index.html dosyasını oluşturur
javadoc --enable-preview --source 22 -d docs Calculator.java


29 Aralık 2024 Pazar

JMeter CLI

CLI vs Non-CLI
Açıklaması şöyle
JMeter has two modes: CLI and Non-CLI. .... CLI mode doesn't have any user interface. But Non-CLI mode has a user interface where you can point-and-click and interact with the JMeter.

Non-CLI mode should be used for recording, scripting, and smoke testing. This mode utilizes more resources (CPU and memory). CLI mode must be used for load testing, stress testing, and other forms of performance testing as well as for CI/CD pipelines. This mode doesn't eat up more resources as there is no user interface to load and render.
Örnek
Şöyle yaparız
jmeter -n -t test_plan.jmx -l test_results.jtl