博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 类型约束_PHP中的约束理论
阅读量:2510 次
发布时间:2019-05-11

本文共 8454 字,大约阅读时间需要 28 分钟。

php 类型约束

The post “The Theory of Constraints in PHP” is the editorial for the PHP Channel’s newsletter on July 11th. To stay on top of PHP news, posts, and relevant links, make sure to keep up to date .

“ PHP的约束理论”一文是7月11日PHP频道新闻通讯的社论。 要掌握PHP新闻,帖子和相关链接,请确保在保持最新。



I had been reading , a great novel about IT (you read that right), which presents day to day IT and devops problems at a large Amazon-like company in a way which makes mortals understand the complexities and chaos of 21st century technology.

我一直在读 ,这是一本有关IT的伟大小说(您没看错),该书每天介绍IT知识,并在一家类似亚马逊的大型公司中处理问题,以使凡人了解21世纪的复杂性和混乱状况技术。

Without giving away any spoilers, at one point in the book the Theory of Constraints is mentioned. As per Wikipedia:

在不放弃任何破坏的前提下,本书中提到了约束理论。 根据维基百科:

The Theory of Constraints (TOC) is a management paradigm that views any manageable system as being limited in achieving more of its goals by a very small number of constraints. There is always at least one constraint, and TOC uses a focusing process to identify the constraint and restructure the rest of the organization around it.

约束理论(TOC)是一种管理范式,它认为任何可管理的系统都受极少数约束的限制,无法实现其更多目标。 总有至少一个约束条件,TOC使用聚焦过程来识别约束条件并围绕该约束条件重组组织的其余部分。

The Theory of Constraints can be distilled to the idea that the chain is only as strong as its weakest link.

约束理论可以提炼为这样一种观点,即链条的强度与其最薄弱的环节一样强

Chain with weak link

In the book it was phrased thusly:

在书中它的措辞是这样的:

Any improvements made anywhere besides the bottleneck are an illusion.

除瓶颈以外的任何地方的任何改进都是一种幻想。

For some reason, this resonated with me much more than the chain idiom. There’s just something about building something that’s ineffective that’s more relatable to me than breaking something that’s weakly built.

由于某种原因,这比连锁成语更能引起我的共鸣。 关于构建无效东西,破坏脆弱的东西相比,对我来说更有意义。

工厂和浏览器 (Factories and Browsers)

As (initially) presented in the book and slightly dumbed down here, a factory floor was seeing a pile-up of work orders at one desk, with other areas of the factory working somewhat satisfactorily. Without working on optimizing this one desk’s throughput and by (either coincidentally or intentionally) upgrading the process that precedes or supersedes it, the factory became clogged with work because the former lead to a stack of products before the desk that had no destination, and the latter lead to idle workers at the other end of the facility, waiting for the products to reach them for shipping, but all stuck in slow processing at the central desk.

正如(最初)在书中介绍的那样,这里有些呆板,工厂车间的一个工作台上堆积着许多工作指令,而工厂的其他区域则工作得令人满意。 如果不致力于优化一张办公桌的生产量并且不通过(偶然地或有意地)升级之前或取代它的流程,工厂就会被工作所困扰,因为前者导致了没有目的地的办公桌的一堆产品,并且后者导致设施另一端的闲置工人等待产品运到他们那里,但是全部滞留在中央服务台的缓慢处理中。

Pile of paperwork on desk

To go off on a slight tangent here – if you follow me on Twitter, you know I like to . I especially lose it when they put in updates like but fail to address the decade old RAM use problem. Some people are quick to address this as an , but I disagree. While, yes, this is an appeal to a worse problem, I don’t see it as fallacy – rather, I see it as a lack of identified constraints on Google’s part. As a company, they of what’s in need of optimization, or are devoid of resources to dedicate to the fixing of this problem (not sure which is worse). So we have all these “improvements” made outside the bottleneck, driving power users mad and resulting in attempts at revamping the browser by slapping another skin on it (Vivaldi, Brave, Opera, Ghost…), but unable to make progress because, again, the bottleneck remains. If you move the desk and the whole factory setup from one building to the next, the desk is still the problem. Fix the desk.

