抽象类抽象变量_编码人员对抽象的掌握

本文深入探讨了编程中的抽象类及其抽象变量的概念,通过译文介绍了如何在实际编码中理解和运用这些抽象概念,以提升代码的设计模式和可扩展性。
摘要由CSDN通过智能技术生成

抽象类抽象变量

The secret to productivity is to master abstraction. Many developers regard “abstraction” as a dirty word. You will hear (otherwise good) suggestions such as “Don’t abstract too early” or the famous “Explicit is better than implicit” in Python’s Zen, which means that concrete is better than abstract. All of these are good suggestions-depending on the context.

生产力的秘诀是掌握抽象。 许多开发人员将“抽象”视为脏话。 您会听到(否则很好的)建议,例如Python的Zen中的“不要过早抽象”或著名的“显式胜于隐式”,这意味着具体要胜于抽象。 所有这些都是好的建议-取决于上下文。

But modern applications use a lot of code. If you print out the source code of the top ten modern applications, these paper stacks will compete with the height of skyscrapers, and the software maintenance costs are high. The more code you create, the higher the cost.

但是现代应用程序使用大量代码。 如果打印出十大现代应用程序的源代码,这些纸叠将与摩天大楼的高度竞争,并且软件维护成本很高。 您创建的代码越多,成本就越高。

减少代码错误的关键 (key to less errors in code)

The correct abstraction can hide details that are not important to the current context and reduce the amount of code required to perform the same work (usually by several orders of magnitude), thereby making the code more readable, adaptable, and maintainable.

正确的抽象可以隐藏对当前上下文不重要的细节,并减少执行同一工作所需的代码量(通常减少几个数量级),从而使代码更具可读性,适应性和可维护性。

Abstraction is not a one-way road. It is actually formed by two complementary concepts: Generalization-remove the repetitive parts (obvious parts) and hide them behind the abstract. Specialization-Apply abstraction in a specific use case, adding only what needs to be different (meaningful).

抽象不是单向的道路。 它实际上由两个互补的概念形成:​​泛化-删除重复部分(显而易见的部分)并将其隐藏在摘要后面。 专业化-在特定用例中应用抽象,仅添加需要不同的内容(有意义)。

Junior developers think they have to write a lot of code to generate a lot of value. Senior developers understand the value of not having to write any code. Imagine, as a coder, he makes extensive use of map operations in programming languages ​​like JavaScript. Map extracts detailed information, such as the type of data you want to map, the type of data structure that contains the data, and the iteration logic required to enumerate each data node in the data structure. It has improved the efficiency of every application I have built in the past ten years.

初级开发人员认为他们必须编写大量代码才能产生很多价值。 高级开发人员了解不必编写任何代码的价值。 想象一下,作为一名编码员,他在JavaScript之类的编程语言中广泛使用了地图操作。 Map提取详细信息,例如要映射的数据类型,包含该数据的数据结构的类型以及枚举数据结构中每个数据节点所需的迭代逻辑。 在过去十年中,它提高了我构建的每个应用程序的效率。

Jeremy Ashkenas made this type of operation popular in JavaScript, and by pioneering its use in CoffeeScript, it paved the way for many important syntax shortcuts that we now take for granted in JavaScript. the way. He produced Underscore and Backbone. Backscore produced Lodash (still the most popular functional programming utility belt in JavaScript), and Backbone made the MVC architecture in JavaScript popular, and laid the foundation for Angular and React.

杰里米·阿什肯纳斯(Jeremy Ashkenas)使这种类型的操作在JavaScript中很流行,并且通过在CoffeeScript中率先使用它,它为许多重要的语法快捷方式铺平了道路,而现在我们在JavaScript中理所当然地想到了这些快捷方式。 方式。 他制作了Underscore和Backbone。 Backscore产生了Lodash(仍然是JavaScript中最受欢迎的函数式编程实用程序带),Backbone使得JavaScript中的MVC架构很流行,并为Angular和React奠定了基础。

John Resig made the popular and influential jQuery, which constitutes the largest collection of reusable, encapsulated JavaScript modules (jQuery plug-ins), until the standard Node modules and ES6 modules appeared a few years later . jQuery’s selector API is so influential that it forms the basis of today’s DOM selection API. When I unit test React components, I still benefit from jQuery’s selection API almost every day.

John Resig制作了流行和有影响力的jQuery,它构成了可重用的,封装JavaScript模块(jQuery插件)的最大集合,直到几年后出现了标准的Node模块和ES6模块。 jQuery的选择器API很有影响力,它构成了当今DOM选择API的基础。 当我对React组件进行单元测试时,几乎每天我仍然会受益于jQuery的选择API。

The right abstraction is a powerful lever that can greatly affect productivity. Abstraction is not an expletive. Modules, functions, variables, classes-all of these are abstract forms, and the whole reason they all exist is to simplify abstraction and abstract composition. You cannot build complex software without abstraction. Even assembly language uses abstract instruction names, memory addresses of variables, code points that jump to subroutines (such as function calls), etc. Modern software is a useful abstract multi-layer cake, these layers provide you with leverage.

正确的抽象是可以极大地影响生产力的强大杠杆。 抽象不是专有名词。 模块,函数,变量,类-所有这些都是抽象形式,它们全部存在的全部原因是为了简化抽象和抽象构成。 没有抽象就不能构建复杂的软件。 甚至汇编语言也使用抽象指令名称,变量的内存地址,跳转到子例程的代码点(例如函数调用)等。现代软件是有用的抽象多层蛋糕,这些层为您提供了杠杆作用。

The key to simplicity: The secret we are pursuing is how to reduce the amount of code being generated and how to do more with less money. After mastering this, you will become much more efficient as a programmer.

简化的关键:我们追求的秘密是如何减少所生成的代码量以及如何用更少的钱做更多的事情。 掌握了这一点之后,您将成为一名程序员,效率更高。

If you want to know a bit more what I do and visit some of my programming code, you can always check out the open-source code I’m hosting on Github at https://github.com/aeonSolutions

如果您想进一步了解我的工作并访问一些编程代码,可以随时在https://github.com/aeonSolutions上查看我在Github上托管的开源代码。

The repository is part of an open-source platform in .Net that aims to speed up deployment of Cloud Windows Apps and with a sleek User Interface. Its a modular platform kit built around PlugIns, widgets, and Packages.

该存储库是.Net开源平台的一部分,该平台旨在通过流畅的用户界面加快Cloud Windows Apps的部署。 它是一个基于PlugIns,widgetPackages构建的模块化平台套件。

翻译自: https://medium.com/@mtpsilva/a-coders-mastery-of-abstraction-9143b59c403f

抽象类抽象变量

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值