为什么程序员的脾气都很大_脾气暴躁的程序员的测试包:评论

为什么程序员的脾气都很大

After having gotten some constructive feedback regarding my testing practices on the basic TDD in your new PHP package tutorial, I decided to read Chris Hartjes “Grumpy Testing Bundle”, a set of two books consisting of The Grumpy Programmer’s Guide To Building Testable PHP Applications and The Grumpy Programmer’s PHPUnit Cookbook. It was my hope that those books will prevent me from using the shoddy practices I displayed in that original post and which originally prompted Matthew Weier O’Phinney’s critique. In this post, I’d like to share with you what I’ve learned, and how much this helped me, if at all.

在您的新PHP软件包教程中获得了有关基本TDD上我的测试实践的建设性反馈之后,我决定阅读Chris Hartjes的“ Grumpy Testing Bundle” ,这本由两本书组成的书,由《 Grumpy程序员构建可测试PHP应用程序指南》和《 脾气暴躁的程序员PHPUnit Cookbook 。 我希望这些书能阻止我使用我在原始帖子中显示的卑鄙做法,并最初引起了Matthew Weier O'Phinney的批评。 在这篇文章中,我想与大家分享我所学到的东西,以及这对我有多大帮助。

脾气暴躁的程序员指南,用于构建可测试PHP应用程序 (The Grumpy Programmer’s Guide To Building Testable PHP Applications)

alt

The first thing I noticed when opening the book was the low page count. For a hefty $20, one would expect more than 68 pages (including dedication, intro, ToC, etc). One shouldn’t judge a book by its cover (or page count), though, so I dove in enthusiastically, disregarding this.

打开书时,我注意到的第一件事是页数低。 一笔20美元的巨额费用,可能会超过68页(包括奉献,简介,目录等)。 但是,不应以封面(或页数)来判断一本书,所以我满腔热情地忽略了这一点。

The book has a total of 15 chapters, and only really starts in chapter 7. If you just read Peter’s tutorial on code analysis tools and are familiar with environment isolation like Vagrant (e.g. our Homestead Improved box), you can skip right to it, as those are the only topics the author touches on in those first 22 pages. Unfortunately, it all goes downhill from there due to the severe outdatedness.

这本书共有15章,只有第7章才真正开始。如果您只是阅读Peter的代码分析工具教程,并且熟悉像Vagrant这样的环境隔离(例如我们的Homestead Improvement框),则可以直接跳到该章节,因为这是作者在前22页中涉及的唯一主题。 不幸的是,由于严重的过时,一切都从那里走下坡路。

  • the author mentions PHPUnit and its installation via PEAR, when this is no longer supported. This would confuse new readers unfamiliar with the situation. In fact, I call to all PHP authors and developers to openly dismiss PEAR as a relic of the past not to be used for any purpose whatsoever any more. If you have PEAR instructions in your blog posts or books, please, update your materials to use Composer.

    不再支持 PHPUnit及其通过PEAR进行安装时,作者会提到。 这会使不熟悉这种情况的新读者感到困惑。 实际上,我呼吁所有PHP作者和开发人员公开将PEAR视为过去的遗物,不再将其用于任何目的。 如果您的博客文章或书籍中有PEAR说明,请更新您的资料以使用Composer。

  • the author mentions the application we’ll be using is on OS X of a specific version, but then continues to talk about VMs and mentions Vagrant. This calls into question the necessity of even mentioning the original setup, as it’s just plain confusing to users of other operating systems, and should be entirely irrelevant if VM-powered best practices are to be advocated.

    作者提到我们将在特定版本的OS X上使用的应用程序,但随后继续谈论VM并提到了Vagrant。 这使人质疑甚至提到原始设置的必要性,因为它对其他操作系统的用户来说是很容易混淆的,并且如果提倡基于VM的最佳实践应该完全不相关。
  • the author makes references to issues of Vagrant instability but this is no longer the case – Vagrant has been stable and problem free for a while now, and temporary bugs shouldn’t be pointed out so prominently as they tend to lose relevancy quickly.

    作者提到了Vagrant不稳定的问题,但现在不再如此了-Vagrant稳定了一段时间了,而且没有问题,并且不应过分指出临时错误,因为它们往往很快失去相关性。
  • at one point, the Phix project was mentioned which, at its prime, was an admirable pre-Composer guide on creating shareable components. Composer rendered it obsolete and the site will be shutting down soon, so references to it should reflect that

    有一次,有人提到了Phix项目,该项目在最初阶段是令人敬佩的Pre-Composer创建共享组件指南。 Composer使它过时了,该站点将很快关闭 ,因此对此的引用应反映出

  • some links are dead, too, like http://framework.zend.com/manual/en/zend.dom.query.html. Ignoring the fact that there are better components suited for the task of DOM traversal today, an author without an official editor and publishing house should always maintain a list of links in a given piece of published for-profit writing and keep them up to date

    某些链接也已失效,例如http://framework.zend.com/manual/en/zend.dom.query.html 。 忽略今天有更好的组件适合进行DOM遍历的事实,没有正式编辑和出版社的作者应始终维护给定已发布的营利性著作中的链接列表,并保持其最新状态。

