过早优化是万恶之源
Has something like this ever happened to you?
发生过类似的事情吗?
You go on a website, and there’s a spinner which loads forever, or an empty screen that forces you to stare. There’s a disabled button that never enables, or a page that drains your battery only for the phone to die in the most inconvenient circumstances.
您进入一个网站,有一个旋转器永久加载,或者一个空白屏幕迫使您凝视。 有一个禁用按钮永远不会启用,或者一个页面会耗尽您的电池电量,以使手机在最不方便的情况下死机。
The software we use today doesn’t work; many of the causes boil down to specialisation.
我们今天使用的软件无法使用 ; 许多原因归结为专业化。
One day, my colleague was refactoring the Big Ball of Mud inside of one of the many API services of their company. Initially, the members of his team were very defensive regarding his approach, so he paired with another colleague to craft a “proof of concept”. After he showcased the POC, the team was impressed. They liked the outcome and agreed that the changes should go to production.
有一天,我的同事正在其公司的众多API服务之一中重构“ 泥泞的大球” 。 最初,他的团队成员对他的方法非常防御,因此他与另一位同事配对以制作“概念证明”。 在他展示POC之后,团队印象深刻。 他们喜欢结果,并同意将更改付诸实践。
The software of his company was serving thousands of users simultaneously around the clock. There were 3 kinds of UI front-ends: the iOS app, the Web app, and the Android app.
他公司的软件全天候为数千名用户提供服务。 UI前端共有3种:iOS应用程序,Web应用程序和Android应用程序。
Everything went fine as the “DevOps Team” deployed the back-end change to production. However, minutes later, customers were unable to login to the iOS app. The Call Center was bombarded with a significant number of angry customers. Everybody was confused, but there were no doubts about what was the cause: the refactoring which had deployed was locking customers out.
随着“ DevOps团队”将后端变更部署到生产中,一切都进行得很好。 但是,几分钟后,客户无法登录到iOS应用程序。 呼叫中心遭到大量生气客户的轰炸。 每个人都感到困惑,但是毫无疑问是什么原因:部署的重构将客户拒之门外。
So what caused the breakage?
那是什么造成了破损呢?
The back-end API and the mobile front-end had an implicit contract. The back-end should return strings in a specific format so that the iOS app would interpret individual tokens from that format as variables. At runtime, clients would replace those variables with some data they had cached. The developers couldn’t observe the problem in any of the end-to-end tests, as the authentication mechanism for the test accounts didn’t require those tokens to be there.
后端API和移动前端具有隐式合同。 后端应以特定格式返回字符串,以便iOS应用将该格式中的各个标记解释为变量。 在运行时,客户端将用已缓存的某些数据替换这些变量。 开发人员无法在任何端到端测试中观察到该问题,因为测试帐户的身份验证机制不需要这些令牌就可以了。
There was no documentation for that functionality. The string format was only consumed by the iOS app, not by any of the other API clients.
没有关于该功能的文档。 字符串格式仅由iOS应用使用,而没有由任何其他API客户端使用。
One of the three front-end clients depended upon a specific string format of a specific server for their login mechanism to work.
三个前端客户端之一依赖于特定服务器的特定字符串格式来使其登录机制起作用。
The company had organised the teams by technology. Each of them was responsible for one client. There was the “iOS Team” owning the iOS app, the “Android Team” owning the Android app, the “Web Team” owning the Web app, and the “Back End Team” owning the API service. Many of the artefacts each of those teams produced had repeated business logic. That means changes in one application would require a developer to touch three to five different repositories to get the work done.
该公司通过技术组织了团队。 他们每个人负责一个客户。 拥有iOS应用的“ iOS团队”,拥有Android应用的“ Android团队”,拥有Web应用的“ Web团队”和拥有API服务的“后端团队”。 每个团队制作的许多人工制品都具有重复的业务逻辑。 这意味着在一个应用程序中进行更改将需要开发人员接触三到五个不同的存储库才能完成工作。
Thanks to the developer turnover rate in the department and the lack of documentation, the team who owned the relevant back-end service had no idea the iOS team was consuming such string format in production. The only way they found out they didn’t have control of their software was after refactoring a critical part of the service, deploying it to production and locking customers out of their accounts.
由于部门中开发人员的离职率和缺乏文档,拥有相关后端服务的团队不知道iOS团队正在生产中使用这种字符串格式。 他们发现自己无法控制软件的唯一方法是在重构了服务的关键部分,将其部署到生产环境并将客户拒之门外之后。
Product development worked like this: the feature started from the User Interface — web or mobile, and then each client had the responsibility to change as many services as they needed to get their work done. The company had multiple teams responsible for implementing similar UI functionality without clear boundaries of who owns what. Each developer was very comfortable with their stack, unwilling to discuss ideas with developers working with other technologies.
产品开发的工作方式是这样的:该功能从Web或移动用户界面开始,然后每个客户都有责任更改完成工作所需的任意数量的服务。 该公司有多个团队负责实施相似的UI功能,而没有明确界定谁拥有什么的界限。 每个开发人员都非常满意自己的堆栈,不愿意与使用其他技术的开发人员讨论想法。
The communication cost for the development of a single feature was so high that each client ended up reinventing their own business rules within their apps. The back-end service ended up becoming a database over HTTP where every system had a direct dependency on it.
开发单个功能的通信成本非常高,以至于每个客户最终都在自己的应用程序中重新制定了自己的业务规则。 后端服务最终成为通过HTTP的数据库,每个系统都直接依赖于该数据库。
The effort to ship features in that company was significantly high; psychological safety was deficient. Everyone involved had all the incentives to produce software in big batches instead of incrementally.
该公司在发布功能方面付出了巨大的努力; 心理安全性不足。 涉及每个人把所有的激励机制在生产软件大批量 ,而不是增量 。
It was a tragedy waiting to happen.
这是一场悲剧,等待发生。
The segregation of people with “Front-End” skills from people with “Back-End” skills had a significant impact on the communication between teams.
具有“前端”技能的人员与具有“后端”技能的人员的隔离对团队之间的沟通产生了重大影响。
Unless you looked from the outside, it was hard to see how the skill segregation was slowing down the software development process. Everybody was delivering their “part” of the job quickly and efficiently. The “other team” was always the problem.
除非您从外部观察,否则很难看到技能隔离如何减慢了软件开发过程。 每个人都在快速,高效地完成工作的“一部分”。 “其他团队”一直是问题所在。
The most straightforward solution to this is to consider the need for “The Architect” — that person sitting in the Ivory Tower dictating what should and should not be. Be careful! “The Architect” may be the right pill to treat the symptom, but it won’t cure the disease. It’s everyone’s job to understand the big picture. How do you expect to work with a purpose if you don’t understand what that overall purpose is?
最直接的解决方案是考虑是否需要“建筑师”,即坐在象牙塔中的人决定应该和不应该做的事情。 小心! “建筑师”也许是治疗症状的正确药丸,但不能治愈这种疾病。 了解全局是每个人的工作。 如果您不了解总体目标是什么,您期望如何实现目标?
“The Architect”, if you must, should be a facilitator rather than a dictator. They should mentor the other developers on how to spot the big picture to ask the right questions.
如果需要,“建筑师”应该是促进者而不是独裁者。 他们应该指导其他开发人员如何发现全局问题 , 提出正确的问题 。
This story happened within a major financial institution that was too big to fail. It didn’t matter how slow they were: as long as the existing system continued producing millions of dollars of revenue, there was no incentive for them to change — technological stagnation at its best.
这个故事发生在一家大型金融机构中,规模太大,无法倒闭。 速度有多慢也没关系:只要现有系统继续产生数百万美元的收入,就没有动力促使他们做出改变-技术停滞处于最佳状态。
They were the lucky ones. Their software was generating enough revenue to outweigh all the costs for the design of new features.
他们是幸运者。 他们的软件产生了足够的收入,超过了设计新功能的所有成本。
However, your company probably won’t be as lucky as them.
但是,您的公司可能不会像他们那样幸运。
Nowadays, it’s prevalent for developers to follow the technical path of major successful organisations. However, that doesn’t mean their path also works for you. There are many reasons why major tech companies have reached their state of success, many of them unrelated to technical excellence.
如今,对于开发人员而言,遵循主要成功组织的技术道路已十分普遍。 但是,这并不意味着他们的道路也对您有用。 大型科技公司取得成功的原因有很多,其中许多与卓越技术无关。
If the software works and the company is too big to fail, then it’s hard to push any change. However, if you’re not too big to fail, then you better act. Fast.
如果软件能够正常运行,并且公司太大而无法倒闭,那么很难推动任何改变。 但是,如果您不是太大而不能失败,那么您最好采取行动。 快速。
The idea of specialisation comes from the traditional mindset of a manual a production line. There are people positioned at different stages of the ramp, each responsible for constructing different parts of the product. Maybe that works for a production line, but it doesn’t work for an intellectually demanding task like software development.
专业化的想法来自手工生产线的传统观念。 有些人位于坡道的不同阶段,每个人负责构造产品的不同部分。 也许这适用于生产线,但不适用于诸如软件开发之类的智力要求很高的任务。
Nowadays, specialisation seems to be the root of the most significant communication problems among software teams and their shift in culture. It doesn’t matter if you’re the best “iOS” developer or “React” developer in the world. If you can’t solve a problem that spans across multiple stacks, either by doing it yourself or pairing with those who know more than you in that area, then it’s harder to justify the value you’re bringing into the table. Pushing work over the wall to “the other team” doesn’t work, you have to own it to the end.
如今,专业化似乎已成为软件团队之间最重大的沟通问题及其文化转变的根源。 您是世界上最好的“ iOS”开发人员还是“ React”开发人员都没有关系。 如果您无法解决跨多个堆栈的问题,无论是您自己解决问题,还是与在该领域中比您了解更多的人结成对子,那么很难证明您要带入表格的价值。 将工作推到“另一个团队”是行不通的,您必须拥有它直到最后。
That doesn’t mean everyone should be the “Jack of all trades, master of none”.
这并不意味着每个人都应该成为“万事通,无精打采”。
Here’s the trick:
这是窍门:
The best programmers I’ve met prioritise learning fundamentals and techniques, not technologies. They learn the trade-off of those techniques even before they understand the details of how to apply them using the tools they have. When they face a situation where one of those techniques makes sense, that’s when they invest the time to research and look up the details of how to apply them.
我遇到的最好的程序员优先考虑学习基础知识和技术,而不是技术。 他们甚至在了解如何使用现有工具应用这些技术的细节之前就已经学会了权衡这些技术。 当他们面对其中一种技术有意义的情况时,那就是他们投入时间进行研究并查找如何应用这些技术的细节。
Learn fundamentals, not technologies. That's how you prevent becoming specialized in one thing while not having to understand everything.
学习基础知识,而不是技术。 这样一来,您不必了解所有内容就可以避免专注于一件事。
It’s impossible to know everything; you optimise to learn what the options are so that you can dig deeper when necessary.
不可能一无所知。 您可以进行优化以了解选项是什么,以便在必要时可以进行更深入的研究。
So what are you going to do?
你接下来打算怎么办?
Are you going to follow the trend of big companies and hire that great “React Developer” which is also a great “C# Developer” and “CS Guru”? Or are you going to work towards hiring that “Software Developer” who regardless of the programming language, understands the basics about architecture, software design, and other areas?
您是否要顺应大公司的趋势,并聘请出色的“ React Developer”(同时也是出色的“ C#Developer”和“ CS Guru”)? 还是您将努力聘请“软件开发人员”,无论该编程语言是什么,他们都了解有关体系结构,软件设计和其他领域的基础知识?
It’s time to look at software as an essential part of our lives and start to apply things that work, not to repeat the same thing over and over again, expecting different results. Specialisation creates silos; broad knowledge-sharing creates opportunities.
现在是时候将软件视为我们生活中必不可少的一部分,并开始应用有效的东西,而不是一遍又一遍地重复同一件事,以期获得不同的结果 。 专业化会产生孤岛; 广泛的知识共享创造了机会。
Don’t be like that tribe, waiting for the planes that’ll never come.
不要像那个部落那样 ,等待永远不会来的飞机。
You’ll be waiting for a long, long time.
您将等待很长一段时间。
Thanks for reading. If you have some feedback, reach out to me on Twitter, Facebook or Github.
谢谢阅读。 如果您有任何反馈意见,请通过Twitter , Facebook或Github与我联系。
翻译自: https://medium.com/@fagnerbrack/specialisation-is-the-root-of-all-evil-b9079d718bea
过早优化是万恶之源