Name giving can easily become a heated debate as we are talking semantics. If you really look at what the proposed
gateway is, you’ll find that it is actually “just” an
adapter interface for the
data side, using the term
data side from the
ports and adapter pattern by Alistair Cockburn, which Uncle Bob’s clean architecture seem to adhere to. The
data side gives
access to data, so we get that the
gateway is really a
data access adapter interface. Whether you find that gateway is a good term to describe this interface, I’ll leave entirely up to you. To me, a gateway indicates something that can be opened and closed by, well, a gate. And I suspect UncleBob to have chosen this word by inspiration of the word
port in the
ports and adapters pattern, though that shall remain complete speculation
. However, UncleBob’s gateway is
not a
port in the
ports and adapters pattern. It is, as mentioned, an
adapter interface.
On a side note, having defined an
adapter interface as the
gateway, does not guarantee that it works the intended way. For example, a
gateway might have some
get-me-this-entity-named-bla-bla-method defined, but not every technology that a
gateway implementation / adapter “wraps” might be able to actually provide entity data by those means.
Summing up, in my world,
gateway doesn’t say as much as
data access adapter, or
repository, for that matter. Take a look at these below, and consider which names would tell an unknowing more about what they really are.
UserGateway
UserRepository
UserDataAccessAdapter
In the end, it’s all about semantics, and Clean Code is all about conveying meaning of code.