In the chapters that follow, the code examples are few and far inbetween, but those that are there are well constructed and help illustrate the importance of SOLID principles in developing testable apps – the main purpose of the book, of course. One gripe I have with the examples is that they aren’t sufficiently explained and often need referring to the PHPUnit docs. For example, the code:

在随后的各章中,代码示例很少而且相隔甚远,但是其中的代码示例结构合理,可以帮助说明SOLID原则在开发可测试应用程序中的重要性,这当然是本书的主要目的。 我对这些示例的一个抱怨是,对它们的解释不够充分,常常需要参考PHPUnit文档。 例如,代码:

// Create a mock object
$testRequest = $this-> getMock(
	'\Grumpy\Request' ,
	array( 'getUri' )
);
	
// Create our test response
$testRequest
	-> expects()
	-> method( 'getUri' )
	-> with( '/dashboard' );

… while technically sound, is not dissected. Finding out what the expects, method and with methods do requires a visit to the documentation, and this breaks the smooth reading flow and reduces confidence in people unfamiliar with PHPUnit by inducing a feeling of “Should I already understand this? Why don’t I?”

…虽然技术上合理,但并未剖析。 找出什么expectsmethodwith方法都需要对文档进行访问,这断一气呵成流量,并减少通过诱导的感觉在人们的信心不熟悉PHPUnit“我应该已经明白这一点? 我为什么不呢?”

Some parts, on the other hand, are very well demonstrated and described. The particular case of mocking a Facebook Connect provider sheds some light on the concept of easy mocking and not having to depend on outside resources better than the official docs of PHPUnit do.

另一方面,对某些部分进行了很好的演示和描述。 模拟Facebook Connect提供程序的特殊情况阐明了简单模拟的概念,并且不必像PHPUnit的官方文档那样更好地依赖外部资源。

Like many other materials in book or conference-talk form today, SOLID principles are advocated throughout the two to three following chapters, and the vast majority of the content will be (over)familiar to you if you’re even the least bit aware of what SOLID stands for. Read Alejandro Gervasio’s absolutely amazing tutorials (I’ve yet to find better and more down-to-earth explanations of SOLID concepts than his) and another chunk of the book (and not just this book!) becomes obsolete fast.

就像今天许多书本或会议演讲形式的其他材料一样,在接下来的两到三章中,我们都提倡SOLID原则,并且,即使您最不了解的内容,绝大多数内容也都是您(不熟悉)的。 SOLID代表什么。 阅读Alejandro Gervasio的绝对惊人的教程 (我还没有找到比SOLID概念更好,更扎实的解释),而本书的另一大部分(而不仅仅是这本书!)很快就过时了。

