快速 开发平台 架构_快速介绍清洁架构
快速 开发平台 架构
by Daniel Deutsch
由Daniel Deutsch
快速介绍清洁架构 (A quick introduction to clean architecture)
In an open source project I started to contribute to, the concept of “clean architecture” was brought to me.
在一个我开始参与的开源项目中 ,“清洁建筑”的概念被带给了我。
First, it was pretty overwhelming, but after some reading it made sense. I thought it might be helpful for others if I wrote down my thoughts.
首先,它非常令人难以理解,但是经过一番阅读之后,它才有意义。 我认为如果我写下自己的想法对他人可能会有帮助。
目录 (Table of Contents)
Visual representations
视觉表现
The concept — presented in bullet points
概念-以要点表示
Code example
代码示例
Resources
资源资源
视觉表现 (Visual representations)
I think it’s always good to start with some visualization.
我认为从一些可视化开始总是好事。
Here are the most common pictures of this concept.
这是此概念的最常见图片。
概念-以要点表示 (The concept — presented in bullet points)
Extended from Source and credit: Mattia Battiston, under CC BY 4.0
摘自来源和信誉: Mattia Battiston,根据CC BY 4.0
它可以提供的价值 (The value it can provide)
- An effective testing strategy that follows the testing pyramid遵循测试金字塔的有效测试策略
- Frameworks are isolated in individual modules. When (not if) we change our mind, we only have to make a change in one place. The app has use cases rather than being tied to a CRUD system框架隔离在各个模块中。 当(如果不是)我们改变主意时,我们只需要在一个地方进行更改即可。 该应用程序具有用例,而不是绑定到CRUD系统
- Screaming architecture a.k.a. it screams its intended usage. When you look at the package structure, you get a feel for what the application does rather than seeing technical details尖叫的架构又称它的预期用途。 当您查看包的结构时,您会感觉到应用程序的功能,而不是看到技术细节
- All business logic is in a use case, so it’s easy to find and not duplicated anywhere else所有业务逻辑都在用例中,因此很容易找到并且在其他任何地方都不会重复
- Hard to do the wrong thing because modules enforce compilation dependencies. If you try to use something that you’re not meant to, the app doesn’t compile很难做错事情,因为模块会强制执行编译依赖关系。 如果您尝试使用不需要的内容,则该应用程序将无法编译
- It is always ready to deploy by leaving the wiring up of the object for last. Or by using feature flags, so we get all the benefits of continuous integration通过将对象的布线留到最后,可以随时进行部署。 或通过使用功能标志,这样我们就可以获得持续集成的所有好处
- Multiple works on stories so that different pairs can easily work on the same story at the same time to complete it quicker多个故事作品,以便不同的配对可以轻松地同时处理同一个故事,从而更快地完成故事
- Good monolith with clear use cases that you can split in microservices later on, once you’ve learned more about them具有清晰用例的良好整体,一旦您了解了更多有关微服务的信息,便可以在以后将其拆分
实体 (Entities)
- Represent your domain object代表您的领域对象
- Apply only logic that is applicable in general to the whole entity (e.g., validating the format of a hostname)仅应用通常适用于整个实体的逻辑(例如,验证主机名的格式)
- Plain objects: no frameworks, no annotations普通对象:无框架,无注释
用例 (Use Cases)
- Represent your business actions: it’s what you can do with the application. Expect one use case for each business action代表您的业务行为:这就是您可以使用该应用程序执行的操作。 预期每个业务操作都有一个用例
- Pure business logic, plain code (except maybe some utils libraries)纯业务逻辑,纯代码(也许某些utils库除外)
- The use case doesn’t know who triggered it and how the results are going to be presented (for example, could be on a web page, or — returned as JSON, or simply logged, and so on.)用例不知道是谁触发了它,以及结果将如何显示(例如,可能在网页上,或者-以JSON返回,或者只是记录下来,等等)。
- Throws business exceptions引发业务异常
接口/适配器 (Interfaces / Adapters)
- Retrieve and store data from and to a number of sources (database, network devices, file system, 3rd parties, and so on.)从多个源(数据库,网络设备,文件系统,第三方等)检索数据并将数据存储到其中。
- Define interfaces for the data that they need in order to apply some logic. One or more data providers will implement the interface, but the use case doesn’t know where the data is coming from为它们需要应用某种逻辑的数据定义接口。 一个或多个数据提供者将实现该接口,但用例不知道数据来自何处
- Implement the interfaces defined by the use case实现用例定义的接口
- There are ways to interact with the application, and typically involve a delivery mechanism (for example, REST APIs, scheduled jobs, GUI, other systems)与应用程序进行交互的方式很多,通常都涉及一种交付机制(例如,REST API,计划的作业,GUI,其他系统)
- Trigger a use case and convert the result to the appropriate format for the delivery mechanism触发用例并将结果转换为交付机制的适当格式
- the controller for a MVCMVC的控制器
外部介面 (External Interfaces)
- Use whatever framework is most appropriate (they are going to be isolated here anyway)使用最合适的框架(无论如何它们都将在这里被隔离)
代码示例 (Code example)
See the structure on GitHub.
请参阅GitHub上的结构。
First of all, it is important to understand that clean architecture is a bundle of organising principles. So therefore everything is open to personal adjustments as long as core ideas are kept intact. The linked repository is a fork of the original project that brought this architecture design idea to me. Feel free to check out the original project as well, as it reflects further improvements.
首先,重要的是要了解干净的体系结构是一整套组织原则。 因此,只要保持核心思想不变,一切都可以进行个人调整。 链接的存储库是原始项目的分支,该项目将这个体系结构设计思想带给了我。 也可以随时检查原始项目,因为它反映了进一步的改进。
The webminer folder is structured into the basic layers:
webminer文件夹分为以下基本层:
- entities实体
- use_cases用例
- interfaces_adaptersinterfaces_adapters
- external_interfacesexternal_interfaces
It shall reflect the very basic approach for the design pattern.
它应反映出设计模式的最基本方法。
Starting from
entities
, you can see that the core model of this project is thearxiv_document
从
entities
开始,您可以看到该项目的核心模型是arxiv_document
The next folder,
use_cases
shows our use case, namely to request the arxiv page下一个文件夹
use_cases
显示了我们的用例,即请求arxiv页面After that, we go through the
interface_adapters
folder that provides adapters for process requests in a REST application or for serializing之后,我们浏览
interface_adapters
文件夹,该文件夹为REST应用程序中的流程请求或序列化提供适配器The final and last layer is
external_interfaces
. This is where we use the flask server to implement the REST functionality最后一层是
external_interfaces
。 这是我们使用Flask服务器实现REST功能的地方
All of those layers are dependent on the core layers but not the other way around.
所有这些层都依赖于核心层,而不是相反。
One important note: This is not 100% correctly implemented in the repository.
重要注意事项:这不是在存储库中100%正确实现的。
Why? Because the use cases are actually different. In reality the main use case is to provide the structured data. Another use case is to get the data from the arxiv page.
为什么? 因为用例实际上是不同的。 实际上,主要用例是提供结构化数据。 另一个用例是从arxiv页面获取数据。
Did you spot this error in the architecture? If yes, congratulations! Not only did you bring enough curiosity to this article but you likely understand the principles well enough to build your own case and apply the concepts in reality!
您在架构中发现此错误了吗? 如果是的话,恭喜! 您不仅为本文带来了足够的好奇心,而且您可能充分理解了这些原理,可以建立自己的案例并在现实中应用这些概念!
Do you agree? If not, why? Thanks for reading my article! Feel free to leave any feedback!
你同意吗? 如果没有,为什么? 感谢您阅读我的文章! 随时留下任何反馈!
翻译自: https://www.freecodecamp.org/news/a-quick-introduction-to-clean-architecture-990c014448d2/
快速 开发平台 架构
相关文章:

