Adapter and Factory: integrating a payment gateway and picking the right implementation
Review an Adapter for a payment gateway that takes VND (a cast that drops the cents, double for money, int overflow) and rewrite it with Money, a sealed result and per-currency rounding. Then tell simple factory, Factory Method and Abstract Factory apart, build a bean registry in Spring, and avoid two wiring traps: @RequiredArgsConstructor with non-final fields and injecting by a parent class.