Then comes the abrupt ending of the book. I say ending because the chapters become republished blog posts starting with chapter 9. A book that was last updated in 2013 and originally published in 2012 must not quote unaltered resources 5-6 years old. That’s simply unacceptable:

然后这本书突然结束了。 我之所以说结束,是因为这些章节从第9章开始成为重新发布的博客文章。最近更新于2013年,最初于2012年出版的书籍不得引用5-6岁的未更改资源。 那简直是不可接受的:

  • with the advent of tools like http://psysh.org/, chapter 9, a copy of this 5 year old blog post, seems obsolete.

    随着诸如http://psysh.org/之类的工具的出现,第9章, 这本已有5年历史的博客文章的副本,似乎已经过时了。

  • chapter 10 is a copy of this old blog post. Its relevance in this book is questionable.

    第10章是此旧博客文章的副本。 它在本书中的相关性值得怀疑。

  • chapter 11 is a repost of this post which is, again, 5 years old and completely obsolete. For up to date CI solutions in the PHP world, just refer to these tutorials.

    第11章是该帖子的改版,它已经有5年历史了,已经完全过时了。 有关PHP世界中最新的CI解决方案,请参考这些教程

  • chapter 12, another repost of a blog post I could not find, talks about infrastructure debt – the art of moving away from personal dev environments and into VM waters for unified environments for the entire team. This topic has been mentioned in a shorter and more effective form in the beginning chapters of the book, so why it bears repeating is unknown.

    第12章,我找不到的博客文章的另一篇转贴,谈到了基础设施债务–从个人开发环境转移到整个团队的统一环境的VM水域的艺术。 在本书开始的各章中,以更短,更有效的形式提到了这个主题,因此,为什么它会重复是个未知数。
  • chapter 13 talks about the fear of change, a valid deterrent in upgrading. This is a good post, but would be better suited as the book’s introduction.

    第十三章谈到了对改变的恐惧,这是升级的有效威慑。 这是一篇不错的文章,但更适合作为本书的简介。
  • a bona fide slap in the face, chapter 14 is almost a whopping 7 years old. While the author’s disclaimer mentions that the content is still relevant, I can assure you it isn’t, in any way. It talks of severely outdated framework versions that have lost all relevance today (the versions of CakePHP and CodeIgniter the book refers to are obsolete, ZF1, as bad as it was, was replaced by the anti-pattern plagued ZF2, and Symfony has changed its architecture completely since then).

    第14章真是耳熟能详,却快7岁了。 尽管作者的免责声明提到内容仍然相关,但我可以以任何方式向您保证它与内容无关。 它谈到了严重过时的框架版本,这些版本今天已经失去了所有的意义(本书所指的CakePHP和CodeIgniter的版本已过时,ZF1的确很糟糕,已被受到反模式困扰的ZF2取代,Symfony更改了其版本。从那时起就完全没有体系结构)。

In the outro, Chris says “I know there is a lot of stuff in this guide for you to consider.” but … there really isn’t. Books as outdated as this should be rewritten completely, their old content reworked to better fit into today’s context, and new editions should be published. That’s what new editions are for, after all.

克里斯说: “我知道本指南中有很多内容可供您考虑。” 但是……确实没有。 应该完全重写已经过时的书籍,对它们的旧内容进行重新整理以更好地适应当今的情况,并应出版新版本。 毕竟,这就是新版本的用途。

Due to the limited amount of new knowledge absorbed by reading this short book, its low page count considering the price – especially considering you’re paying for two and a half chapters instead of 15 in this book, as it only properly starts in chapter 7 and ends in chapter 9 with the beginning of the blog copies – the occasional typos indicating the lack of an expert English editor, and its outdatedness, I give it a 1/5 and cannot recommend you purchase it.