linux uart m200平台波特率500kbps乱码问题和输入不响应问题
[问题] linux uart m200平台波特率500kbps乱码问题 [解答] [问题] linux uart m200平台波特率500kbps输入不响应问题 [解答]转载于:https://www.cnblogs.com/harvis/p/6972196.html

VS2013中, 无法嵌入互操作类型“……”,请改用适用的接口的解决方法
使用VS2013,在引用COM组件的时候,出现了无法嵌入互操作类型“……”,请改用适用的接口的错误提示。 查阅资料,找到解决方案,记录如下: 选中项目中引入的dll,鼠标右键,选择属性&#…

JS根据两点的经纬度坐标得到驾车行驶距离
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 html <!DOCTYPE html> <html><head><meta http-equiv"Content-Type" content"text/html; charsetutf-8"><meta name"viewport" content&quo…

three.ar.js_我们如何通过AR.js使产品吉祥物栩栩如生
three.ar.jsby Mateusz Tarnaski由Mateusz Tarnaski 我们如何通过AR.js使产品吉祥物栩栩如生 (How we brought our product mascot to life with AR.js) Short answer: using a browser-based Augmented Reality (AR) application. For the long answer, read below.简短答案&…

利用tuning-primer脚本优化MySQL数据库
脚本下载网址: http://www.day32.com/MySQL/tuning-primer.sh #!/bin/sh # vim: ts8########################################################################## ## MySQL performance tuning primer script ## Writen by: Matthew Montgomery ## Report bugs t…

