官方定义
A northbound interface is an interface that conceptualizes lower level details. It interfaces to higher level layers and is normally drawn at the top of an architectural overview.
北向接口(Northbound Interface)是指,一个较低层次的接口连接更高层的层接口,通常绘制在体系结构概述的顶部。
A southbound interface decomposes concepts in the technical details, mostly specific to a single component of the architecture. Southbound interfaces are drawn at the bottom of an architectural overview.
南向接口(Southbound Interface)是指,偏重技术细节,主要是特定于架构的单个组件。通常绘制在体系结构概述的底部。
命名由来
北向接口因处于架构图的顶部而得名,南向接口则因处于架构图的底部而得名,地图中上北下南。
简图解释
![[]](https://www.zhangqin.tech/2021/09/11/%E7%90%86%E8%AE%BA/%E5%8D%97%E5%90%91%E6%8E%A5%E5%8F%A3%E4%B8%8E%E5%8C%97%E5%90%91%E6%8E%A5%E5%8F%A3/%E5%8D%97%E5%90%91%E6%8E%A5%E5%8F%A3%E4%B8%8E%E5%8C%97%E5%90%91%E6%8E%A5%E5%8F%A3.png)
南北向接口只是针对某个组件来说的,向下的接口称为南向,向上的接口称为北向。
例如在 Spring 项目中,View 对 Controller 层就是北向接口,Controller 对 Service 层就是南向接口,而 Service 对 mapper 层又是北向接口,mapper 层对数据库层又是北向接口。