由于阅读这本简短的书籍所吸收的新知识数量有限,考虑到价格,它的页面数很少-特别是考虑到您要花两半半的篇幅代替本书中的十五篇,因为它仅从第7章开始并在第9章以博客副本的开头结尾–偶尔的错别字表示缺少专业的英语编辑,并且它的过时了,我给它打1/5,因此不建议您购买。

I consider Modernizing Legacy Applications in PHP a much better reference to building testable PHP applications, because it takes a hands-on approach and covers testing alongside all other fixes and best practices. It’s more expensive, but well worth it.

我认为在PHP中更新旧版应用程序是构建可测试PHP应用程序的更好参考,因为它采用了动手方法,并且涵盖了测试以及所有其他修补程序和最佳实践。 它更昂贵,但值得。

alt

脾气暴躁的程序员PHPUnit食谱 (The Grumpy Programmer’s PHPUnit Cookbook)

Disappointed, I moved on to the second part of the bundle.

失望的是,我继续进行捆绑的第二部分。

alt

After an excellent foreword by Justin Searls, the first 22 pages of this book are a breath of fresh air. Already in this short segment one has learned more than in the entire first book – various options for running different types of tests and producing different output, fistfuls of good advice, and generally things that PHPUnit’s endless and intimidating documentation doesn’t make easy on newcomers.

在贾斯汀·塞尔斯(Justin Searls)撰写了精彩的序言之后,本书的前22页充满了新鲜空气。 在这短暂的一小段时间里,您已经学到了比整本书更全面的知识–用于运行不同类型的测试和产生不同输出的各种选项,大量好的建议,以及一般而言,PHPUnit的无尽而令人生畏的文档对新手来说并不容易。

While I would have preferred the code samples to be more real-world rather than foos and bars, the mocks and stubs are well explained, their sub-types defined (spies and dummies!), and example use cases presented. In the Test Doubles chapter alone I went from an attitude of “Why would I use a mock when I can just use the real class” to “Ok, I’m not going to use real classes any more”. The chapter on Data Providers was as brief as one could make it, yet it explained some things I never knew in under 10 minutes – had I read it before writing the post I mentioned in the introductory paragraph of this review, I would have avoided Matthew’s scorn :)

尽管我希望代码示例比foos和bars更真实,但它们会很好地解释了模拟和存根,定义了子类型(间谍和虚拟人!)以及示例用例。 仅在“测试双打”一章中,我就从“为什么只可以使用真实类时为什么要使用模拟游戏”变成了“好吧,我不再使用真实类”。 关于数据提供者的章节虽然简短,却能解释我在不到10分钟的时间内所不知道的一些内容–如果在撰写本评论的介绍性段落中提到的帖子之前先阅读了该内容,那我就可以避免Matthew的轻蔑:)

The book is far from perfect and has its downsides. Once again, there are slightly outdated installation instructions. PEAR is again mentioned with Composer’s somewhat outdated approach in the forefront. This entire part can be reworked into a single paragraph where PHPUnit is in a composer.json’s “require-dev” block, though given the audience it’s questionable whether or not we actually need any installation instructions at all – the book is aimed at people who are already interested in PHPUnit and thereby are probably already using it. Removing installation instructions altogether would increase the longevity of the book while focusing on the target content sooner.

这本书远非完美,也有缺点。 再次,有一些过时的安装说明。 在Composer的过时方法中,PEAR再次被提到前列。 整个部分都可以修改为一个单独的段落,其中PHPUnit位于composer.json的“ require-dev”块中,尽管给听众带来了疑问,我们是否真的需要任何安装说明,该书的目的是已经对PHPUnit感兴趣并因此可能已经在使用它的人。 完全删除安装说明将增加本书的使用寿命,同时将注意力集中在目标内容上。

Likewise, the book needs updating to the most recent PHPUnit version where, for example, there is no longer a “getObjectForTrait” but this.

同样,该书需要更新到最新PHPUnit版本,例如,在该版本中不再有“ getObjectForTrait”,而是this

