When Alistair Cockburn wrote the first paper about the pattern, he attempts to: “Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.”
But how do we implement this in Java and don’t die trying? First we need to understand what is a port and then what is an adapter.
A port is an interface, on the strict meaning of the word, please don’t think about an interface on Java. It’s an endpoint to allow us to consume or expose information to the outside. An adapter is a mechanism to translate the information from a device to the port.
Analogy
For example, a Video Card has many ports, but for now we need to think it has a VGA port, so we bought a new monitor and it came with only an HDMI port. Our Application is the whole Computer and their video cards is one of his domains. The Video Card Domain has ports to communicate with the outside (Infrastructure), but we need an adapter to translate the analog signal on a digital signal for the HDMI. Here comes the adapter to allow us to connect the computer to monitor and enjoy our games. So the video card sends the signal through a port to the adapter, and receives the data to show on the screen. The adapter is part of the infrastructure.