自定义View步骤学习笔记
用途 : 一个View内部的子控件比较多的时候可以自定义一个View,把它内部的子控件屏蔽起来(就像苹果的导航栏上面的UIBarButton,你是通过BarButtonitem来修改显示的内容) 1.重写 initWithFrame 和 awakeFromNib(一般两个都要写),然后在写一个初始化的方法,在初始化方法中添加子控…

小程序给视频加默认图片封面,点击播放视频并停止播放上一个视频
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 实现的功能: 微信小程序视频组件添加图片封面, 点击图片播放视频, 点击下一个视频的封面图自动停止播放当前视频并播放点击的视频。 效果GIF图: 实现代码: WXML …

一天 用户旅程_439天的旅程改变了我的生活
一天 用户旅程by Daniel Lemay丹尼尔勒梅(Daniel Lemay) 439天的旅程改变了我的生活 (The 439 day Journey that Changed my Life) It was Spring of 2017. I was beyond displeased with my current work situation. I dreaded going into work every day and being a punchi…

实现音乐播放器
音乐播放器 首先声明一下,本例是直接采用课本中范例122的方法。 效果图如下: 1、activity_main.xml布局 1 //四个按钮2 <LinearLayout3 android:layout_width"fill_parent"4 android:layout_height"wrap_content"5 …

学习ASP.NET MVC系列 - 还有比这更简炼的吗?把复杂的事情变简单了,贡献啊!...
转自学习ASP.NET MVC系列: 学习ASP.NET MVC(一)——我的第一个ASP.NET MVC应用程序 学习ASP.NET MVC(二)——我的第一个ASP.NET MVC 控制器 学习ASP.NET MVC(三)——我的第一个ASP.NET MVC 视图 学习ASP.NET MVC(四)——我的第一个ASP.NET MVC 实体对象 学习ASP.NET…
微信小程序开通腾讯云开发实践流程附详细图解
微信小程序开发交流qq群 173683895 云开发流程: 1.关联账户 关联腾讯云账号与微信公众号平台账号。前往关联账号时,请选择微信公众号。错误关联账号请在腾讯云账号中心重新绑定。 已关联账号 2.安装开发者工具 下载与安装客户端微信开发者工具并使…

github组织存储库使用_为什么我不使用您的GitHub存储库
github组织存储库使用by Sam Westreich, PhD由Sam Westreich博士 为什么我不使用您的GitHub存储库 (Why I’m not using your GitHub repository) As a bioinformatician, I reside in an interesting middle ground between developers and end users. My background trainin…

PHP导入excel到mysql数据库完整代码附效果图
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.新建一个数据库 ImportXlsx 并在里面添加表名 IsXlsx. 2.下载 phpExcel 插件 点击下载 3.导入文件和xlsx 。 4.获取xlsx表的对象并存入数据库 效果图: PHP 实现 demo <?phph…

黑马程序员—易混淆的知识
------- android培训、java培训、期待与您交流! ---------- String和StringBuffer类区别1.String 是定长的例如:String s1"abc";s1"egf";StringBuffer类:是变成字符串,因为它具有(buffer)缓冲区&a…

简谈 Java 中的泛型通配符
很好的一篇文章https://zhuanlan.zhihu.com/p/26681625 转载于:https://www.cnblogs.com/hihtml5/p/6978651.html

播客#47:劳伦斯·布拉德福德
On todays episode, I interview Laurence Bradford. Shes the creator of the LearnToCodeWith.me blog and podcast, and the Newbie Coder Warehouse Facebook group.在今天的一集中,我采访了劳伦斯布拉德福德。 她是LearnToCodeWith.me博客和播客以及Newbie Cod…

如何使用 DBCC MEMORYSTATUS 命令来监视 SQL Server 2005 中的内存使用情况
https://technet.microsoft.com/en-us/solutionaccelerators/dd537566.aspx 注意:这篇文章是由无人工介入的微软自动的机器翻译软件翻译完成。微软很高兴能同时提供给您由人工翻译的和由机器翻译的文章, 以使您能使用您的语言访问所有的知识库文章。然而由机器翻译的…

