When you write a couple of classes and just realise that there are functionalities that can be shared, a tendency is to create a parent / abstract class or define a utility class. But inheritance and global utilities are often hard to test, failed to encapsulate functionality and highly coupled. In practices, using an interface offers a better design.

In this instance, I have several Adapter classes (in Spring) that wrap synchronous JDBC calls with a thread pool.

@Component
class ReactiveUserRelationalAdapter(
@Autowired val repo: UserRepository,
@Autowired @Qualifier("jdbcScheduler") val jdbcScheduler: Scheduler
): ReactiveUserService {
val logger: Logger = LoggerFactory.getLogger(ReactiveUserRelationalAdapter::class.java)

Nam Nguyen

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store