centos 初学者_初学者的唯一真理来源

centos 初学者

Image for post
All rights to their respective owners.
各自所有者的所有权利。

A quick skim of Google search results won’t shed much light on what exactly is the “single source of truth” — or the SSOT. Wikipedia defines it as, “the practice of structuring information models and associated data schema such that every data element is mastered in only one place.” If your reaction was along the lines of, “Wait, what?” then you’re not alone. As a software engineering student, when I first heard this term, I thought it sounded more like a line from a Sci-Fi/Fantasy book series than a computer science concept. It was only until I put this into practice when learning about tables and object associations in Ruby, that I understood why this concept is so crucial.

快速浏览一下Google搜索结果不会对“单一真相”或SSOT到底有多大的了解。 维基百科将其定义为“构造信息模型和相关数据模式的实践,这样每个数据元素都只能在一个地方掌握。 ”如果您的React是“等等,那是什么?” 那么你并不孤单。 作为软件工程专业的学生,​​当我第一次听到这个词时,我认为它听起来更像是科幻/奇幻小说系列的一句话,而不是计算机科学的概念。 直到我在学习Ruby中的表和对象关联时将其付诸实践,我才理解为什么这个概念如此重要。

First, it’s important to clarify that SSOT is an overarching computer science term and can be applied towards many languages. I’ll only concentrate on Ruby for purposes of this article. Using an object-oriented programming language, we (aspiring) engineers and developers build objects (or things, whichever is easier to understand) by first considering what the intended use is, and then by how it interacts with different objects.

首先,重要的是要弄清楚SSOT是计算机科学的一个主要术语,可以应用于多种语言。 就本文而言,我将仅关注Ruby。 我们(有抱负的)工程师和开发人员使用面向对象的编程语言来构建对象(或事物,以较容易理解的为准),方法是首先考虑预期的用途,然后考虑其与不同对象的交互方式。

Ok…can I get an example?

好吧...我可以举个例子吗?

Let’s use a hypothetical situation from Avatar: The Last Airbender, when Zuko (“Lee”) and Uncle Iroh (“Mushi”) open a tea shop in Ba Sing Se.

让我们使用《阿凡达》中的一个假设情况:《最后的气宗》,当祖科(“李”)和伊罗叔叔(“木石”)在巴星瑟开设一家茶店时。

Image for post
Please excuse how uneven the arrows are. Images are not my own.
请原谅箭头的高度。 图片不是我自己的。

You would build a class called Shopkeeper and create the instances “Lee” and “Mushi”. Think of a class as a template — it wouldn’t be very time efficient to create a class for every individual object. These two shopkeepers own a tea shop, the Jasmine Dragon. The Jasmine Dragon is such a success that they have repeat customers. Likewise, you’d create a class Shop with the instance “Jasmine Dragon” and create the class Customer for their many repeat customers. It doesn’t matter if they have 5, 50, or even 500 customers. The shopkeepers know their customers and vice versa, because the tea shop is what links them. In Ruby, these three classes would each be their individual tables, and the tea shop is the single source of truth. They can interact with each other through this source.

您将构建一个名为Shopkeeper的类,并创建实例“ Lee”和“ Mushi”。 将类视为模板–为每个单独的对象创建类并不是很省时。 这两个店主拥有一家茶店,茉莉龙。 茉莉花龙(Jasmine Dragon)如此成功,以致他们拥有回头客。 同样,您将使用实例“ Jasmine Dragon”创建一个Shop类,并为他们的许多回头客创建Customer类。 他们有5个,50个甚至500个客户都没关系。 店主知道他们的顾客,反之亦然,因为茶店是联系他们的。 在Ruby中,这三个类分别是各自的表,而茶馆则是真理的唯一来源。 他们可以通过此来源相互交流。

What happens if we expand our number of classes?

如果我们增加课程数量会怎样?

Previously on Avatar, Aang and his friends travel to Chin Village where they are shocked to discover that not only is the Avatar not welcome, but in a previous life, Avatar Kyoshi allegedly killed their founder, Chin the Conqueror. Aang tries to make amends with the village but his attempts fail to win them over.

以前在阿凡达(Avatar)上,阿昂(Aang)和他的朋友们前往奇恩村(Chin Village),他们震惊地发现,不仅不欢迎阿凡达(Avatar),而且在前世,阿凡达(Avatar Kyoshi)据称杀害了其创始人“征服者奇恩(Chin the Conqueror)”。 阿昂(Aang)试图对村庄进行补偿,但他的努力未能赢得他们。