{code:-1,error:`QcloudSecretId`不能为空,请确保 SDK 配置已正确初始化}解决方法
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 微信小程序云开发登录报错:{"code":-1,"error":"QcloudSecretId不能为空,请确保 SDK 配置已正确初始化"} 遇到这个错误的原因是:腾讯不…

[转载] Tmux 速成教程:技巧和调整
原文: http://blog.jobbole.com/87584/ 决定从 screen 转向 tmux 了, 非常喜欢 tmux 的窗格功能. 简介 有些开发者经常要使用终端控制台工作,导致最终打开了过多的标签页。如果你也是他们当中的一员,或者你正在实践结对编程,那么我推荐你读一…

css在兼容模式下无法引用_如何在CSS中使用深色模式
css在兼容模式下无法引用by Frank Lmmer由FrankLmmer 如何在CSS中使用深色模式 (How to get dark mode working with CSS) I have been playing around with MacOS Mojave’s dark mode lately. It’s not 100% pleasing to my eyes, yet. But it’s especially useful when n…

COJ 0995 WZJ的数据结构(负五)区间操作
WZJ的数据结构(负五)难度级别:C; 运行时间限制:1000ms; 运行空间限制:262144KB; 代码长度限制:2000000B 试题描述请你设计一个数据结构,完成以下功能…

接入网易云信IM即时通讯的微信小程序聊天室
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 接入流程: 初次接触网易云通信IM服务,您可以通过以下产品介绍文档了解我们的产品功能、相关概念、业务限制: 产品简介主要功能帐号集成与登录接口及业务限制 1. 创建…

vue颜色选择器_如何制作? Vue的颜色选择器!
vue颜色选择器by ZAYDEK由ZAYDEK 如何制作? Vue的颜色选择器! (How to make a ? color picker with Vue!) 注意:颜色看起来可能比实际颜色更可爱! (Caution: colors may appear cuter than they are!) Before I get to the arti…

centos7中使用yum安装tomcat以及它的启动、停止、重启
centos7中使用yum安装tomcat 介绍 Apache Tomcat是用于提供Java应用程序的Web服务器和servlet容器。 Tomcat是Apache Software Foundation发布的Java Servlet和JavaServer Pages技术的开源实现。 本教程介绍在CentOS 7服务器上使用yum进行Tomcat 7的基本安装和一些配置。请注意…

JS 数组A有数组B的数据就删除
微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 创建了两个数组,并且封装了一个函数以供调用。 var arr1 [a,b,c,d],arr2 [a,c,d,f]; this.arrayWeightRemoval(arr1,arr2); //返回结果 [b] ;// 数据去重this.arrayWeightRemoval functio…

PL/SQL Developer的调试存储过程
学会使用PL/SQL Developer的调试功能,对于编写复杂的存储过程,包,funtion...非常有帮助,所以今晚学习了一下: (1)在sp里设置断点。 (2)点击TEST. (3) Debug-->Start. …

graphql_普通英语GraphQL指南
graphqlby Luis Aguilar路易斯阿吉拉尔(Luis Aguilar) 普通英语GraphQL指南 (A Guide to GraphQL in Plain English) 您需要了解的最新流行语正在席卷API开发领域。 (All you need to know about the latest buzzword that’s taking the API development scene by storm.) TL…

第1课第4.4节_Android硬件访问服务编写HAL代码
android应用如何访问C库 - 落魄影子 - 博客频道 - CSDN.NET http://blog.csdn.net/ab198604/article/details/51249303 Android硬件访问服务框架代码编写 - 落魄影子 - 博客频道 - CSDN.NET http://blog.csdn.net/ab198604/article/details/51397586 4 编写HAL代码 源码下载方…
Android新版NDK环境配置(免Cygwin)
本菜鸟在查阅了很多文章,又是去折腾cygwin之类的,虽然可以编译出so文件,但运行项目却有很多问题。当发现最新的ndk不需要cygwin的时候,跪了(orz)。 现在进入正题。 使用工具: adt-bundle-window…

小程序获取用户的操作轨迹日志
微信小程序开发交流qq群 173683895 花费了两天时间,修改过数次,终于把这个功能封装成了一个独立的工具。 任何小程序都可在不修改原代码的情况下直接镶入使用!!! 步骤: 1. 在小程序 app.js 的平级目录…