要在这里稍加切线-如果您在Twitter上关注我,您知道我喜欢 。 当他们进行类的更新但无法解决已有十年历史的RAM使用问题时,我尤其会丢失它。 有些人很快就解决了这一 ,但我不同意。 是的,这是一个更严重问题的诉求,但我不认为这是谬论–相反,我认为这是Google 缺乏确定的约束 。 作为一家公司,他们不知道需要优化的内容,或者没有足够的资源来解决此问题(不确定哪个更糟)。 因此,我们在瓶颈之外进行了所有这些“改进”,使高级用户发狂,并尝试通过在浏览器上打上另一种皮肤(Vivaldi,Brave,Opera,Ghost等)来尝试修改浏览器,但是却无法取得进展,因为再次,瓶颈仍然存在。 如果将办公桌和整个工厂设置从一栋楼移到另一栋楼,办公桌仍然是问题所在。 固定桌子。

PHP约束理论 (Theory of Constraints in PHP)

So how does this apply to web apps? Or, better yet, PHP apps in particular?

那么这如何适用于Web应用程序? 或者,更好的是,特别是PHP应用程序?

These days, it’s really easy to follow this principle and identify the constraint(s). We have so many amazing tools at our disposal that identifying the bottleneck within a few hours is generally a given:

如今,遵循此原理并确定约束条件确实很容易。 我们有许多惊人的工具可供使用,因此通常可以在几个小时内确定瓶颈:

  • will provide you with fantastic in-depth graphs of your application’s execution stack, indicating code bottlenecks with ease. These will include database bottlenecks as well, if executed in the code stack you’re analyzing, making the whole thing infinitely easier to optimize.

    将为您提供有关应用程序执行堆栈的出色深度图,轻松显示代码瓶颈。 如果在您要分析的代码堆栈中执行,这些还将包括数据库瓶颈,从而使整个事情无限地容易优化。

  • Not many people know this, but Xdebug , letting you do that same thing locally!

    很少有人知道这一点,但是Xdebug ,可让您在本地执行相同的操作!

  • There’s a which can help you test your app to bits – super long test times are often indicative of bottlenecks, and pinpointing them there while they’re running on mock data and test examples can be incredibly rewarding.

    有 ,可以帮助您对应用程序进行逐点测试-超长的测试时间通常表明存在瓶颈,而在运行模拟数据和测试示例时将其准确定位会带来令人难以置信的回报。

  • A bit of an oldie but goldie, this set of posts helps you optimize your MySQL once you’ve identified it as a bottleneck..

    这套帖子有点老套但有点古怪 ,一旦发现瓶颈,就可以帮助您优化MySQL。

    But remember that optimizing it just for the sake of optimization isn’t a good idea!

    但是请记住, 仅仅为了优化而优化并不是一个好主意!

  • It helps if you nuke your app with requests, and compare before/after results – it’ll be a clear indicator on much your optimizations boosted the app as a whole. A tool like Siege can help with that, and we have an for just that.

    如果您用请求来推动应用程序并比较结果前后,这将有所帮助–这将清楚地表明您的优化在很大程度上促进了应用程序的整体发展。 诸如Siege之类的工具可以帮助您解决此问题,我们为此提供了 。

The tools above are a good start, but far from exhaustive, and far from applicable to every problem you might run into. Additional articles from this might be useful, but I’m honestly hoping for more diverse examples and links from you! Shoot!

上面的工具是一个很好的开始,但是还不全面,也无法应用于您可能遇到的每个问题。 此其他文章可能会很有用,但老实说,我希望从您那里获得更多样例和链接! 射击!

结论 (Conclusion)

The ToC is a valid concern in software development, and just as applicable as anywhere else. We’ve all encountered bottlenecks, and we’ve all stupidly tried to improve upon anything other than the bottleneck – or if you haven’t fallen into this trap yet, I promise that you will.