Image for post
In this model, the Avatar and Villager are aware of one another and can interact. PastAvatar is needed, but cannot be accessed.
在此模型中,阿凡达和村民彼此了解并可以互动。 PastAvatar是必需的,但无法访问。

Eventually, he figures he needs to go directly to the source. Aang turns to Kyoshi, who confirms to both Aang and the villagers that she indirectly killed Chin (or as Kyoshi put it, “a horrible tyrant”), when she split the peninsula from his empire. Avatars Aang and Kyoshi are aware of each other, but the villagers are not aware of Kyoshi. Similarly, Kyoshi is unable to contact the villagers if not for the Avatar connection. The Avatar connection, in this example, is the single source of truth. Without the Avatar connection, Aang would have no way of knowing about Kyoshi’s presence, let alone getting the truth from Kyoshi, nor would Kyoshi be able to access Aang and speak directly to the villagers.

最终,他认为自己需要直接去找源头。 Aang求助于Kyoshi,她向Aang和村民证实,当她将半岛与帝国分开时,她间接杀害了Chin(或正如Kyoshi所说,是“可怕的暴君” )。 头像Aang和Kyoshi彼此了解,但村民们并不了解Kyoshi。 同样,如果没有Avatar连接,Kyoshi将无法与村民联系。 在此示例中,头像连接是事实的唯一来源。 没有阿凡达(Avatar)的联系,Aang将无法得知Kyoshi的身影,更不用说从Kyoshi那里获得真相了,而且Kyoshi也无法访问Aang并直接与村民交谈。

Image for post
In this model, Past Avatar, Avatar, and Villager are aware of one another because the Avatar Connection exists. 在此模型中,“过去头像”,“头像”和“村民”彼此了解,因为存在“头像连接”。

What’s the difference between a join table and a Single Source Of Truth?

联接表和单一真相之间有什么区别?

SSOT is a concept, and a join table is a method of how we would address relationships or associations in Ruby/Rails, in order to have a Single Source of Truth. There are likely many variations of this across programming languages.

SSOT是一个概念,而联接表是一种方法,我们可以通过它解决Ruby / Rails中的关系或关联,以使 真相。 跨编程语言,这可能会有很多变化。

Ok, but I still don’t get why it’s important.

好的,但是我仍然不明白为什么它很重要。

Here are a few reasons why understanding the Single Source of Truth is essential.

以下是为什么理解真理的单一来源至关重要的几个原因。

  1. Clarity. At some point, the classes in your code need to interact with each other and access certain attributes. As Mulesoft put it, your code and data don’t exist in silos. Understanding SSOT will make it clearer for you as you write your code and build more features. You’ll need to know whether or not to generate a new class or join table based on how your code interacts with what you’re intending to build.

    明晰。 在某些时候,代码中的类需要相互交互并访问某些属性。 正如Mulesoft所说,您的代码和数据并不孤岛。 了解SSOT将使您在编写代码和构建更多功能时更加清楚。 您将需要根据代码与您要构建的代码之间的交互方式来知道是否生成新类或联接表。

  2. Keeping your code DRY. If you’ve heard it once, you’ve heard it a thousand times. You don’t want repetitive code. Understanding SSOT will help you create methods and even improve your method’s efficiency in their classes so they can build upon one another other. It may not seem like a big deal with the few lines of code you’ve created locally, but imagine the implications when you’re dealing with much bigger batches of information.

    保持代码干燥。 如果您听过一次,则听过一千次。 您不需要重复的代码。 了解SSOT将有助于您创建方法,甚至可以提高方法在类中的效率,从而使它们可以彼此建立。 您在本地创建的几行代码看起来似乎没什么大不了的,但是请想象一下在处理大量信息时的含义。

Single source of truth can be a confusing concept, especially when you’re starting your coding journey. When in doubt, think about how the classes you’re building interact with one another and if helpful, create or base it on an example (in my case, a story subplot). Even code needs to understand how it relates to one another.

单一事实来源可能是一个令人困惑的概念,尤其是在您开始编码之旅时。 如有疑问,请考虑您正在构建的类之间如何交互,如果有帮助,请基于示例(在我的情况下为故事子情节)创建或建立类。 甚至代码也需要理解它们之间的关系。

Sources:

资料来源:

What is a Single Source of Truth? by Mulesoft

什么是真理的单一来源? 由Mulesoft

Single Source of Truth by Wikipedia

维基百科的真相单一来源

翻译自: https://medium.com/swlh/single-source-of-truth-for-beginners-e3dae44877d5

centos 初学者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值