Posts

Java Adapter and Facade Patterns: Integrate Incompatible Code Cleanly

Maya's bookstore now sells online, and the shop needs to take card payments. The shop already has a payment account with a legacy gateway, LegacyPay — a vendor library the shop cannot change. Its jar is signed, the vendor is long gone, and three other systems already depend on its exact behavior. It speaks a different language from the rest of the shop: amounts in cents as a plain long , and integer status codes instead of results. Meanwhile, checkout itself is scattered: the web handler reserves stock, calls the gateway, creates the shipment, and sends the confirmation — and the phone-order tool repeats the same four steps, with its own copy of the error handling. The question this post asks: how do you use code you cannot change, and how do you stop every caller from having to know how checkout works? Post 1 asked what varies? Post 2, Java Singleton Pattern: Enum, Lazy Holder & Double-Checked Locking Explained , asked how many? Post 3, Java Factory Pattern: Factory Method...

Java Builder Pattern: Build Complex Objects Without Telescoping Constructors

Maya's bookstore app has grown since the last post. Checkout notifies customers, regions have their own senders and footers, and the shop is selling steadily. Now Maya wants a monthly sales report: how much each category sold, in which region, above which order value — delivered as a PDF, a CSV, or a web page, to whoever needs to see it. The first version of the report request is a single constructor with seven parameters, and every call site carries a comment explaining which argument is which — because without the comment, nobody can tell. Then the shop asks for an eighth option, a minimum order count, and the comment gets longer while the constructor gets wider. The question this post asks is the one the comment is already answering: how do you build an object with many optional parts, readably? Post 1 asked what varies? Post 2, Java Singleton Pattern: Enum, Lazy Holder & Double-Checked Locking Explained , asked how many? Post 3, Java Factory Pattern: Factory Method vs A...

66 Linux, DSA & Behavioral Interview Questions and Answers for Java Backend Developers

This post answers 66 interview questions Java backend developers actually get asked about Linux commands, data structures and algorithms, and behavioral interviews — with a simple explanation first and a short worked example for each one. It is Part 6 of the Java Backend Interview Question Bank series, covering sections 13–15 of the bank: Linux & Operational Commands (Q418–433), DSA & Coding Practice (Q434–461), and Behavioral, Project & Managerial Interview (Q462–483). Part 1, 95 Microservices, Kafka & Redis Interview Questions and Answers , covered sections 7–9 (Q230–324). Part 2, 89 Spring Boot, Security & JPA Interview Questions and Answers , covered sections 3–5 (Q87–175). Part 3, 54 SQL & Database Engineering Interview Questions and Answers , covered section 6 (Q176–229). Part 4, 86 Core Java & Concurrency Interview Questions and Answers , covered sections 1–2 (Q1–86). Part 5, 93 Performance, System Design & Cloud Interview Questions and Answers , ...