{"id":411031,"date":"2024-06-29T21:43:53","date_gmt":"2024-06-29T21:43:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=411031"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=411031","title":{"rendered":"<span>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c DDD \u0432 Go<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aea\/046\/d60\/aea046d60beca170d1766a15608fb26f.png\" alt=\"Image by Percy Bolm\u00e9r. Gopher by Takuya Ueda, Original Go Gopher by Ren\u00e9e French (CC BY 3.0)\" title=\"Image by Percy Bolm\u00e9r. Gopher by Takuya Ueda, Original Go Gopher by Ren\u00e9e French (CC BY 3.0)\" width=\"2000\" height=\"1413\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aea\/046\/d60\/aea046d60beca170d1766a15608fb26f.png\"\/><figcaption>Image by Percy Bolm\u00e9r. Gopher by Takuya Ueda, Original Go Gopher by Ren\u00e9e French (CC BY 3.0)<\/figcaption><\/figure>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0438 \u0433\u0438\u0431\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0431\u0435\u0441\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u0442\u043e \u0441\u043a\u043e\u0440\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0441\u044f \u0441 \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043d\u0435\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e. \u0418\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 DDD (Domain-Driven Design, \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435). \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u043b \u043f\u0440\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0430\u0442\u044b\u043a\u0430\u044e\u0441\u044c \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<blockquote>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/towardsdatascience.com\/how-to-implement-domain-driven-design-ddd-in-golang-2e2139beb09d\">&#171;How to Implement Domain-Driven Design (DDD) in Golang&#187;<\/a>. \u041f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0443 \u0432\u0435\u0441\u0442\u0438 \u043e\u0442 \u043b\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0430, \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u044b\u0441\u043b\u044f\u043c\u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043a\u0430\u043a \u0438 \u044d\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<hr\/>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441 \u043d\u0443\u043b\u044f \u043e\u043d\u043b\u0430\u0439\u043d-\u0442\u0430\u0432\u0435\u0440\u043d\u0443, \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 DDD. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u0447\u0438\u0442\u0430\u044e \u043f\u0440\u043e DDD, \u043c\u043e\u044f \u0433\u043e\u043b\u043e\u0432\u0430 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043e \u0447\u0451\u043c \u044f, \u0442\u043e \u044d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u043e\u044e \u0431\u043e\u043b\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8b9\/eaa\/298\/8b9eaa298a7c1f0418c1f330d82d9f4f.png\" alt=\"Keywords in DDD \u2014 Graph from Eric Evans book Domain-Driven Design: Tackling Complexity in the Heart of Software\" title=\"Keywords in DDD \u2014 Graph from Eric Evans book Domain-Driven Design: Tackling Complexity in the Heart of Software\" width=\"1003\" height=\"900\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b9\/eaa\/298\/8b9eaa298a7c1f0418c1f330d82d9f4f.png\"\/><figcaption>Keywords in DDD \u2014 Graph from Eric Evans book Domain-Driven Design: Tackling Complexity in the Heart of Software<\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043c\u043e\u0451 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e DDD, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430\u0436\u0443, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u0445, \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0441\u0435\u0431\u044f \u0432 Go-\u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b; \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0439 best practice. \u0411\u0443\u0434\u0443 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043f\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 DDD. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0451\u043b \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043d\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435 \u0443\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f. \u0428\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0431\u043e\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e: \u0442\u0430\u043c \u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u043c \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u042f \u043d\u0435 \u0440\u0430\u0437 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b \u0433\u043e\u0440\u044f\u0447\u0438\u0435 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043e DDD \u0438 \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0418 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043e\u0431\u0440\u0430\u0449\u0430\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u044e\u0434\u0438 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0446\u0435\u043b\u044c DDD \u0438 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u043f\u043e\u0440\u0430\u0445 \u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u042d\u0432\u0430\u043d\u0441\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438, \u0430 \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u044b \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435.<\/p>\n<p>DDD \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041d\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 DDD<\/h2>\n<p>Domain-Driven Design \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (\u0434\u043e\u043c\u0435\u043d\u0430, domain), \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u041f\u041e. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u0415\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u043b\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e DDD, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430\u043c\u0438 \u0432 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (Subject Matter Experts, SME). \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 \u043b\u044e\u0434\u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0437\u043d\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0430\u043a\u0446\u0438\u044f\u043c\u0438, \u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0444\u043e\u043d\u0434\u043e\u0432\u043e\u043c \u0440\u044b\u043d\u043a\u0435 \u0438\u0437 \u0443\u0441\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u043d\u0451\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00a0\u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439.<\/p>\n<h3>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0433\u043e\u0444\u0435\u0440\u0430 \u0432 DDD<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0433\u043e\u0444\u0435\u0440\u0430 \u0414\u0430\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0432\u0435\u0440\u043d\u0443. \u0414\u0430\u043d\u0442\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439. \u0412 \u0442\u043e\u0442 \u0434\u0435\u043d\u044c, \u043a\u043e\u0433\u0434\u0430 \u0414\u0430\u043d\u0442\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u0443 \u043d\u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041e\u043d \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u0443, \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u044f \u0441\u0432\u043e\u0438 \u043f\u043b\u0430\u043d\u044b. \u041f\u043e\u043a\u0430 \u0414\u0430\u043d\u0442\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u0441\u0432\u0435\u0442\u043e\u0444\u043e\u0440\u0435, \u043a \u043d\u0435\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0448\u043b\u044f\u043f\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442: \u00ab<em>\u041f\u043e\u0445\u043e\u0436\u0435, \u0432\u044b \u0447\u0435\u043c-\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0435\u043d\u044b, \u043c\u043e\u043b\u043e\u0434\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0442\u0430\u0432\u0435\u0440\u043d\u044b?<\/em>\u00bb.<\/p>\n<p>\u0414\u0430\u043d\u0442\u0435 \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0448\u043b\u044f\u043f\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0433\u0443\u043b\u044f\u043b\u0438 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439. \u0414\u0430\u043d\u0442\u0435 \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0443 \u043b\u044e\u0434\u0435\u0439 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0432\u044b\u043f\u0438\u0432\u043e\u0445\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u00ab\u0448\u043b\u044f\u043f\u0430\u00bb \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c\u0438, \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 \u0438 \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u043c\u0438.<\/p>\n<h3>\u0414\u043e\u043c\u0435\u043d, \u043c\u043e\u0434\u0435\u043b\u044c, \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0438 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u044b<\/h3>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u043e \u0414\u0430\u043d\u0442\u0435, \u0432\u0435\u0434\u044c \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a. \u041e\u043d\u0430 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u0442 \u043d\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0449\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f.<\/p>\n<p>\u0413\u0435\u0440\u043e\u0438 \u043d\u0430\u0448\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u0441\u0435\u0441\u0441\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438: \u00ab\u0448\u043b\u044f\u043f\u0430\u00bb \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430, \u0430 \u0414\u0430\u043d\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u0431\u0435\u0441\u0435\u0434\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043d\u0430\u0434 \u0442\u0435\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0434\u043e\u043c\u0435\u043d\u043e\u043c (Core\/Root domain) \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0432\u0435\u0440\u043d\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0428\u043b\u044f\u043f\u0430 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u0438 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u0445; \u0442\u0430\u043a \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a (ubiquitous language), \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u0431\u0438\u0432\u0430\u043b\u043e \u0431\u044b \u0441 \u0442\u043e\u043b\u043a\u0443, \u0430 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u2014 \u0432\u0430\u0436\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u0442\u0430\u0432\u0435\u0440\u043d\u0443. \u041f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u00ab\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f\u00bb \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<h2>\u041a\u043e\u0434 DDD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Go<\/h2>\n<h3>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u041f\u043e\u0440\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">mkdir ddd-go go mod init github.com\/percybolmer\/ddd-go<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>domain<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u044b. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0434\u043e\u043c\u0435\u043d\u043e\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0430\u043f\u043a\u0430. \u0412 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0451 <code>entity<\/code> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0442\u0443\u0434\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (entity) \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/026\/d1b\/b27\/026d1bb27dcc0ec3d9132fa4564f2cb7.png\" width=\"336\" height=\"82\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/026\/d1b\/b27\/026d1bb27dcc0ec3d9132fa4564f2cb7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438: <code>Person<\/code> \u0438 <code>Item<\/code>. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u043a\u043e\u0434\u0430 \u044f \u0434\u0435\u043b\u0430\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u0433\u043a\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0421\u0435\u0439\u0447\u0430\u0441 \u0442\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u043d\u043e \u043f\u043e\u0437\u0436\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438 \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/805\/754\/6f5\/8057546f5b9185241384f937abcb5052.png\" width=\"340\" height=\"114\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/805\/754\/6f5\/8057546f5b9185241384f937abcb5052.png\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"go\">package entity  import \"github.com\/google\/uuid\"  \/\/ Person is a entity that represents a person in all Domains type Person struct { \/\/ ID is the identifier of the Entity, the ID is shared for all sub domains ID uuid.UUID Name string Age int }<\/code><\/pre>\n<pre><code class=\"go\">package entity  import \"github.com\/google\/uuid\"  \/\/ Item represents a Item for all sub domains type Item struct { ID          uuid.UUID  Name        string     Description string     }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c (Value Objects) \u2014 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u041e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0432 \u043d\u0438\u0445. \u0421\u0435\u0439\u0447\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Transaction<\/code>, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 ID \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c, \u043d\u043e \u0434\u043b\u044f \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<pre><code class=\"go\">package valueobject  import \"time\"  type Transaction struct { \/\/ all values lowercase since they are immutable amount    int from      uuid.UUID to        uuid.UUID createdAt time.Time }<\/code><\/pre>\n<h3>\u0410\u0433\u0440\u0435\u0433\u0430\u0442\u044b: \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0410\u0433\u0440\u0435\u0433\u0430\u0442 (Aggregate) \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 <code>Customer<\/code>. \u0420\u043e\u043b\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u2014 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. \u041e\u043d\u0438 \u043d\u0435 \u0434\u0430\u044e\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Person<\/code>, \u043d\u043e \u0438 <code>Products<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <code>Transactions<\/code>.<\/p>\n<p>\u0423 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 \u0432 DDD \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c (root entity). \u0422\u043e\u0433\u0434\u0430, \u0441\u0441\u044b\u043b\u0430\u044f\u0441\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ID \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Person \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 <code>Customer<\/code>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>aggregate<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0444\u0430\u0439\u043b <code>customer.go<\/code>. \u0422\u0430\u043c \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Customer<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0431\u0443\u043a\u0432\u044b (\u0442\u0430\u043a \u043c\u044b \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044f\u043c \u0432\u043d\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b). \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u043e\u0432 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u0435\u0451 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0443.<\/p>\n<pre><code class=\"go\">package aggregate  import ( \"github.com\/percybolmer\/ddd-go\/entity\" \"github.com\/percybolmer\/ddd-go\/valueobject\" )  \/\/ Customer is a aggregate that combines all entities needed to represent a customer type Customer struct { \/\/ person is the root entity of a customer \/\/ which means the person.ID is the main identifier for this aggregate person *entity.Person  \/\/ a customer can hold many products products []*entity.Item  \/\/ a customer can perform many transactions transactions []valueobject.Transaction  }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0418 \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<h3>\u0424\u0430\u0431\u0440\u0438\u043a\u0438: \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438<\/h3>\n<p>\u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0438 \u043d\u0430\u0447\u043d\u0451\u043c \u043c\u044b \u0441 \u0444\u0430\u0431\u0440\u0438\u043a (factories). \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0434 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<blockquote>\n<p>\u0415\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/w3sdesign.com\/index0100.php\">\u0441\u0430\u0439\u0442-\u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u2014 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 DDD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438 \u0432\u044b, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<p>DDD \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 (\u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043c\u0438 \u0434\u0430\u043b\u0435\u0435). \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 <code>NewCustomer<\/code>. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043a\u0440\u044b\u0442\u043e \u043e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0435\u0451 \u043a\u043e\u0434\u0430 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 <code>domains\/customer<\/code> \u0440\u044f\u0434\u043e\u043c \u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u043e\u0439, \u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"go\">package aggregate  import ( \"errors\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/entity\" \"github.com\/percybolmer\/ddd-go\/valueobject\" )  var ErrInvalidPerson = errors.New(\"a customer has to have an valid person\")  type Customer struct { person *entity.Person products []*entity.Item transactions []valueobject.Transaction }  \/\/ NewCustomer is a factory to create a new Customer aggregate \/\/ It will validate that the name is not empty func NewCustomer(name string) (Customer, error) { if name == \"\" { return Customer{}, ErrInvalidPerson }  \/\/ Create a new person and generate ID person := &amp;entity.Person{ Name: name, ID:   uuid.New(), } \/\/ Create a customer object and initialize all the values to avoid nil pointer exceptions return Customer{ person:       person, products:     make([]*entity.Item, 0), transactions: make([]valueobject.Transaction, 0), }, nil }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0432\u0437\u044f\u043b\u0430 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e ID \u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044e \u0432\u0441\u0435\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u043e\u0433\u0438\u043a\u0430, \u043f\u043e\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b <code>customer_test.go<\/code> \u0432 \u043f\u0430\u043a\u0435\u0442 <code>aggregate<\/code>.<\/p>\n<pre><code class=\"go\">package aggregate_test  import ( \"testing\"  \"github.com\/percybolmer\/ddd-go\/aggregate\" )  func TestCustomer_NewCustomer(t *testing.T) { \/\/ Build our needed testcase data struct type testCase struct { test        string name        string expectedErr error } \/\/ Create new test cases testCases := []testCase{ { test:        \"Empty Name validation\", name:        \"\", expectedErr: aggregate.ErrInvalidPerson, }, { test:        \"Valid Name\", name:        \"Percy Bolmer\", expectedErr: nil, }, }  for _, tc := range testCases { \/\/ Run Tests t.Run(tc.test, func(t *testing.T) { \/\/ Create a new customer _, err := aggregate.NewCustomer(tc.name) \/\/ Check if the error matches the expected error if err != tc.expectedErr { t.Errorf(\"Expected error %v, got %v\", tc.expectedErr, err) }  }) }  }<\/code><\/pre>\n<blockquote>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445.<\/p>\n<\/blockquote>\n<p>\u041d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0442\u0430\u0432\u0435\u0440\u043d\u044b \u043c\u044b \u043d\u0435 \u0443\u0435\u0434\u0435\u043c. \u041f\u043e\u0440\u0430 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d.<\/p>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/h3>\n<p>DDD \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430\u043c\u0438. \u0418\u0437\u0443\u0447\u0438\u0432 \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041e\u043d \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0431\u0435\u0437 \u043e\u043f\u0430\u0441\u0435\u043d\u0438\u044f \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u043d\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0437\u0436\u0435 \u043d\u0430 MongoDB, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0437\u0430\u043c\u0435\u043d\u0435 \u0432\u0435\u043d\u0434\u043e\u0440\u0430, \u043d\u043e \u0438 \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438: \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u043e\u043a\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 <code>repository.go<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 <code>domain\/customer<\/code>. \u0417\u0430\u0432\u0435\u0434\u0451\u043c \u0442\u0430\u043c \u043e\u0431\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<pre><code class=\"go\">\/\/ Package Customer holds all the domain logic for the customer domain. package customer  import ( \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" )  var ( ErrCustomerNotFound = errors.New(\"the customer was not found in the repository\") ErrFailedToAddCustomer = errors.New(\"failed to add the customer to the repository\") ErrUpdateCustomer = errors.New(\"failed to update the customer in the repository\") )  \/\/ CustomerRepository is a interface that defines the rules around what a customer repository type CustomerRepository interface { Get(uuid.UUID) (aggregate.Customer, error) Add(aggregate.Customer) error Update(aggregate.Customer) error }<\/code><\/pre>\n<blockquote>\n<p>\u0421\u0430\u043c \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c: \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u0440\u044f\u0434 \u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c. \u0420\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u0410 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0437\u043c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <code>customer<\/code>, \u0430 \u043d\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0418 \u043d\u0430\u0447\u043d\u0443 \u044f \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0447\u0430\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u043e\u0432\u044b\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043b\u0435\u0433\u0447\u0435 \u0432\u043d\u0438\u043a\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u043c \u2014 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">mkdir memory touch memory\/memory.go<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u043d\u0430\u0434 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>Customer<\/code>-\u0443.<\/p>\n<pre><code class=\"go\">func (c *Customer) GetID() uuid.UUID { return c.person.ID }  func (c *Customer) SetID(id uuid.UUID) { if c.person == nil { c.person = &amp;entity.Person{} } c.person.ID = id }  func (c *Customer) SetName(name string) { if c.person == nil { c.person = &amp;entity.Person{} } c.person.Name = name }  func (c *Customer) GetName() string { return c.person.Name }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043d\u0435\u0451 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430.<\/p>\n<pre><code class=\"go\">\/\/ Package memory is a in-memory implementation of the customer repository package memory  import ( \"fmt\" \"sync\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" \"github.com\/percybolmer\/ddd-go\/domain\/customer\" )  \/\/ MemoryRepository fulfills the CustomerRepository interface type MemoryRepository struct { customers map[uuid.UUID]aggregate.Customer sync.Mutex }  \/\/ New is a factory function to generate a new repository of customers func New() *MemoryRepository { return &amp;MemoryRepository{ customers: make(map[uuid.UUID]aggregate.Customer), } }  \/\/ Get finds a customer by ID func (mr *MemoryRepository) Get(id uuid.UUID) (aggregate.Customer, error) { if customer, ok := mr.customers[id]; ok { return customer, nil }  return aggregate.Customer{}, customer.ErrCustomerNotFound }  \/\/ Add will add a new customer to the repository func (mr *MemoryRepository) Add(c aggregate.Customer) error { if mr.customers == nil { \/\/ Saftey check if customers is not create, shouldn't happen if using the Factory, but you never know mr.Lock() mr.customers = make(map[uuid.UUID]aggregate.Customer) mr.Unlock() } \/\/ Make sure Customer isn't already in the repository if _, ok := mr.customers[c.GetID()]; ok { return fmt.Errorf(\"customer already exists: %w\", customer.ErrFailedToAddCustomer) } mr.Lock() mr.customers[c.GetID()] = c mr.Unlock() return nil }  \/\/ Update will replace an existing customer information with the new customer information func (mr *MemoryRepository) Update(c aggregate.Customer) error { \/\/ Make sure Customer is in the repository if _, ok := mr.customers[c.GetID()]; !ok { return fmt.Errorf(\"customer does not exist: %w\", customer.ErrUpdateCustomer) } mr.Lock() mr.customers[c.GetID()] = c mr.Unlock() return nil }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b. \u0418 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432: \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0451\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u043e\u0432.<\/p>\n<blockquote>\n<p>\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0442\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u0430\u0431. \u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 <code>memory_test<\/code> (\u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442), \u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043c\u0430\u043f\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u043a\u0440\u0430\u0441\u043e\u0442\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u0435\u0440\u043a\u043d\u0435\u0442. \u041d\u043e \u0441\u0438\u043b\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438, \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0435\u043e\u0441\u043f\u043e\u0440\u0438\u043c\u0430. \u041d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0448\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0435\u0433\u043e \u043c\u043e\u043a\u043e\u043c, \u0438 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b.<\/p>\n<\/blockquote>\n<pre><code class=\"go\">package memory  import ( \"testing\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" \"github.com\/percybolmer\/ddd-go\/domain\/customer\" )  func TestMemory_GetCustomer(t *testing.T) { type testCase struct { name        string id          uuid.UUID expectedErr error }  \/\/ Create a fake customer to add to repository cust, err := aggregate.NewCustomer(\"Percy\") if err != nil { t.Fatal(err) } id := cust.GetID() \/\/ Create the repo to use, and add some test Data to it for testing \/\/ Skip Factory for this repo := MemoryRepository{ customers: map[uuid.UUID]aggregate.Customer{ id: cust, }, }  testCases := []testCase{ { name:        \"No Customer By ID\", id:          uuid.MustParse(\"f47ac10b-58cc-0372-8567-0e02b2c3d479\"), expectedErr: customer.ErrCustomerNotFound, }, { name:        \"Customer By ID\", id:          id, expectedErr: nil, }, }  for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) {  _, err := repo.Get(tc.id) if err != tc.expectedErr { t.Errorf(\"Expected error %v, got %v\", tc.expectedErr, err) } }) } }  func TestMemory_AddCustomer(t *testing.T) { type testCase struct { name        string cust        string expectedErr error }  testCases := []testCase{ { name:        \"Add Customer\", cust:        \"Percy\", expectedErr: nil, }, }  for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { repo := MemoryRepository{ customers: map[uuid.UUID]aggregate.Customer{}, }  cust, err := aggregate.NewCustomer(tc.cust) if err != nil { t.Fatal(err) }  err = repo.Add(cust) if err != tc.expectedErr { t.Errorf(\"Expected error %v, got %v\", tc.expectedErr, err) }  found, err := repo.Get(cust.GetID()) if err != nil { t.Fatal(err) } if found.GetID() != cust.GetID() { t.Errorf(\"Expected %v, got %v\", cust.GetID(), found.GetID()) } }) } }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0433\u043e\u0442\u043e\u0432. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0434\u043e\u043c\u0435\u043d\u043e\u043c (\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043e\u043f\u0440\u044f\u0436\u0451\u043d\u043d\u043e\u0441\u0442\u044c, high cohesion). \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u043c <code>Customer<\/code>, \u0442\u0430\u043a \u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u044e\u0434\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430\u043c\u0438, \u0432\u0435\u0434\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0441\u043b\u0430\u0431\u0443\u044e \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c (loose coupling).<\/p>\n<p>\u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u0442\u043e\u0433\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0432\u0435\u0440\u043d\u044b, \u0435\u0441\u043b\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d Customer Repository? \u0421\u043a\u043e\u0440\u043e \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u0432\u0435\u0440\u043d\u044b.<\/p>\n<h3>\u0421\u0435\u0440\u0432\u0438\u0441\u044b: \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443<\/h3>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043d\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0430\u0448 \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0446\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u0430\u043a \u00ab\u0441\u0435\u0440\u0432\u0438\u0441\u00bb. \u041e\u043d \u0441\u0432\u044f\u0436\u0435\u0442 \u0432\u0441\u0435 \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442 \u043d\u0443\u0436\u0434\u0430\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 <code>Order<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 (<code>CustomerRepository<\/code> \u0438 <code>ProductRepository<\/code>) \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438: <code>Order<\/code>, <code>Api<\/code> \u0438\u043b\u0438 <code>Billing<\/code>. \u041f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<\/p>\n<p>\u0412\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 <code>services<\/code>. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0444\u0430\u0439\u043b\u0430 <code>order.go<\/code> \u0438 <code>OrderService<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438 \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0435. \u0423 \u043d\u0430\u0441 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432, \u0442\u0430\u043a \u0447\u0442\u043e \u0437\u0430\u0432\u0435\u0434\u0451\u043c <code>CustomerRepository<\/code>, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<pre><code class=\"go\">\/\/ Package services holds all the services that connects repositories into a business flow package services  import \"github.com\/percybolmer\/ddd-go\/domain\/customer\"  \/\/ OrderConfiguration is an alias for a function that will take in a pointer to an OrderService and modify it type OrderConfiguration func(os *OrderService) error  type OrderService struct { customers customer.CustomerRepository }  \/\/ NewOrderService takes a variable amount of OrderConfiguration functions and returns a new OrderService \/\/ Each OrderConfiguration will be called in the order they are passed in func NewOrderService(cfgs ...OrderConfiguration) (*OrderService, error) { os := &amp;OrderService{} \/\/ Apply all Configurations passed in for _, cfg := range cfgs { err := cfg(os) if err != nil { return nil, err } } return os, nil }  \/\/ WithCustomerRepository applies a given customer repository to the OrderService func WithCustomerRepository(cr customer.CustomerRepository) OrderConfiguration { \/\/ return a function that matches the OrderConfiguration alias, \/\/ You need to return this so that the parent function can take in all the needed parameters return func(os *OrderService) error { os.customers = cr return nil } }  \/\/ WithMemoryCustomerRepository applies a memory customer repository to the OrderService func WithMemoryCustomerRepository() OrderConfiguration { \/\/ Create the memory repo, if we needed parameters, such as connection strings they could be inputted here cr := memory.New() return WithCustomerRepository(cr) }<\/code><\/pre>\n<blockquote>\n<p>\u0410\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0441\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u042f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0443\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0442\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u043a\u043e\u0434 \u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043e\u043c.<\/p>\n<\/blockquote>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443, \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0435.<\/p>\n<pre><code class=\"go\">\/\/ CreateOrder will chain together all repositories to create a order for a customer func (o *OrderService) CreateOrder(customerID uuid.UUID, productIDs []uuid.UUID) error { \/\/ Get the customer c, err := o.customers.Get(customerID) if err != nil { return err }  \/\/ Get each Product, Ouchie, We need a ProductRepository  return nil }<\/code><\/pre>\n<p>\u0423\u043f\u0441, \u0432 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0432\u0435\u0440\u043d\u0435 \u043d\u0435\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c. \u041d\u043e \u043c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0435 \u0431\u043b\u044e\u0434 \u0438 \u043d\u0430\u043f\u0438\u0442\u043a\u043e\u0432.<\/p>\n<h3>ProductRepository: \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u0442\u0430\u0432\u0435\u0440\u043d\u044b<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 DDD, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c <code>ProductRepository<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u043e\u0432. \u0421 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u044b.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0442 <code>Product<\/code> \u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<\/p>\n<pre><code class=\"go\">\/\/ File: product.go \/\/ Product is an aggregate that represents a product. package aggregate  import ( \"errors\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/entity\" )  var ErrMissingValues = errors.New(\"missing values\")  \/\/ Product is a aggregate that combines item with a price and quantity type Product struct { \/\/ item is the root entity which is an item item  *entity.Item price float64 \/\/ Quantity is the number of products in stock quantity int }  func NewProduct(name, description string, price float64) (Product, error) { if name == \"\" || description == \"\" { return Product{}, ErrMissingValues }  return Product{ item: &amp;entity.Item{ ID:          uuid.New(), Name:        name, Description: description, }, price:    price, quantity: 0, }, nil }  func (p Product) GetID() uuid.UUID { return p.item.ID }  func (p Product) GetItem() *entity.Item { return p.item }  func (p Product) GetPrice() float64 { return p.price }<\/code><\/pre>\n<p>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"go\">package aggregate_test  import ( \"testing\"  \"github.com\/percybolmer\/ddd-go\/aggregate\" )  func TestProduct_NewProduct(t *testing.T) { type testCase struct { test        string name        string description string price       float64 expectedErr error }  testCases := []testCase{ { test:        \"should return error if name is empty\", name:        \"\", expectedErr: aggregate.ErrMissingValues, }, { test:        \"validvalues\", name:        \"test\", description: \"test\", price:       1.0, expectedErr: nil, }, }  for _, tc := range testCases { t.Run(tc.test, func(t *testing.T) { _, err := aggregate.NewProduct(tc.name, tc.description, tc.price) if err != tc.expectedErr { t.Errorf(\"Expected error: %v, got: %v\", tc.expectedErr, err) } }) } }<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>domain\/product\/repository.go<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>ProductRepository<\/code>, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u043e\u0432\u0430\u0440\u0430\u043c.<\/p>\n<pre><code class=\"go\">\/\/ Package product holds the repository and the implementations for a ProductRepository package product  import ( \"errors\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" )  var ( ErrProductNotFound = errors.New(\"the product was not found\") ErrProductAlreadyExist = errors.New(\"the product already exists\") )  \/\/ ProductRepository is the repository interface to fulfill to use the product aggregate type ProductRepository interface { GetAll() ([]aggregate.Product, error) GetByID(id uuid.UUID) (aggregate.Product, error) Add(product aggregate.Product) error Update(product aggregate.Product) error Delete(id uuid.UUID) error }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u043e\u043c\u0435\u043d\u0435 <code>product<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>memory<\/code>.<\/p>\n<pre><code class=\"go\">\/\/ Package memory is a in memory implementation of the ProductRepository interface. package memory  import ( \"sync\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" \"github.com\/percybolmer\/ddd-go\/domain\/product\" )  type MemoryProductRepository struct { products map[uuid.UUID]aggregate.Product sync.Mutex }  \/\/ New is a factory function to generate a new repository of customers func New() *MemoryProductRepository { return &amp;MemoryProductRepository{ products: make(map[uuid.UUID]aggregate.Product), } }  \/\/ GetAll returns all products as a slice \/\/ Yes, it never returns an error, but \/\/ A database implementation could return an error for instance func (mpr *MemoryProductRepository) GetAll() ([]aggregate.Product, error) { \/\/ Collect all Products from map var products []aggregate.Product for _, product := range mpr.products { products = append(products, product) } return products, nil }  \/\/ GetByID searches for a product based on it's ID func (mpr *MemoryProductRepository) GetByID(id uuid.UUID) (aggregate.Product, error) { if product, ok := mpr.products[uuid.UUID(id)]; ok { return product, nil } return aggregate.Product{}, product.ErrProductNotFound }  \/\/ Add will add a new product to the repository func (mpr *MemoryProductRepository) Add(newprod aggregate.Product) error { mpr.Lock() defer mpr.Unlock()  if _, ok := mpr.products[newprod.GetID()]; ok { return product.ErrProductAlreadyExist }  mpr.products[newprod.GetID()] = newprod  return nil }  \/\/ Update will change all values for a product based on it's ID func (mpr *MemoryProductRepository) Update(upprod aggregate.Product) error { mpr.Lock() defer mpr.Unlock()  if _, ok := mpr.products[upprod.GetID()]; !ok { return product.ErrProductNotFound }  mpr.products[upprod.GetID()] = upprod return nil }  \/\/ Delete remove an product from the repository func (mpr *MemoryProductRepository) Delete(id uuid.UUID) error { mpr.Lock() defer mpr.Unlock()  if _, ok := mpr.products[id]; !ok { return product.ErrProductNotFound } delete(mpr.products, id) return nil }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b.<\/p>\n<pre><code class=\"go\">package memory  import ( \"testing\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" \"github.com\/percybolmer\/ddd-go\/domain\/product\" )  func TestMemoryProductRepository_Add(t *testing.T) { repo := New() product, err := aggregate.NewProduct(\"Beer\", \"Good for you're health\", 1.99) if err != nil { t.Error(err) }  repo.Add(product) if len(repo.products) != 1 { t.Errorf(\"Expected 1 product, got %d\", len(repo.products)) } } func TestMemoryProductRepository_Get(t *testing.T) { repo := New() existingProd, err := aggregate.NewProduct(\"Beer\", \"Good for you're health\", 1.99) if err != nil { t.Error(err) }  repo.Add(existingProd) if len(repo.products) != 1 { t.Errorf(\"Expected 1 product, got %d\", len(repo.products)) }  type testCase struct { name        string id          uuid.UUID expectedErr error }  testCases := []testCase{ { name:        \"Get product by id\", id:          existingProd.GetID(), expectedErr: nil, }, { name:        \"Get non-existing product by id\", id:          uuid.New(), expectedErr: product.ErrProductNotFound, }, }  for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { _, err := repo.GetByID(tc.id) if err != tc.expectedErr { t.Errorf(\"Expected error %v, got %v\", tc.expectedErr, err) }  }) }  } func TestMemoryProductRepository_Delete(t *testing.T) { repo := New() existingProd, err := aggregate.NewProduct(\"Beer\", \"Good for you're health\", 1.99) if err != nil { t.Error(err) }  repo.Add(existingProd) if len(repo.products) != 1 { t.Errorf(\"Expected 1 product, got %d\", len(repo.products)) }  err = repo.Delete(existingProd.GetID()) if err != nil { t.Error(err) } if len(repo.products) != 0 { t.Errorf(\"Expected 0 products, got %d\", len(repo.products)) } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c <code>OrderService<\/code>-\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>ProductRepository<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043e\u043f\u0446\u0438\u0438.<\/p>\n<pre><code class=\"go\">\/\/ OrderService is a implementation of the OrderService type OrderService struct { customers customer.CustomerRepository products  product.ProductRepository }  \/\/ WithMemoryProductRepository adds a in memory product repo and adds all input products func WithMemoryProductRepository(products []aggregate.Product) OrderConfiguration { return func(os *OrderService) error { \/\/ Create the memory repo, if we needed parameters, such as connection strings they could be inputted here pr := prodmemory.New()  \/\/ Add Items to repo for _, p := range products { err := pr.Add(p) if err != nil { return err } } os.products = pr return nil } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>CreateOrder<\/code>: \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0443\u044e \u0438\u0445 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"go\">\/\/ CreateOrder will chain together all repositories to create a order for a customer \/\/ will return the collected price of all Products func (o *OrderService) CreateOrder(customerID uuid.UUID, productIDs []uuid.UUID) (float64, error) { c, err := o.customers.Get(customerID) if err != nil { return 0, err }  \/\/ Get each Product, Ouchie, We need a ProductRepository var products []aggregate.Product var price float64 for _, id := range productIDs { p, err := o.products.GetByID(id) if err != nil { return 0, err } products = append(products, p) price += p.GetPrice() }  \/\/ All Products exists in store, now we can create the order log.Printf(\"Customer: %s has ordered %d products\", c.GetID(), len(products))  return price, nil }<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b <code>order_test.go<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0441 \u043e\u0431\u043e\u0438\u043c\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"go\">package services  import ( \"testing\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" )  func init_products(t *testing.T) []aggregate.Product { beer, err := aggregate.NewProduct(\"Beer\", \"Healthy Beverage\", 1.99) if err != nil { t.Error(err) } peenuts, err := aggregate.NewProduct(\"Peenuts\", \"Healthy Snacks\", 0.99) if err != nil { t.Error(err) } wine, err := aggregate.NewProduct(\"Wine\", \"Healthy Snacks\", 0.99) if err != nil { t.Error(err) } products := []aggregate.Product{ beer, peenuts, wine, } return products }  func TestOrder_NewOrderService(t *testing.T) { \/\/ Create a few products to insert into in memory repo products := init_products(t)  os, err := NewOrderService( WithMemoryCustomerRepository(), WithMemoryProductRepository(products), )  if err != nil { t.Error(err) }  \/\/ Add Customer cust, err := aggregate.NewCustomer(\"Percy\") if err != nil { t.Error(err) }  err = os.customers.Add(cust) if err != nil { t.Error(err) }  \/\/ Perform Order for one beer order := []uuid.UUID{ products[0].GetID(), }  _, err = os.CreateOrder(cust.GetID(), order)  if err != nil { t.Error(err) } }<\/code><\/pre>\n<h2>Tavern: \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b<\/h2>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438: \u0441\u0435\u0440\u0432\u0438\u0441\u0443 <code>Tavern<\/code>. \u0423 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>OrderService<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u044b. \u0422\u0430\u043a\u0430\u044f \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <code>Tavern<\/code> \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0447\u0435\u0442\u0430\u043c\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u0432 \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441, \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"go\">package services  import ( \"log\"  \"github.com\/google\/uuid\" )  \/\/ TavernConfiguration is an alias that takes a pointer and modifies the Tavern type TavernConfiguration func(os *Tavern) error  type Tavern struct { \/\/ orderservice is used to handle orders OrderService *OrderService \/\/ BillingService is used to handle billing \/\/ This is up to you to implement BillingService interface{} }  \/\/ NewTavern takes a variable amount of TavernConfigurations and builds a Tavern func NewTavern(cfgs ...TavernConfiguration) (*Tavern, error) { \/\/ Create the Tavern t := &amp;Tavern{} \/\/ Apply all Configurations passed in for _, cfg := range cfgs { \/\/ Pass the service into the configuration function err := cfg(t) if err != nil { return nil, err } } return t, nil }  \/\/ WithOrderService applies a given OrderService to the Tavern func WithOrderService(os *OrderService) TavernConfiguration { \/\/ return a function that matches the TavernConfiguration signature return func(t *Tavern) error { t.OrderService = os return nil } }  \/\/ Order performs an order for a customer func (t *Tavern) Order(customer uuid.UUID, products []uuid.UUID) error { price, err := t.OrderService.CreateOrder(customer, products) if err != nil { return err } log.Printf(\"Bill the Customer: %0.0f\", price)  \/\/ Bill the customer \/\/ err = t.BillingService.Bill(customer, price) return nil }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u0434\u0435\u043b\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442.<\/p>\n<pre><code class=\"go\">package services  import ( \"testing\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" )  func Test_Tavern(t *testing.T) { \/\/ Create OrderService products := init_products(t)  os, err := NewOrderService( WithMemoryCustomerRepository(), WithMemoryProductRepository(products), ) if err != nil { t.Error(err) }  tavern, err := NewTavern(WithOrderService(os)) if err != nil { t.Error(err) }  cust, err := aggregate.NewCustomer(\"Percy\") if err != nil { t.Error(err) }  err = os.customers.Add(cust) if err != nil { t.Error(err) } order := []uuid.UUID{ products[0].GetID(), } \/\/ Execute Order err = tavern.Order(cust.GetID(), order) if err != nil { t.Error(err) } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>CustomerRepository<\/code>. \u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 MongoDB. \u0422\u0443\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439\u00bb \u0437\u0430\u0441\u0438\u044f\u0435\u0442 \u0432\u043e \u0432\u0441\u0435\u0439 \u043a\u0440\u0430\u0441\u0435. \u042f \u043e\u0447\u0435\u043d\u044c \u0446\u0435\u043d\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439.<\/p>\n<blockquote>\n<p>\u0421\u0430\u043c \u044f \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0441\u043b\u044b\u0448\u0430\u043b, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u0435\u043d\u044f\u044e\u0442 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, MySQL \u043d\u0430 PostgreSQL, \u043d\u043e \u0432 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e. \u041f\u0440\u0430\u0432\u0434\u0430, \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 MongoDB. \u0418 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u044c\u043d\u043e. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0441\u043c\u0435\u043d\u044b \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043a\u0430\u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439, \u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u043e\u0432\u043e\u0434 \u043f\u0440\u044f\u0442\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438 \u2014 \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u043a\u043e\u0434\u044b, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441 \u0432\u0430\u0448\u0438\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043a\u0435\u0442 <code>mongo<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043c\u0435\u043d\u0430 <code>customer<\/code> \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0443\u044e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e <code>CustomerRepository<\/code>.<\/p>\n<p>\u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>mongoCustomer<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 MongoDB. \u041c\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 <code>aggregate.Customer<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043b\u043e \u0431\u044b \u0430\u0433\u0440\u0435\u0433\u0430\u0442 \u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u0432 \u0430\u0433\u0440\u0435\u0433\u0430\u0442 \u043f\u0440\u043e\u0441\u043e\u0447\u0438\u043b\u0438\u0441\u044c \u0431\u044b bson-\u0442\u0435\u0433\u0438 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0442\u0430\u043b\u043e \u0431\u044b \u0441\u043b\u043e\u0436\u043d\u043e). \u0410 \u043c\u044b, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u0435\u0447\u0430\u043b \u0437\u0430 (\u0434\u0435)\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u044f \u0441\u0432\u043e\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0432\u043d\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 \u0442\u0435\u0433\u0438 <code>json<\/code> \u0438\u043b\u0438 <code>bson<\/code>. \u041f\u0435\u0440\u0435\u0433\u043e\u043d\u044f\u0442\u044c \u0436\u0435 \u0438\u0437 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u0430\u0433\u0440\u0435\u0433\u0430\u0442 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<pre><code class=\"go\">\/\/ Mongo is a mongo implementation of the Customer Repository package mongo  import ( \"context\" \"time\"  \"github.com\/google\/uuid\" \"github.com\/percybolmer\/ddd-go\/aggregate\" \"go.mongodb.org\/mongo-driver\/bson\" \"go.mongodb.org\/mongo-driver\/mongo\" \"go.mongodb.org\/mongo-driver\/mongo\/options\" )  type MongoRepository struct { db *mongo.Database \/\/ customer is used to store customers customer *mongo.Collection }  \/\/ mongoCustomer is an internal type that is used to store a CustomerAggregate \/\/ we make an internal struct for this to avoid coupling this mongo implementation to the customeraggregate. \/\/ Mongo uses bson so we add tags for that type mongoCustomer struct { ID   uuid.UUID `bson:\"id\"` Name string    `bson:\"name\"` }  \/\/ NewFromCustomer takes in a aggregate and converts into internal structure func NewFromCustomer(c aggregate.Customer) mongoCustomer { return mongoCustomer{ ID:   c.GetID(), Name: c.GetName(), } }  \/\/ ToAggregate converts into a aggregate.Customer \/\/ this could validate all values present etc func (m mongoCustomer) ToAggregate() aggregate.Customer { c := aggregate.Customer{}  c.SetID(m.ID) c.SetName(m.Name)  return c  }  \/\/ Create a new mongodb repository func New(ctx context.Context, connectionString string) (*MongoRepository, error) { client, err := mongo.Connect(ctx, options.Client().ApplyURI(connectionString)) if err != nil { return nil, err }  \/\/ Find Metabot DB db := client.Database(\"ddd\") customers := db.Collection(\"customers\")  return &amp;MongoRepository{ db:       db, customer: customers, }, nil }  func (mr *MongoRepository) Get(id uuid.UUID) (aggregate.Customer, error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel()  result := mr.customer.FindOne(ctx, bson.M{\"id\": id})  var c mongoCustomer err := result.Decode(&amp;c) if err != nil { return aggregate.Customer{}, err } \/\/ Convert to aggregate return c.ToAggregate(), nil }  func (mr *MongoRepository) Add(c aggregate.Customer) error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel()  internal := NewFromCustomer(c) _, err := mr.customer.InsertOne(ctx, internal) if err != nil { return err } return nil }  func (mr *MongoRepository) Update(c aggregate.Customer) error { panic(\"to implement\") }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0432 <code>OrderService<\/code>.<\/p>\n<pre><code class=\"go\">func WithMongoCustomerRepository(connectionString string) OrderConfiguration { return func(os *OrderService) error { \/\/ Create the mongo repo, if we needed parameters, such as connection strings they could be inputted here cr, err := mongo.New(context.Background(), connectionString) if err != nil { return err } os.customers = cr return nil } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441 \u043b\u0451\u0433\u043a\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<pre><code class=\"go\">func Test_MongoTavern(t *testing.T) { \/\/ Create OrderService products := init_products(t)  os, err := NewOrderService( WithMongoCustomerRepository(\"mongodb:\/\/localhost:27017\"), WithMemoryProductRepository(products), ) if err != nil { t.Error(err) }  tavern, err := NewTavern(WithOrderService(os)) if err != nil { t.Error(err) }  cust, err := aggregate.NewCustomer(\"Percy\") if err != nil { t.Error(err) }  err = os.customers.Add(cust) if err != nil { t.Error(err) } order := []uuid.UUID{ products[0].GetID(), } \/\/ Execute Order err = tavern.Order(cust.GetID(), order) if err != nil { t.Error(err) } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u0442\u0430\u0432\u0435\u0440\u043d\u0430 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 in-memory \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c, \u0442\u0430\u043a \u0438 \u0441 MongoDB.<\/p>\n<p>\u0412\u043e\u0442 \u043c\u044b \u0438 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438:<\/p>\n<ul>\n<li>\n<p>\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (entities) \u2014 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (value objects) \u2014 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0431\u0435\u0437 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b (aggregates) \u2014 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 (repository) \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0444\u0430\u0431\u0440\u0438\u043a\u0430 (factory) \u2014 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0434\u043e\u043c\u0435\u043d\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0435\u0440\u0432\u0438\u0441 (service) \u2014 \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u043f\u0430\u043a\u0435\u0442\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u043c \u0432 DDD \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043c. \u0422\u0430\u043a \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u0447\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u043c\u0438 \u0438 \u0438\u0434\u0435\u044f\u043c\u0438. \u042d\u0442\u043e \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0431\u044b \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435.<\/p>\n<blockquote>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0430\u0432\u0442\u043e\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043b <a href=\"https:\/\/towardsdatascience.com\/how-to-structure-ddd-in-golang-28a7c3e7263b\">\u0432\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a>, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043d\u0435\u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/blockquote>\n<h2>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433<\/h2>\n<h3>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u043e\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u043f\u0430\u043a\u0435\u0442\u0430 <code>aggregate<\/code>. \u041c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442. \u042f \u0441\u043a\u043b\u043e\u043d\u044f\u044e\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043c\u0435\u043d. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0433\u0440\u0435\u0433\u0430\u0442 <code>Customer<\/code> \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043a\u0435\u0442\u0435-\u0434\u043e\u043c\u0435\u043d\u0435 <code>customer<\/code>.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/473\/60c\/2a4\/47360c2a4b45b66f83422e1fe46d03c6.png\" width=\"391\" height=\"167\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/473\/60c\/2a4\/47360c2a4b45b66f83422e1fe46d03c6.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u043f\u0430\u043f\u043a\u0438 <code>entity<\/code> \u0438 <code>valueobject<\/code>, \u0447\u0442\u043e, \u044f \u0434\u0443\u043c\u0430\u044e, \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043f\u043b\u043e\u0445\u043e, \u0432\u0435\u0434\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u0430\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u043e\u0433\u043e \u0436\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0438\u043d\u044b\u043c, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0417\u0430\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 <code>tavern<\/code> \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0442\u0443\u0434\u0430 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1e0\/547\/8aa\/1e05478aa52119ff139a13a4071db17b.png\" width=\"548\" height=\"414\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1e0\/547\/8aa\/1e05478aa52119ff139a13a4071db17b.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <code>go mod init<\/code> \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u044b.<\/p>\n<blockquote>\n<p>\u0410\u0432\u0442\u043e\u0440 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043e\u043f\u0440\u044f\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0447\u0442\u043e\u0431\u044b \u0432 \u043d\u0451\u043c \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u0430\u043c\u044b\u043c \u043b\u0443\u0447\u0448\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u0435\u0433\u043e \u043c\u044b\u0441\u043b\u0435\u0439. \u0412\u0435\u0434\u044c \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043b\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0443\u043d\u043e\u0441\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438.<\/p>\n<\/blockquote>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430: <code>order<\/code> \u0438 <code>tavern<\/code>. \u041f\u0440\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442 \u0437\u0430\u043c\u0443\u0441\u043e\u0440\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0415\u0449\u0451 \u043e\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u0442 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u043d\u0435 \u043e\u0442 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0430 \u043e\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/423\/c22\/c39\/423c22c39ef5f203eedf78f39468a977.png\" width=\"384\" height=\"191\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/423\/c22\/c39\/423c22c39ef5f203eedf78f39468a977.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0432\u0438\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bb3\/155\/889\/bb3155889f686f9fb387929230c5c6d6.png\" width=\"552\" height=\"524\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb3\/155\/889\/bb3155889f686f9fb387929230c5c6d6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043e\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0445\u043e\u0447\u0443 \u0432\u0430\u043c \u0434\u0430\u0442\u044c: \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 <code>cmd<\/code> \u0441 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a API, consumer-\u0430, \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439. \u0412 \u043f\u0430\u043f\u043a\u0435 <code>cmd<\/code> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<blockquote>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 (<a href=\"https:\/\/towardsdatascience.com\/how-to-implement-domain-driven-design-ddd-in-golang-2e2139beb09d\">\u0447\u0430\u0441\u0442\u044c 1<\/a>, <a href=\"https:\/\/towardsdatascience.com\/how-to-structure-ddd-in-golang-28a7c3e7263b\">\u0447\u0430\u0441\u0442\u044c 2<\/a>) \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0430\u0442\u044c DDD.<\/p>\n<p>\u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c, \u043d\u043e \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u044b. \u041a\u0430\u043a \u0432\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439, \u0438\u043b\u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443?<\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/companies\/domclick\/articles\/592087\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041d\u0443\u0436\u043d\u044b \u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">69.9% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0443\u0436\u043d\u044b<\/span><span class=\"tm-article-poll__answer-votes\">72<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 69.9%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">25.24% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0443\u0436\u043d\u044b, \u043d\u043e\u2026 (\u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u043c\u0438, \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0442\u0435\u043c\u044b..)<\/span><span class=\"tm-article-poll__answer-votes\">26<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 25.24%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">4.85% <\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0435 \u043d\u0443\u0436\u043d\u044b<\/span><span class=\"tm-article-poll__answer-votes\">5<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 4.85%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 103 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 10 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/592087\/\"> https:\/\/habr.com\/ru\/articles\/592087\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption>Image by Percy Bolm\u00e9r. Gopher by Takuya Ueda, Original Go Gopher by Ren\u00e9e French (CC BY 3.0)<\/figcaption><\/figure>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0438 \u0433\u0438\u0431\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0431\u0435\u0441\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u0442\u043e \u0441\u043a\u043e\u0440\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0441\u044f \u0441 \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043d\u0435\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e. \u0418\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 DDD (Domain-Driven Design, \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435). \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u043b \u043f\u0440\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043d\u0430\u0442\u044b\u043a\u0430\u044e\u0441\u044c \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<blockquote>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/towardsdatascience.com\/how-to-implement-domain-driven-design-ddd-in-golang-2e2139beb09d\">&#171;How to Implement Domain-Driven Design (DDD) in Golang&#187;<\/a>. \u041f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0443 \u0432\u0435\u0441\u0442\u0438 \u043e\u0442 \u043b\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0430, \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u044b\u0441\u043b\u044f\u043c\u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043a\u0430\u043a \u0438 \u044d\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<hr\/>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441 \u043d\u0443\u043b\u044f \u043e\u043d\u043b\u0430\u0439\u043d-\u0442\u0430\u0432\u0435\u0440\u043d\u0443, \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 DDD. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044f \u0447\u0438\u0442\u0430\u044e \u043f\u0440\u043e DDD, \u043c\u043e\u044f \u0433\u043e\u043b\u043e\u0432\u0430 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0432\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043e \u0447\u0451\u043c \u044f, \u0442\u043e \u044d\u0442\u0430 \u0441\u0445\u0435\u043c\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u043e\u044e \u0431\u043e\u043b\u044c.<\/p>\n<figure class=\"full-width\"><figcaption>Keywords in DDD \u2014 Graph from Eric Evans book Domain-Driven Design: Tackling Complexity in the Heart of Software<\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043c\u043e\u0451 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e DDD, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u043a\u0430\u0436\u0443, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u0445, \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0441\u0435\u0431\u044f \u0432 Go-\u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b; \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u044b\u0439 best practice. \u0411\u0443\u0434\u0443 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043f\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 DDD. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0451\u043b \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043d\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u0447\u0435 \u0443\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f. \u0428\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0431\u043e\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e: \u0442\u0430\u043c \u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u043c \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u042f \u043d\u0435 \u0440\u0430\u0437 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b \u0433\u043e\u0440\u044f\u0447\u0438\u0435 \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043e DDD \u0438 \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0418 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043e\u0431\u0440\u0430\u0449\u0430\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u044e\u0434\u0438 \u0437\u0430\u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0446\u0435\u043b\u044c DDD \u0438 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u043f\u043e\u0440\u0430\u0445 \u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u042d\u0432\u0430\u043d\u0441\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438, \u0430 \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u044b \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435.<\/p>\n<p>DDD \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u043d\u0438\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041d\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 DDD<\/h2>\n<p>Domain-Driven Design \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (\u0434\u043e\u043c\u0435\u043d\u0430, domain), \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u041f\u041e. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u0415\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u043b\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e DDD, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430\u043c\u0438 \u0432 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (Subject Matter Experts, SME). \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 \u043b\u044e\u0434\u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0437\u043d\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0430\u043a\u0446\u0438\u044f\u043c\u0438, \u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0444\u043e\u043d\u0434\u043e\u0432\u043e\u043c \u0440\u044b\u043d\u043a\u0435 \u0438\u0437 \u0443\u0441\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u043d\u0451\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u00a0\u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439.<\/p>\n<h3>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0433\u043e\u0444\u0435\u0440\u0430 \u0432 DDD<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e \u0433\u043e\u0444\u0435\u0440\u0430 \u0414\u0430\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0432\u0435\u0440\u043d\u0443. \u0414\u0430\u043d\u0442\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439. \u0412 \u0442\u043e\u0442 \u0434\u0435\u043d\u044c, \u043a\u043e\u0433\u0434\u0430 \u0414\u0430\u043d\u0442\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u0443 \u043d\u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c? \u041e\u043d \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u0443, \u043e\u0431\u0434\u0443\u043c\u044b\u0432\u0430\u044f \u0441\u0432\u043e\u0438 \u043f\u043b\u0430\u043d\u044b. \u041f\u043e\u043a\u0430 \u0414\u0430\u043d\u0442\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u0441\u0432\u0435\u0442\u043e\u0444\u043e\u0440\u0435, \u043a \u043d\u0435\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0448\u043b\u044f\u043f\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442: \u00ab<em>\u041f\u043e\u0445\u043e\u0436\u0435, \u0432\u044b \u0447\u0435\u043c-\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0435\u043d\u044b, \u043c\u043e\u043b\u043e\u0434\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u0435 \u043d\u0443\u0436\u043d\u0430 \u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0442\u0430\u0432\u0435\u0440\u043d\u044b?<\/em>\u00bb.<\/p>\n<p>\u0414\u0430\u043d\u0442\u0435 \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0448\u043b\u044f\u043f\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0433\u0443\u043b\u044f\u043b\u0438 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0432\u0435\u0440\u043d\u043e\u0439. \u0414\u0430\u043d\u0442\u0435 \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0443 \u043b\u044e\u0434\u0435\u0439 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438, \u0430 \u043d\u0435 \u0432\u044b\u043f\u0438\u0432\u043e\u0445\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u00ab\u0448\u043b\u044f\u043f\u0430\u00bb \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0432 \u0442\u0430\u0432\u0435\u0440\u043d\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c\u0438, \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 \u0438 \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u043c\u0438.<\/p>\n<h3>\u0414\u043e\u043c\u0435\u043d, \u043c\u043e\u0434\u0435\u043b\u044c, \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0438 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u044b<\/h3>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u043e \u0414\u0430\u043d\u0442\u0435, \u0432\u0435\u0434\u044c \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a. \u041e\u043d\u0430 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u0442 \u043d\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u043e\u0449\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f.<\/p>\n<p>\u0413\u0435\u0440\u043e\u0438 \u043d\u0430\u0448\u0435\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432 \u0441\u0435\u0441\u0441\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438: \u00ab\u0448\u043b\u044f\u043f\u0430\u00bb \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430, \u0430 \u0414\u0430\u043d\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u0431\u0435\u0441\u0435\u0434\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043d\u0430\u0434 \u0442\u0435\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0434\u043e\u043c\u0435\u043d\u043e\u043c (Core\/Root domain) \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0432\u0435\u0440\u043d\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0428\u043b\u044f\u043f\u0430 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u0438 \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u0445; \u0442\u0430\u043a \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a (ubiquitous language), \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u0431\u0438\u0432\u0430\u043b\u043e \u0431\u044b \u0441 \u0442\u043e\u043b\u043a\u0443, \u0430 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u043b\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u2014 \u0432\u0430\u0436\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u0442\u0430\u0432\u0435\u0440\u043d\u0443. \u041f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u00ab\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f\u00bb \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/p>\n<h2>\u041a\u043e\u0434 DDD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Go<\/h2>\n<h3>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u041f\u043e\u0440\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">mkdir ddd-go go mod init github.com\/percybolmer\/ddd-go<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>domain<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u044b. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0434\u043e\u043c\u0435\u043d\u043e\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0430\u043f\u043a\u0430. \u0412 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0451 <code>entity<\/code> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0442\u0443\u0434\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (entity) \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438: <code>Person<\/code> \u0438 <code>Item<\/code>. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u043a\u043e\u0434\u0430 \u044f \u0434\u0435\u043b\u0430\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u0433\u043a\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0421\u0435\u0439\u0447\u0430\u0441 \u0442\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u043d\u043e \u043f\u043e\u0437\u0436\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438 \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<pre><code class=\"go\">package entity  import \"github.com\/google\/uuid\"  \/\/ Person is a entity that represents a person in all Domains type Person struct { \/\/ ID is the identifier of the Entity, the ID is shared for all sub domains ID uuid.UUID Name string Age int }<\/code><\/pre>\n<pre><code class=\"go\">package entity  import \"github.com\/google\/uuid\"  \/\/ Item represents a Item for all sub domains type Item struct { ID          uuid.UUID  Name        string     Description string     }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c (Value Objects) \u2014 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440. \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u041e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0432 \u043d\u0438\u0445. \u0421\u0435\u0439\u0447\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Transaction<\/code>, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 ID \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c, \u043d\u043e \u0434\u043b\u044f \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<pre><code class=\"go\">package valueobject  import \"time\"  type Transaction struct { \/\/ all values lowercase since they are immutable amount    int from      uuid.UUID to        uuid.UUID createdAt time.Time }<\/code><\/pre>\n<h3>\u0410\u0433\u0440\u0435\u0433\u0430\u0442\u044b: \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0410\u0433\u0440\u0435\u0433\u0430\u0442 (Aggregate) \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 <code>Customer<\/code>. \u0420\u043e\u043b\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u2014 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. \u041e\u043d\u0438 \u043d\u0435 \u0434\u0430\u044e\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Person<\/code>, \u043d\u043e \u0438 <code>Products<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <code>Transactions<\/code>.<\/p>\n<p>\u0423 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 \u0432 DDD \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c (root entity). \u0422\u043e\u0433\u0434\u0430, \u0441\u0441\u044b\u043b\u0430\u044f\u0441\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, ID \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 Person \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 <code>Customer<\/code>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>aggregate<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0444\u0430\u0439\u043b <code>customer.go<\/code>. \u0422\u0430\u043c \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Customer<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0431\u0443\u043a\u0432\u044b (\u0442\u0430\u043a \u043c\u044b \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044f\u043c \u0432\u043d\u0435 \u043f\u0430\u043a\u0435\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b). \u042d\u0442\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u043e\u0432 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u0435\u0451 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u0443.<\/p>\n<pre><code class=\"go\">package aggregate  import ( \"github.com\/percybolmer\/ddd-go\/entity\" \"github.com\/percybolmer\/ddd-go\/valueobject\" )  \/\/ Customer is a aggregate that combines all entities needed to represent a customer type Customer struct { \/\/ person is the root entity of a customer \/\/ which means the person.ID is the main identifier for this aggregate person *entity.Person  \/\/ a customer can hold many products products []*entity.Item  \/\/ a customer can perform many transactions transactions []valueobject.Transaction  }<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0435\u0434\u0435\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0418 \u044f \u0445\u043e\u0447\u0443 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<h3>\u0424\u0430\u0431\u0440\u0438\u043a\u0438: \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438<\/h3>\n<p>\u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0438 \u043d\u0430\u0447\u043d\u0451\u043c \u043c\u044b \u0441 \u0444\u0430\u0431\u0440\u0438\u043a (factories). \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u043e\u0434 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0434\u0435\u0442\u0430\u043b\u044f\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<blockquote>\n<p>\u0415\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/w3sdesign.com\/index0100.php\">\u0441\u0430\u0439\u0442-\u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u2014 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 DDD-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0438 \u0432\u044b, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437.<\/p>\n<p>DDD \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 (\u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043c\u0438 \u0434\u0430\u043b\u0435\u0435). \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 <code>NewCustomer<\/code>. \u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043a\u0440\u044b\u0442\u043e \u043e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0435\u0451 \u043a\u043e\u0434\u0430 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-411031","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=411031"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411031\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}