2023-11-06 16:05:27 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<title>
|
|
|
|
|
领域驱动设计
|
|
|
|
|
</title>
|
|
|
|
|
<meta name="description" content="">
|
|
|
|
|
<meta name="keywords" content="">
|
|
|
|
|
<meta name="author" content="Mozzie">
|
2024-03-15 15:38:52 +08:00
|
|
|
|
<link rel="canonical" href="https://maxshader.com/posts/31204/">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="icon" type="image/svg" href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 7h1a2 2 0 0 1 2 2v.5a.5.5 0 0 0 .5.5a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5a.5.5 0 0 0-.5.5v.5a2 2 0 0 1-2 2h-2"></path><path d="M8 7H6a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1"></path><path d="M12 8l-2 4h3l-2 4"></path></g></svg>'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<link rel="stylesheet" href="/css/b4c95347.css">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<script>window.i18n = {"tip-status-done":"完成","tip-status-default":"全部","tip-status-todo":"计划","tip-status-doing":"进行","tip-status-other":"其他","text-select":"选择","text-move":"移动","text-esc":"退出","January":"一月","February":"二月","March":"三月","April":"四月","May":"五月","June":"六月","July":"七月","August":"八月","September":"九月","October":"十月","November":"十一月","December":"十二月"}</script>
|
|
|
|
|
<meta name="generator" content="Hexo 7.0.0"></head>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
<body id="app">
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<aside id="aside-box" class="left-aside">
|
|
|
|
|
<div class="header">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<link rel="stylesheet" href="/css/61875ce9.css">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<div class="profile">
|
|
|
|
|
<a class="badge" href="/">
|
|
|
|
|
<span>Hi</span>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<span>Mozzie</span>
|
|
|
|
|
</a>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<cosy-tooltip id="left-aside-button" placement="right">
|
|
|
|
|
<span slot="content">
|
|
|
|
|
<span>显示 / 隐藏 左侧导航</span>
|
|
|
|
|
<cosy-short-key>[</cosy-short-key>
|
|
|
|
|
</span>
|
|
|
|
|
<cosy-icon>
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20">
|
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M16 4c1.104-.019 2 .896 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h12zm1 2a1 1 0 0 0-1-1h-2.995v10H16a1 1 0 0 0 1-1V6zm-4.995 9V5H4.001a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8.004z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
|
|
|
|
</cosy-icon>
|
|
|
|
|
</cosy-tooltip>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<script src="/js/e0a67917.js"></script>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<cosy-search id="post-search" placeholder="搜索">
|
|
|
|
|
<div slot="short-key">
|
|
|
|
|
<cosy-short-key>⌘</cosy-short-key>
|
|
|
|
|
<cosy-short-key>K</cosy-short-key>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</div>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</cosy-search>
|
|
|
|
|
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
window.algolia = {
|
|
|
|
|
appId: "5DTW808BZ8",
|
|
|
|
|
SearchOnlyAPIKey: "27845b245efc8a2853cc0bdc7366ea26"
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<script src="/js/62d6af47.js"></script>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="aside-category">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<link rel="stylesheet" href="/css/db04a759.css">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<nav class="category-nav cosy-scrollbar">
|
|
|
|
|
<ul><li data-path="archives">
|
2023-11-10 13:44:10 +08:00
|
|
|
|
<a href="/archives">
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20"><g fill="none"><path d="M3.5 3A1.5 1.5 0 0 0 2 4.5v4A1.5 1.5 0 0 0 3.5 10h9A1.5 1.5 0 0 0 14 8.5v-4A1.5 1.5 0 0 0 12.5 3h-9zM3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5v-4zm.5 6.5A1.5 1.5 0 0 0 2 12.5v4A1.5 1.5 0 0 0 3.5 18h9a1.5 1.5 0 0 0 1.5-1.5v-4a1.5 1.5 0 0 0-1.5-1.5h-9zM3 12.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5v-4zm14-.063a2.003 2.003 0 0 1-2.5-1.937A2 2 0 0 1 16 8.563a2.005 2.005 0 0 1 1 0a2 2 0 0 1 0 3.874zM16.5 3a.5.5 0 0 1 .5.5v4.041a3.02 3.02 0 0 0-1 0V3.5a.5.5 0 0 1 .5-.5zm0 10.5c-.17 0-.337-.014-.5-.041V17.5a.5.5 0 0 0 1 0v-4.041c-.163.027-.33.041-.5.041z" fill="currentColor"></path></g></svg>
|
|
|
|
|
<div class="ellipsis">归档</div>
|
|
|
|
|
</a>
|
|
|
|
|
</li><li data-path="cosy-roadmap">
|
|
|
|
|
<a href="/cosy-roadmap">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20"><g fill="none"><path d="M9.384 2a1 1 0 0 0-.966.742L4.616 17H2.5a.5.5 0 0 0 0 1h15a.5.5 0 0 0 0-1h-2.116L11.582 2.742A1 1 0 0 0 10.616 2H9.384zM5.651 17l.8-3H11.5a.5.5 0 0 0 0-1H6.717l.534-2H10.5a.5.5 0 0 0 0-1H7.517l1.867-7h1.232l3.733 14H5.651z" fill="currentColor"></path></g></svg>
|
|
|
|
|
<div class="ellipsis">路线图</div>
|
|
|
|
|
</a>
|
|
|
|
|
</li><li data-path="cosy-resume">
|
|
|
|
|
<a href="/cosy-resume">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20"><g fill="none"><path d="M8.5 4.498a1.5 1.5 0 1 1 3 0a1.5 1.5 0 0 1-3 0zm1.5-2.5a2.5 2.5 0 0 0-2.43 3.086L5.471 4.15a1.761 1.761 0 0 0-2.317.88c-.4.882-.008 1.917.877 2.31L7 8.662v2.287l-1.877 4.645a1.75 1.75 0 0 0 3.245 1.311l1.556-3.849a.073.073 0 0 1 .028-.038a.086.086 0 0 1 .046-.012c.02 0 .035.005.046.012a.074.074 0 0 1 .028.038l1.555 3.849a1.75 1.75 0 0 0 3.245-1.311L13 10.96V8.662l2.968-1.322a1.74 1.74 0 0 0 .877-2.31a1.761 1.761 0 0 0-2.317-.88l-2.097.934a2.5 2.5 0 0 0-2.43-3.086zM4.065 5.444a.761.761 0 0 1 1-.38l3.918 1.744a2.5 2.5 0 0 0 2.034 0l3.918-1.744a.761.761 0 0 1 1 .38a.739.739 0 0 1-.373.983l-2.969 1.321a1 1 0 0 0-.593.914v2.298a1 1 0 0 0 .073.375l1.872 4.633a.75.75 0 0 1-1.39.562l-1.556-3.849c-.364-.9-1.639-.9-2.003 0l-1.555 3.85a.75.75 0 1 1-1.39-.562l1.876-4.646A1 1 0 0 0 8 10.95V8.662a1 1 0 0 0-.593-.914L4.438 6.427a.739.739 0 0 1-.373-.983z" fill="currentColor"></path></g></svg>
|
|
|
|
|
<div class="ellipsis">简历</div>
|
|
|
|
|
</a>
|
2023-11-10 13:44:10 +08:00
|
|
|
|
</li></ul>
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<ul><li class="active">
|
|
|
|
|
<a href="/categories/CS/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 4l-2 14.5l-6 2l-6-2L4 4z"></path><path d="M7.5 8h3v8l-2-1"></path><path d="M16.5 8H14a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.423a.5.5 0 0 1 .495.57L15.5 15.5l-2 .5"></path></g></svg>
|
2023-11-10 13:51:34 +08:00
|
|
|
|
<div class="ellipsis">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<span>CS</span>
|
2023-11-10 13:51:34 +08:00
|
|
|
|
</div>
|
2023-11-10 13:44:10 +08:00
|
|
|
|
</a>
|
|
|
|
|
</li><li class="">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<a href="/categories/EQ/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5.636 5.636a9 9 0 0 1 13.397.747L13.414 12l5.619 5.617A9 9 0 1 1 5.636 5.636z"></path><circle cx="11.5" cy="7.5" r="1" fill="currentColor"></circle></g></svg>
|
2023-11-10 13:51:34 +08:00
|
|
|
|
<div class="ellipsis">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<span>EQ</span>
|
2023-11-10 13:51:34 +08:00
|
|
|
|
</div>
|
2023-11-10 13:44:10 +08:00
|
|
|
|
</a>
|
|
|
|
|
</li><li class="">
|
|
|
|
|
<a href="/categories/Hexo/">
|
2023-11-10 13:51:34 +08:00
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"></path><path d="M8 16h8"></path><path d="M8.322 12.582l7.956.836"></path><path d="M8.787 9.168l7.826 1.664"></path><path d="M10.096 5.764l7.608 2.472"></path></g></svg>
|
|
|
|
|
<div class="ellipsis">
|
|
|
|
|
<span>Hexo</span>
|
|
|
|
|
</div>
|
2023-11-10 13:44:10 +08:00
|
|
|
|
</a>
|
2023-11-21 13:49:17 +08:00
|
|
|
|
</li><li class="">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<a href="/categories/%E8%87%AA%E5%AA%92%E4%BD%93/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M9 12a4 4 0 1 0 4 4V4a5 5 0 0 0 5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
|
2023-11-21 13:49:17 +08:00
|
|
|
|
<div class="ellipsis">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<span>自媒体</span>
|
2023-11-21 13:49:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
</a>
|
2023-11-11 18:48:29 +08:00
|
|
|
|
</li><li class="">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<a href="/categories/%E8%AF%BB%E4%B9%A6/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20"><g fill="none"><path d="M4 16V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v11a1 1 0 0 1-1 1H5a1 1 0 0 0 1 1h9.5a.5.5 0 0 1 0 1H6a2 2 0 0 1-2-2zM15 4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v11h10V4zM7.041 8h.973c.045-.773.192-1.485.42-2.059A3.002 3.002 0 0 0 7.04 8zM6 8.5a4 4 0 1 1 8 0a4 4 0 0 1-8 0zm6.959-.5a3.002 3.002 0 0 0-1.392-2.059c.227.574.374 1.286.419 2.059h.973zm-.973 1c-.045.773-.192 1.486-.42 2.059A3.002 3.002 0 0 0 12.96 9h-.973zm-1.002-1c-.046-.707-.189-1.324-.383-1.778c-.12-.28-.25-.474-.368-.591c-.117-.115-.195-.131-.233-.131c-.038 0-.116.016-.233.13c-.118.118-.248.312-.368.592c-.194.454-.337 1.07-.383 1.778h1.968zM9.016 9c.046.707.189 1.324.383 1.778c.12.28.25.474.368.591c.117.115.195.131.233.131c.038 0 .116-.016.233-.13c.118-.118.248-.313.368-.592c.194-.454.336-1.07.383-1.778H9.016zM8.014 9h-.973c.147.87.668 1.614 1.392 2.059c-.227-.573-.374-1.286-.419-2.059z" fill="currentColor"></path></g></svg>
|
2023-11-11 18:48:29 +08:00
|
|
|
|
<div class="ellipsis">
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<span>读书</span>
|
|
|
|
|
</div>
|
|
|
|
|
</a>
|
|
|
|
|
</li><li class="">
|
|
|
|
|
<a href="/categories/%E8%B4%A2%E7%BB%8F/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"></circle><path d="M14.8 9A2 2 0 0 0 13 8h-2a2 2 0 0 0 0 4h2a2 2 0 0 1 0 4h-2a2 2 0 0 1-1.8-1"></path><path d="M12 6v2m0 8v2"></path></g></svg>
|
|
|
|
|
<div class="ellipsis">
|
|
|
|
|
<span>财经</span>
|
2023-11-11 18:48:29 +08:00
|
|
|
|
</div>
|
|
|
|
|
</a>
|
2023-11-10 13:44:10 +08:00
|
|
|
|
</li></ul>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</nav>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<script src="/js/da8f6845.js"></script>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="bottom">
|
|
|
|
|
<cosy-tooltip id="button-preference" placement="right">
|
|
|
|
|
<span slot="content">
|
|
|
|
|
<span>偏好</span>
|
|
|
|
|
<cosy-short-key>⌘</cosy-short-key>
|
|
|
|
|
<cosy-short-key>p</cosy-short-key>
|
|
|
|
|
</span>
|
|
|
|
|
<cosy-icon bordered id="button-about-cosy-theme">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16">
|
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M8 6a2 2 0 1 0 0 4a2 2 0 0 0 0-4zM7 8a1 1 0 1 1 2 0a1 1 0 0 1-2 0zm3.618-3.602a.708.708 0 0 1-.824-.567l-.26-1.416a.354.354 0 0 0-.275-.282a6.072 6.072 0 0 0-2.519 0a.354.354 0 0 0-.275.282l-.259 1.416a.71.71 0 0 1-.936.538l-1.359-.484a.355.355 0 0 0-.382.095c-.569.627-1 1.367-1.262 2.173a.352.352 0 0 0 .108.378l1.102.931a.704.704 0 0 1 0 1.076l-1.102.931a.352.352 0 0 0-.108.378A5.986 5.986 0 0 0 3.53 12.02a.355.355 0 0 0 .382.095l1.36-.484a.708.708 0 0 1 .936.538l.258 1.416c.026.14.135.252.275.281a6.075 6.075 0 0 0 2.52 0a.353.353 0 0 0 .274-.281l.26-1.416a.71.71 0 0 1 .936-.538l1.359.484c.135.048.286.01.382-.095c.569-.627 1-1.367 1.262-2.173a.352.352 0 0 0-.108-.378l-1.102-.931a.703.703 0 0 1 0-1.076l1.102-.931a.352.352 0 0 0 .108-.378A5.985 5.985 0 0 0 12.47 3.98a.355.355 0 0 0-.382-.095l-1.36.484a.71.71 0 0 1-.111.03zm-6.62.58l.937.333a1.71 1.71 0 0 0 2.255-1.3l.177-.97a5.105 5.105 0 0 1 1.265 0l.178.97a1.708 1.708 0 0 0 2.255 1.3L12 4.977c.255.334.467.698.63 1.084l-.754.637a1.704 1.704 0 0 0 0 2.604l.755.637a4.99 4.99 0 0 1-.63 1.084l-.937-.334a1.71 1.71 0 0 0-2.255 1.3l-.178.97a5.099 5.099 0 0 1-1.265 0l-.177-.97a1.708 1.708 0 0 0-2.255-1.3L4 11.023a4.987 4.987 0 0 1-.63-1.084l.754-.638a1.704 1.704 0 0 0 0-2.603l-.755-.637c.164-.386.376-.75.63-1.084z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
|
|
|
|
</cosy-icon>
|
|
|
|
|
</cosy-tooltip>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
<main>
|
|
|
|
|
|
2023-12-26 10:56:25 +08:00
|
|
|
|
<link rel="stylesheet" href="/css/9bb9a539.css">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="post-container">
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<header>
|
|
|
|
|
<div class="left">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<link rel="stylesheet" href="/css/7d333f9e.css">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
<nav class="breadcrumb">
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<section>
|
|
|
|
|
<cosy-tooltip placement="bottom-left">
|
|
|
|
|
<span slot="content"><span>首页</span>
|
|
|
|
|
<cosy-short-key>⌘</cosy-short-key>
|
|
|
|
|
<cosy-short-key>H</cosy-short-key>
|
|
|
|
|
</span>
|
|
|
|
|
<cosy-icon href="/">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20">
|
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M8.998 2.388a1.5 1.5 0 0 1 2.005 0l5.5 4.942A1.5 1.5 0 0 1 17 8.445V15.5a1.5 1.5 0 0 1-1.5 1.5H13a1.5 1.5 0 0 1-1.5-1.5V12a.5.5 0 0 0-.5-.5H9a.5.5 0 0 0-.5.5v3.5A1.5 1.5 0 0 1 7 17H4.5A1.5 1.5 0 0 1 3 15.5V8.445c0-.425.18-.83.498-1.115l5.5-4.942zm1.336.744a.5.5 0 0 0-.668 0l-5.5 4.942A.5.5 0 0 0 4 8.445V15.5a.5.5 0 0 0 .5.5H7a.5.5 0 0 0 .5-.5V12A1.5 1.5 0 0 1 9 10.5h2a1.5 1.5 0 0 1 1.5 1.5v3.5a.5.5 0 0 0 .5.5h2.5a.5.5 0 0 0 .5-.5V8.445a.5.5 0 0 0-.166-.371l-5.5-4.942z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
|
|
|
|
</cosy-icon>
|
|
|
|
|
</cosy-tooltip>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<svg class="arrow" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M7.733 4.207a.75.75 0 0 1 1.06.026l5.001 5.25a.75.75 0 0 1 0 1.035l-5 5.25a.75.75 0 1 1-1.087-1.034L12.216 10l-4.51-4.734a.75.75 0 0 1 .027-1.06z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
2023-12-26 10:59:02 +08:00
|
|
|
|
<a class="ellipsis" href="/categories/CS/">
|
|
|
|
|
CS
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<svg class="arrow" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M7.733 4.207a.75.75 0 0 1 1.06.026l5.001 5.25a.75.75 0 0 1 0 1.035l-5 5.25a.75.75 0 1 1-1.087-1.034L12.216 10l-4.51-4.734a.75.75 0 0 1 .027-1.06z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<span class="ellipsis">
|
|
|
|
|
领域驱动设计
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</section>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="/js/31d6cfe0.js"></script>
|
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="right">
|
|
|
|
|
|
|
|
|
|
<cosy-tooltip id="toc-show-button" placement="left">
|
|
|
|
|
<span slot="content">
|
|
|
|
|
<span>显示 / 隐藏 文章目录</span>
|
|
|
|
|
<cosy-short-key>]</cosy-short-key>
|
|
|
|
|
</span>
|
|
|
|
|
<cosy-icon>
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20">
|
|
|
|
|
<g fill="none">
|
|
|
|
|
<path d="M4 4c-1.104-.019-2 .896-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4zM3 6a1 1 0 0 1 1-1h2.995v10H4a1 1 0 0 1-1-1V6zm4.995 9V5h8.004a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H7.995z" fill="currentColor"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
|
|
|
|
</cosy-icon>
|
|
|
|
|
</cosy-tooltip>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<main class="cosy-scrollbar">
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<div class="article-container">
|
|
|
|
|
<!-- 渲染文章内容 -->
|
2023-11-08 13:45:34 +08:00
|
|
|
|
<article>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<!-- 文章标题 -->
|
|
|
|
|
<h1 class="post-title">领域驱动设计</h1>
|
|
|
|
|
<div class="last-updated">
|
2024-03-15 23:26:32 +08:00
|
|
|
|
上次更新: 2024-03-15 23:14:48
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
<!-- 文章 -->
|
2023-11-08 13:45:34 +08:00
|
|
|
|
<h1 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h1><ul>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<li><a target="_blank" rel="noopener" href="https://juejin.cn/post/6844903618680881165">蚂蚁金服数据体验技术团队 - 领域驱动设计</a></li>
|
|
|
|
|
<li><a target="_blank" rel="noopener" href="https://tech.meituan.com/2017/12/22/ddd-in-practice.html">美团 - 领域驱动设计在互联网业务开发中的实践</a></li>
|
|
|
|
|
<li><a target="_blank" rel="noopener" href="https://huhao.dev/posts/61190ae2/#%E9%97%AE%E9%A2%98%E5%AD%90%E5%9F%9F%E8%AF%86%E5%88%AB">领域驱动实战思考</a></li>
|
|
|
|
|
<li><a target="_blank" rel="noopener" href="https://www.tangshuang.net/8663.html">基于 DDD 的前端项目架构设计与实战</a></li>
|
|
|
|
|
<li><a target="_blank" rel="noopener" href="https://www.tangshuang.net/8212.html">React 语境下前端 DDD 的思考</a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
<h1 id="架构对比"><a href="#架构对比" class="headerlink" title="架构对比"></a>架构对比</h1><p>从后端视角看,对比传统的三层架构,领域驱动</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>充血</code>复用了:领域对外的接口</li>
|
|
|
|
|
<li><code>领域服务</code>封装了:领域之间的联系</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<p>贫血模型->充血模型,降低了<code>service层</code>的负担,同时保证了业务迭代,<code>entity</code>的独立性</p>
|
|
|
|
|
<h2 id="MVC"><a href="#MVC" class="headerlink" title="MVC"></a>MVC</h2><p>从数据库视角、分析实体出发,进行系统的构建</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>DAO 层</li>
|
|
|
|
|
<li>Service 层</li>
|
|
|
|
|
<li>Controller 层</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<h2 id="后端-DDD"><a href="#后端-DDD" class="headerlink" title="后端 DDD"></a>后端 DDD</h2><blockquote>
|
|
|
|
|
<p>针对基础设施层,也可以考虑加入<code>防腐层</code>、<code>工厂</code></p>
|
|
|
|
|
</blockquote>
|
|
|
|
|
<p>一个领域基本四层架构</p>
|
|
|
|
|
<ol>
|
|
|
|
|
<li>用户层(user interface): 对标 controller,对外提供 web 服务、接口</li>
|
|
|
|
|
<li>应用层(application): 业务层,定义领域可以解决的问题 <code>domainService</code></li>
|
|
|
|
|
<li>领域层(domain): 纯粹的描述业务实体</li>
|
|
|
|
|
<li>基础设施层(infra): 持久化层(Builder+repository)</li>
|
|
|
|
|
</ol>
|
|
|
|
|
<p>同时,领域拆分带来如下两个致命问题</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>领域化(微服务)后,数据库是分开的,导致实体调用链复杂,避免跨库查询</li>
|
|
|
|
|
<li>避免分布式事务同步</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<h2 id="前端-DDD"><a href="#前端-DDD" class="headerlink" title="前端 DDD"></a>前端 DDD</h2><blockquote>
|
|
|
|
|
<p>?? 这里存在一个问题,api 网关到底要不要挪到前端领域目录下来开发</p>
|
|
|
|
|
</blockquote>
|
|
|
|
|
<ol>
|
|
|
|
|
<li>用户层: web、mobile、mini-program …多端</li>
|
|
|
|
|
<li>service: 暴露给 UI 组件的 <code>domainSerivce</code>,组织实体的状态流转</li>
|
|
|
|
|
<li>entity: 实体、聚合实体、事件</li>
|
|
|
|
|
<li>infra: api 请求、缓存、工具</li>
|
|
|
|
|
</ol>
|
2024-01-04 23:11:27 +08:00
|
|
|
|
<h2 id="工厂-Factory-Builder"><a href="#工厂-Factory-Builder" class="headerlink" title="工厂 Factory / Builder"></a>工厂 Factory / Builder</h2><ul>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<li>数据库表设计层面,如果要<code>多对多</code>的关系,只能很别扭的设计一个中间表。</li>
|
|
|
|
|
<li>实体 A 适合 <code>mongo</code>文档形存储,实体 B 适合<code>mysql</code>关系型存储。对于 <code>Builder</code> 而言,直接在这个领域搓出来 <code>A 和 B</code> 的 <code>CRUD</code>的实现方法</li>
|
|
|
|
|
</ul>
|
2024-01-04 23:11:27 +08:00
|
|
|
|
<h2 id="防腐层-Facade-Adaptor"><a href="#防腐层-Facade-Adaptor" class="headerlink" title="防腐层 Facade / Adaptor"></a>防腐层 Facade / Adaptor</h2><p>也被成为适配器,隔离第三方/外部服务,例如场景,用户上传文件到阿里云、腾讯云</p>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token keyword">class</span> <span class="token class-name">UserUploadServiceFacade</span> <span class="token keyword">extends</span> <span class="token class-name">UserService</span> <span class="token punctuation">{</span>
|
|
|
|
|
<span class="token comment">/**
|
|
|
|
|
* 上传
|
|
|
|
|
*/</span>
|
|
|
|
|
<span class="token keyword">async</span> <span class="token function">upload</span><span class="token punctuation">(</span><span class="token parameter">oss</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token punctuation">(</span>oss <span class="token operator">===</span> <span class="token string">"ali"</span><span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token string">"OK"</span><span class="token punctuation">;</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token punctuation">(</span>oss <span class="token operator">===</span> <span class="token string">"tx"</span><span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token string">"FAIL"</span><span class="token punctuation">;</span>
|
|
|
|
|
<span class="token punctuation">}</span>
|
|
|
|
|
<span class="token punctuation">}</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
|
|
|
|
|
|
|
|
|
|
<h1 id="领域模型"><a href="#领域模型" class="headerlink" title="领域模型"></a>领域模型</h1><p>实体的<code>贫血->充血</code>是一个随着业务发展过程演变的结果,初期业务场景不明确,很难充血,瞎几把充血,纯属找难受。</p>
|
|
|
|
|
<p>是否需要引入<code>聚合根(aggregate root)</code>的概念,解决领域内实体独立、平铺关系带来的不方便,这个可能比较看心情</p>
|
|
|
|
|
<h2 id="贫血模型-POJO-的问题"><a href="#贫血模型-POJO-的问题" class="headerlink" title="贫血模型(POJO)的问题"></a>贫血模型(POJO)的问题</h2><blockquote>
|
|
|
|
|
<p>脱离了业务复杂度谈分层,好比抛开剂量谈毒性</p>
|
|
|
|
|
</blockquote>
|
|
|
|
|
<p>领域对象里只有<code>get/set</code>方法,所有的业务逻辑都不包含在内,从而造成<code>失忆症</code>,从实体中,无法知道发生了那些业务,需要去 <code>service层</code> 里挨个梳理,一旦业务迭代、<code>service 层</code>直接开始变成屎山</p>
|
2024-01-04 23:11:27 +08:00
|
|
|
|
<h2 id="充血模型-领域服务的关系"><a href="#充血模型-领域服务的关系" class="headerlink" title="充血模型 && 领域服务的关系"></a>充血模型 && 领域服务的关系</h2><blockquote>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<p>确保领域之间独立的,随着不断的充血,保证领域(实体)是独立发展的</p>
|
|
|
|
|
</blockquote>
|
|
|
|
|
<p>假定两个 domain(实体):</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>学生: 上课、做作业</li>
|
|
|
|
|
<li>老师、全体起立、布置作业</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<p>假定<code>老师</code>调用<code>全体起立</code>,对应肯定要<code>学生</code>调用<code>上课</code>,这个就是 <code>领域服务(domainService)</code> 需要去处理的,他俩不能建立直接的联系。</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>增加新的业务逻辑:在 <code>domainService</code> 增加新的方法。</li>
|
|
|
|
|
<li>调整旧的业务逻辑:修改<code>学生</code>,<code>老师</code>,内部具体的方法,<code>domainService</code> 完全不需要变化。</li>
|
|
|
|
|
</ul>
|
2023-11-08 13:45:34 +08:00
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<div class="post-tags">
|
|
|
|
|
<!-- 文章tags -->
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<p class="motto">重拾纯粹的写作</p>
|
2023-11-08 13:45:34 +08:00
|
|
|
|
</article>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<!-- 评论 -->
|
|
|
|
|
<div id="vcomments"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</main>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<!-- toc -->
|
|
|
|
|
|
|
|
|
|
<cosy-drag-box id="toc-drag-box" trigger="left" min-width="220" uid="toc-box">
|
|
|
|
|
<div class="meta-container">
|
|
|
|
|
<div class="toc-wrapper cosy-scrollbar">
|
2023-12-26 10:56:25 +08:00
|
|
|
|
<p class="catalog">
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
|
|
|
|
|
<g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
|
|
|
<path d="M4 6h16"></path>
|
|
|
|
|
<path d="M4 12h16"></path>
|
|
|
|
|
<path d="M4 18h12"></path>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
|
|
|
|
<span>目录</span>
|
|
|
|
|
</p>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
<!-- 文章toc -->
|
2024-01-04 23:11:27 +08:00
|
|
|
|
<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE"><span class="toc-number">1.</span> <span class="toc-text">参考文献</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%9E%B6%E6%9E%84%E5%AF%B9%E6%AF%94"><span class="toc-number">2.</span> <span class="toc-text">架构对比</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#MVC"><span class="toc-number">2.1.</span> <span class="toc-text">MVC</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%8E%E7%AB%AF-DDD"><span class="toc-number">2.2.</span> <span class="toc-text">后端 DDD</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF-DDD"><span class="toc-number">2.3.</span> <span class="toc-text">前端 DDD</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B7%A5%E5%8E%82-Factory-Builder"><span class="toc-number">2.4.</span> <span class="toc-text">工厂 Factory / Builder</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%98%B2%E8%85%90%E5%B1%82-Facade-Adaptor"><span class="toc-number">2.5.</span> <span class="toc-text">防腐层 Facade / Adaptor</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%A2%86%E5%9F%9F%E6%A8%A1%E5%9E%8B"><span class="toc-number">3.</span> <span class="toc-text">领域模型</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B4%AB%E8%A1%80%E6%A8%A1%E5%9E%8B-POJO-%E7%9A%84%E9%97%AE%E9%A2%98"><span class="toc-number">3.1.</span> <span class="toc-text">贫血模型(POJO)的问题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%85%E8%A1%80%E6%A8%A1%E5%9E%8B-%E9%A2%86%E5%9F%9F%E6%9C%8D%E5%8A%A1%E7%9A%84%E5%85%B3%E7%B3%BB"><span class="toc-number">3.2.</span> <span class="toc-text">充血模型 && 领域服务的关系</span></a></li></ol></li></ol>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</cosy-drag-box>
|
|
|
|
|
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</div>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
|
2023-11-06 16:05:27 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-11-08 10:11:56 +08:00
|
|
|
|
window.page = {
|
|
|
|
|
use: ''
|
|
|
|
|
}
|
2023-11-06 16:05:27 +08:00
|
|
|
|
window.katex = {
|
2023-11-08 10:11:56 +08:00
|
|
|
|
enable: "",
|
2023-11-06 16:05:27 +08:00
|
|
|
|
jsCdn: "//cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.js",
|
|
|
|
|
cssCdn: "//cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css"
|
|
|
|
|
}
|
|
|
|
|
window.mermaid = {
|
2023-11-08 10:11:56 +08:00
|
|
|
|
enable: "",
|
2023-11-15 10:21:41 +08:00
|
|
|
|
theme: "",
|
2023-11-06 16:05:27 +08:00
|
|
|
|
cdn: "//cdn.jsdelivr.net/npm/mermaid@10.4.0/dist/mermaid.min.js",
|
|
|
|
|
}
|
|
|
|
|
window.valine = {
|
2023-11-08 10:11:56 +08:00
|
|
|
|
enable: "",
|
2023-11-06 16:05:27 +08:00
|
|
|
|
appId: 'TisMit6uhflounFqAN3ZGjgq-MdYXbMMI',
|
|
|
|
|
appKey: 'CdjirjYdz07U5i62ElsJvXUh',
|
|
|
|
|
avatar: 'monsterid',
|
|
|
|
|
cdn: '//unpkg.com/valine@latest/dist/Valine.min.js',
|
|
|
|
|
serverURLs: '//tismit6u.api.lncldglobal.com'
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<script src="/js/5bf38c1b.js"></script>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
</main>
|
|
|
|
|
</body>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
|
2023-11-06 16:05:27 +08:00
|
|
|
|
<script>
|
2023-12-25 16:39:03 +08:00
|
|
|
|
window.theme = {
|
|
|
|
|
color: 'hsl(238,50%,56%)'
|
2023-11-06 16:05:27 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-12-25 16:39:03 +08:00
|
|
|
|
|
2023-12-28 11:27:53 +08:00
|
|
|
|
<script src="/js/82a967e8.js"></script>
|
2023-11-06 16:05:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</html>
|