As in the previous book, links need updating and there are also some spelling (“Testing API’s”) and formatting errors in the book, indicating again the lack of a technical editor, but nothing major:

与上一本书一样,链接需要更新,并且书中还存在一些拼写(“测试API”)和格式错误,这再次表明缺少技术编辑器,但没有什么主要的:

alt
alt

All in all, the downsides I mention are nitpicking – the second book is an excellent user guide to PHPUnit, and I’m actually excited to go forth and test, test, test. 3.5/5 – would have been 4.5/5 if the above issues weren’t present.

总而言之,我提到的缺点是挑剔的-第二本书是PHPUnit的优秀用户指南,而我真的很高兴继续进行测试,测试和测试。 3.5 / 5 –如果上述问题不存在,则为4.5 / 5。

alt

结论 (Conclusion)

As a sum of its parts, the bundle disappoints. The first book was a complete miss, but I do like and intend to continue using the second one as a future reference, particularly if updated. It’s just sad to see, once again, the lack of quality in Leanpub publications. People who are not formally trained in passing on knowledge often refuse to admit they need professional help and ask friends, colleagues and family for reviews and opinions – this is a horrible idea. What’s needed is an unbiased professional who can give it to you straight, correct your errors in some cases and point out missed marks in other cases. Outdated instructions are one thing, and the sole responsibility of the author, but technical errors, dead links and formatting issues are all easily fixable in the modern publishing world, and there are no excuses for them – in blog posts or books.

总的来说,捆绑包令人失望。 第一本书简直是一本完整的书,但我确实喜欢并打算继续使用第二本书作为将来的参考,尤其是如果对其进行了更新。 这只是伤心地看到,再次,在Leanpub出版物缺乏质量。 未经正式的知识传授培训的人常常拒绝承认他们需要专业帮助,并向朋友,同事和家人征求评论和意见,这是一个可怕的想法。 我们需要的是公正的专业人员,可以直截了当地给您,在某些情况下更正您的错误,在其他情况下指出遗漏的标记。 过时的说明是一回事,是作者的全部责任,但是技术错误,无效链接和格式问题在现代出版界都可以轻松修复,并且没有任何借口–在博客文章或书籍中。

For example, there is an easy fix for dead links. Direct links in your book to shortened forms, and change the endpoints of shortened links when updating is required. No need to republish your book that way, then. For example – a link that says “latest documentation” but leads to the docs of PHPUnit 3.7 is far from latest. However, if you make it point to something like http://grm.py/phpunit_assertdoc_latest, all you need to do is alter the ultimate destination on the link and you’re all set, indefinitely. You can even set a reminder for yourself to check the links every 6 months – it shouldn’t take more than an hour when they’re all in one place, easily updateable.

例如,有一个容易解决的死链接。 将书中的链接直接链接到简化形式,并在需要更新时更改简化链接的端点。 那就不需要那样重新出版你的书了。 例如,一个指向“最新文档”但指向PHPUnit 3.7文档的链接距离最近。 但是,如果您指向http://grm.py/phpunit_assertdoc_latest东西,您要做的就是更改链接上的最终目标,并且已经无限期地进行了设置。 您甚至可以为自己设置一个提醒,每6个月检查一次链接-将它们全部集中在一个位置,并且很容易更新,不超过一个小时。

All in all, I’d recommend getting the PHPUnit Cookbook if you find it on a discount – but until it gets some love from the author and is refreshed, paying full price for it just isn’t worth it. Go read Modernizing Legacy Applications in PHP instead – you’ll learn more on real, memorable examples.

总而言之,如果您能以折扣价找到PHPUnit Cookbook,我建议您获得它-但是,直到它得到作者的爱戴并得到刷新之前,为此付出全部代价是不值得的。 请改为阅读用PHP现代化旧版应用程序 -您将了解有关真实,令人难忘的示例的更多信息。

翻译自: https://www.sitepoint.com/grumpy-programmers-testing-bundle-review/

为什么程序员的脾气都很大

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值