ToC是软件开发中的有效关注点,并且与其他任何地方一样适用。 我们都遇到了瓶颈,并且我们都愚蠢地尝试改善瓶颈以外的任何问题–否则,如果您还没有落入这个陷阱,我保证会的。

Luckily, the PHP ecosystem is ripe with tools that help with identifying bottlenecks and turning them into system constraints. If your application is having performance or throughput issues, find the bottleneck, tag it, then drop all other work until the bottleneck has been resolved. Pull critical people off of other tasks, even if it means ignoring incoming unrelated high priority tasks, and have everyone who’s qualified focus on that one problem until it’s resolved. The entire system will thank you for it because, more often than not, that one bottleneck is the reason for those other high priority tickets in the first place. Don’t Brent yourself into a corner! (To understand that reference, you’ll need to read the book)

幸运的是,PHP生态系统已经有了成熟的工具,这些工具可帮助您识别瓶颈并将其转变为系统约束。 如果您的应用程序存在性能或吞吐量问题,请找到瓶颈,对其进行标记,然后放弃所有其他工作,直到解决瓶颈为止。 使关键人员脱离其他任务,即使这意味着忽略传入的无关紧要的高优先级任务,并让有资格的每个人都专注于该问题,直到解决为止。 整个系统将对此表示感谢,因为(通常)一个瓶颈就是那些其他优先级较高的票据首先出现的原因。 不要把自己的布伦特变成一个角落! (要理解该参考,您需要阅读本书)

If you’re flying solo, the same principles apply – as you’re looking at your columns of tasks in Trello, Zenkit, Freedcamp, or another project management tool, identify the bottleneck one, paint it red, and move all others into a column off-screen or one that can be collapsed until the constraint has been resolved and the system remodeled around it. Doing anything less will incur mountains of tech debt that’ll bury you later.

如果您是单人飞行,则遵循相同的原则-在查看Trello,Zenkit,Freedcamp或其他项目管理工具中的任务栏时,找出瓶颈,将其涂成红色,然后将所有其他瓶颈转移到列在屏幕外,或者可以折叠直到解决约束并围绕它重塑系统为止。 少做任何事情都会招致大量的科技债务,这些债务以后会让您埋葬。

How do you find your bottlenecks? Do you remodel the system around the identified constraint, or do you remodel the constraint instead and try to hack your way through it? Which tools/tutorials have I missed in the above list? Let me know in the comments – let’s build a comprehensive list together – and remember: “Improving daily work is even more important than doing daily work“! (Another great quote from the book)

如何找到瓶颈? 您是否围绕已识别的约束对系统进行重塑,还是对约束进行重塑并尝试破解它? 我在上面的列表中错过了哪些工具/教程? 在评论中让我知道–我们一起建立一个全面的列表–并记住: “改善日常工作比做日常工作更为重要 ”! (这本书的另一篇引文)

翻译自:

php 类型约束

转载地址:http://ooegb.baihongyu.com/

你可能感兴趣的文章
JSP九大内置对象及四个作用域
查看>>
ConnectionString 属性尚未初始化
查看>>
数据结构-栈 C和C++的实现
查看>>
MySQL基本命令和常用数据库对象
查看>>
poj 1222 EXTENDED LIGHTS OUT(位运算+枚举)
查看>>
进程和线程概念及原理
查看>>
Lucene、ES好文章
查看>>
android 生命周期
查看>>
jquery--this
查看>>
MySQL 5.1参考手册
查看>>
TensorFlow安装流程(GPU加速)
查看>>
Java基础语法总结
查看>>
这些.NET开源项目你知道吗?让.NET开源来得更加猛烈些吧【转】
查看>>
实现MySQL 用户密码的设置步骤
查看>>
CF961G Partitions
查看>>
弹出层之1:JQuery.Boxy (一)
查看>>
SpringBoot数据库集成-Mybatis
查看>>
CSS 基本语法
查看>>
SQLite清空表并将自增列归零
查看>>
Response.AddHeader
查看>>