Skip to content

Instantly share code, notes, and snippets.

@fResult
fResult / EligibleEmployeeForJava8.java
Last active January 11, 2026 17:42
This is a part of my post, "When Language Ergonomics Fight Your Architecture (And How to Win)" on LinkedIn (https://www.linkedin.com/feed/update/urn:li:activity:7415629554402111488)
import java.util.Objects;
import java.util.Optional;
import lombok.Builder;
import lombok.Value;
import lombok.experimental.Accessors;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@Value // ← Use Lombok's @Value to simulate Java Record
@Accessors(fluent = true) // ← Great choice to mimic Record accessors
@fResult
fResult / HighEntropy.kt
Created November 1, 2025 17:12
High-Entropy VS Low-Entropy in Spring Cloud Gateway
@Configuration
@Profile("routes-filter")
class FilterConfiguration {
companion object {
private val log = Loggers.getLogger(FilterConfiguration::class.java)
}
@Bean
fun filterGateway(builder: RouteLocatorBuilder): RouteLocator =
builder.routes()
@fResult
fResult / changes.diff
Last active September 21, 2025 11:30
Git diff (source/main…HEAD) capturing my personal code notes for Medium post“Personal Notes: Documenting PR Changes with AI (no Agent mode version).”
diff --git a/README.md b/README.md
index ced9bd0..d30d6ec 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,9 @@ Each module is implemented in both [Java](./java) and [Kotlin](./kotlin) to comp
- Implemented parallel Kotlin versions of Java examples
- Updated to Spring Boot 3.5.x while the book uses an older Spring Boot version 2.5.0
- Adopted a monorepo approach with [Gradle Multi-project Builds][gradle-multiproject] and [Gradle Composite Builds][gradle-composite-builds] to manage both Java and Kotlin implementations in a single repository
+ - Learned that Gradle Kotlin DSL supports both type-safe and string-based dependency declarations, and that the string-based form was required
+ in [`08:rsocket/build.gradle.kts`](./kotlin/08-rsocket/build.gradle.kts) when adding dependencies inside `afterEvaluate`
@fResult
fResult / PricingDiscountApp.java
Last active June 3, 2025 10:36
Example for the article https://fresult.medium.com/31014f433b49 and POC Strategy Design Pattern
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
class PricingDiscountApp {
public static void main(String[] args) {
final var customer1 = new Customer("1", "John Doe", CustomerType.VIP);
final var customer2 = new Customer("2", "Jane Doe", CustomerType.REGULAR);
final var customer3 = new Customer("3", "Business Corp", CustomerType.BUSINESS);
import java.time.LocalDateTime;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
class DocumentProcessorApp {
public static void main(String[] args) {
final var trinity = new Submitter("trin123");
final var morpheus = new Approver("morph456");
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
class TripAnalyzerApp1 {
private static final List<Trip> TRIPS = List.of(
new Trip(TripType.BUSINESS, "Tokyo", Duration.ofHours(5),LocalDateTime.of(2025, 5, 25, 8, 0), "Thomas Anderson", new BigDecimal("1200.00")),
import static java.time.temporal.ChronoUnit.HOURS;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.function.Supplier;
@fResult
fResult / TestSecureResource1.java
Last active May 11, 2025 16:25
Try Union Type In Java
sealed interface Permission permits Read, Write {}
record Read() implements Permission {}
record Write() implements Permission {}
record Execute() {}
class ResourceAction {
public String perform(Permission permission) {
return String.format("Performing action with %s...", permission.getClass().getSimpleName());
}
@fResult
fResult / Customer.java
Last active April 20, 2025 13:29
Optional Demo for the article: https://medium.com/p/03845513d9f5 (You can see the whole code block at the file in the bottommost.)
// Basic domain record
public record Customer(String id, String email) {}
type Functor<T> = {
map<R>(fn: (val: T) => R): Functor<R>
concat(other: Functor<T>, combiner: (a: T, b: T) => T): Functor<T>
getValue(): T
}
function id<T>(value: T): Functor<T> {
return {
map<R>(fn: (val: T) => R): Functor<R> {
return id(fn(value))