rss-parser
Version:
A lightweight RSS parser, for Node and the browser
36 lines • 346 kB
JSON
{
"feed": {
"items": [
{
"title": "Code Health: Providing Context with Commit Messages and Bug Reports",
"link": "http://feedproxy.google.com/~r/blogspot/RLXA/~3/lTnHFI_mRTg/code-health-providing-context-with.html",
"pubDate": "2017-09-11T21:12:45.960Z",
"author": "Google Testing Bloggers",
"content": "<span id=\"docs-internal-guid-96cdc92b-72a3-298c-9f87-daaddf19a3ec\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">This is another post in our </span><a href=\"https://testing.googleblog.com/2017/04/code-health-googles-internal-code.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">Code Health</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> series. A version of this post originally appeared in Google bathrooms worldwide as a Google </span><a href=\"https://testing.googleblog.com/2007/01/introducing-testing-on-toilet.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">Testing on the Toilet</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> episode. You can download a </span><a href=\"https://docs.google.com/document/d/1Ub4xrBA6cyJjJ2bgFL7_VynlvJf423p7UBKIWBRMsnU/edit?usp=sharing\" rel=\"nofollow\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">printer-friendly version</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> to display in your office.</span></span></span><br /><span style=\"background-color: white; color: #222222; font-family: "arial"; font-size: 9.5pt; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"><br /></span><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\">By Chris Lewis</span></span><br /><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\"><br /></span></span><span id=\"docs-internal-guid-7555d281-72b2-27f4-085f-2b65456fdd8c\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"vertical-align: baseline; white-space: pre-wrap;\">You are caught in a trap. Mechanisms whirl around you, but they make no sense. You desperately search the room and find the builder's original plans! The description of the work order that implemented the trap reads, </span><span style=\"font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">\"Miscellaneous fixes.\" </span><span style=\"vertical-align: baseline; white-space: pre-wrap;\">Oh dear.</span></span></span><br /><span style=\"vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\"><br /></span></span><span id=\"docs-internal-guid-7555d281-72b5-7098-346a-238d0acb67ad\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"vertical-align: baseline; white-space: pre-wrap;\">Reading other engineers' code can sometimes feel like an archaeology expedition, full of weird and wonderful statements that are hard to decipher. </span><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">Code is always written with a purpose, but sometimes that purpose is not clear in the code itself.</span></span><span style=\"color: #980000; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"vertical-align: baseline; white-space: pre-wrap;\">You can address this knowledge gap by documenting the context that explains why a change was needed. Code comments provide context, but comments alone sometimes can’t provide enough.</span></span></span><br /><span style=\"vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\"><br /></span></span><span id=\"docs-internal-guid-7555d281-72b5-f9ae-74c8-cbd8e1c6176b\"><span style=\"vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\">There are two key ways to indicate context:</span></span></span><br /><span id=\"docs-internal-guid-7555d281-72b6-2664-d850-c25d5e29af28\"><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\">Commit Messages</span></span></span><br /><br /><ul><li><span style=\"white-space: pre-wrap;\"><b><span id=\"docs-internal-guid-7555d281-72b6-8d7f-0b46-1fa8c7bec68e\" style=\"font-weight: normal;\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"font-weight: 700; vertical-align: baseline;\"><span style=\"color: purple;\">A commit message is one of the easiest, most discoverable</span></span><span style=\"color: #980000; font-weight: 700; vertical-align: baseline;\"> </span><span style=\"vertical-align: baseline;\">means of providing context. When you encounter lines of code that may be unclear, checking the commit message which introduced the code is a great way to gain more insight into what the code is meant to do.</span></span></span></b></span></li><li><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"white-space: pre-wrap;\"><b><span style=\"font-weight: normal;\"><span style=\"vertical-align: baseline;\"><span id=\"docs-internal-guid-7555d281-72b7-48b7-d0de-75b127ea1f1d\"><span style=\"color: purple;\"><span style=\"font-weight: 700; vertical-align: baseline;\">Write the first line of the commit message so it stands alone</span><span style=\"vertical-align: baseline;\">,</span></span><span style=\"color: #980000; vertical-align: baseline;\"> </span><span style=\"vertical-align: baseline;\">as tools like GitHub will display this line in commit listing pages. Stand-alone first lines allow you to </span><span style=\"font-weight: 700; vertical-align: baseline;\"><span style=\"color: purple;\">skim through code history much faster</span></span><span style=\"vertical-align: baseline;\">, quickly building up your understanding of how a source file evolved over time. </span></span></span></span></b></span><span id=\"docs-internal-guid-7555d281-72b7-d872-f4f6-c11333f0669d\"><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">Example:</span><span style=\"color: #980000;\"> </span></span></span> </span> <div style=\"overflow-x: auto;\"><table class=\"my-bordered-table\" style=\"width: 613px;\"><tbody><tr><td style=\"background-color: #cfe2f3; vertical-align: top; width: 607px;\"><pre style=\"background-color: #cfe2f3; border: 0px; color: black; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-top: 0px;\"><span style=\"font-family: "courier new" , "courier" , monospace;\">Add Frobber to the list of available widgets.<br /><br />This allows consumers to easily discover the new Frobber widget and<br />add it to their application.</span></pre></td></tr></tbody></table></div> </li></ul><div><span id=\"docs-internal-guid-7555d281-72b9-5f39-e1a5-055ba3614359\"><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\">Bug Reports</span></span></span></div><div><ul><li><span style=\"white-space: pre-wrap;\"><b><span id=\"docs-internal-guid-7555d281-72b9-bf82-7122-7cdf7b359c2a\" style=\"font-weight: normal;\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"font-weight: 700; vertical-align: baseline;\"><span style=\"color: purple;\">You can use a bug report to track the entire story of a bug/feature/refactoring,</span></span><span style=\"vertical-align: baseline;\"> adding context such as the original problem description, the design discussions between the team, and the commits that are used to solve the problem. This lets you easily see all related commits in one place, and allows others to easily keep track of the status of a particular problem.</span></span></span></b></span></li><li><span style=\"white-space: pre-wrap;\"><b><span style=\"font-weight: normal;\"><span style=\"vertical-align: baseline;\"><span id=\"docs-internal-guid-7555d281-72ba-4b5b-1a53-71238d76987b\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"font-weight: 700; vertical-align: baseline;\"><span style=\"color: purple;\">Most commits should reference a bug report</span></span><span style=\"vertical-align: baseline;\"><span style=\"color: purple;\">.</span> Standalone commits (e.g. one-time cleanups or other small unplanned changes) don't need their own bug report, though, since they often contain all their context within the description and the source changes.</span></span></span></span></span></b></span></li></ul><div><span id=\"docs-internal-guid-7555d281-72ba-7a34-c41b-ae90ca3524c5\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"color: #980000; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">I</span><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">nformative commit messages and bug reports go hand-in-hand,</span></span><span style=\"vertical-align: baseline; white-space: pre-wrap;\"> providing context from different perspectives.</span><span style=\"color: #980000; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"vertical-align: baseline; white-space: pre-wrap;\">Keep in mind that such</span><span style=\"color: #980000; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">context can be useful even to yourself</span></span><span style=\"vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">,</span> providing an easy reminder about the work you did last week, last quarter, or even last year. Future you will thank past you!</span></span></span></div></div><div class=\"feedflare\">\r\n<a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=lTnHFI_mRTg:V6DyzhI_ZR4:yIl2AUoC8zA\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?d=yIl2AUoC8zA\" border=\"0\"></img></a> <a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=lTnHFI_mRTg:V6DyzhI_ZR4:V_sGLiPBpWU\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?i=lTnHFI_mRTg:V6DyzhI_ZR4:V_sGLiPBpWU\" border=\"0\"></img></a>\r\n</div><img src=\"http://feeds.feedburner.com/~r/blogspot/RLXA/~4/lTnHFI_mRTg\" height=\"1\" width=\"1\" alt=\"\"/>",
"contentSnippet": "This is another post in our Code Health series. A version of this post originally appeared in Google bathrooms worldwide as a Google Testing on the Toilet episode. You can download a printer-friendly version to display in your office.By Chris LewisYou are caught in a trap. Mechanisms whirl around you, but they make no sense. You desperately search the room and find the builder's original plans! The description of the work order that implemented the trap reads, \"Miscellaneous fixes.\" Oh dear.Reading other engineers' code can sometimes feel like an archaeology expedition, full of weird and wonderful statements that are hard to decipher. Code is always written with a purpose, but sometimes that purpose is not clear in the code itself. You can address this knowledge gap by documenting the context that explains why a change was needed. Code comments provide context, but comments alone sometimes can’t provide enough.There are two key ways to indicate context:Commit MessagesA commit message is one of the easiest, most discoverable means of providing context. When you encounter lines of code that may be unclear, checking the commit message which introduced the code is a great way to gain more insight into what the code is meant to do.Write the first line of the commit message so it stands alone, as tools like GitHub will display this line in commit listing pages. Stand-alone first lines allow you to skim through code history much faster, quickly building up your understanding of how a source file evolved over time. Example: Add Frobber to the list of available widgets.This allows consumers to easily discover the new Frobber widget andadd it to their application. Bug ReportsYou can use a bug report to track the entire story of a bug/feature/refactoring, adding context such as the original problem description, the design discussions between the team, and the commits that are used to solve the problem. This lets you easily see all related commits in one place, and allows others to easily keep track of the status of a particular problem.Most commits should reference a bug report. Standalone commits (e.g. one-time cleanups or other small unplanned changes) don't need their own bug report, though, since they often contain all their context within the description and the source changes.Informative commit messages and bug reports go hand-in-hand, providing context from different perspectives. Keep in mind that such context can be useful even to yourself, providing an easy reminder about the work you did last week, last quarter, or even last year. Future you will thank past you!",
"id": "tag:blogger.com,1999:blog-15045980.post-8046216467923860328"
},
{
"title": "Code Health: Eliminate YAGNI Smells",
"link": "http://feedproxy.google.com/~r/blogspot/RLXA/~3/zQwgFkJ8VWQ/code-health-eliminate-yagni-smells.html",
"pubDate": "2017-08-14T19:19:32.891Z",
"author": "Google Testing Bloggers",
"content": "<span id=\"docs-internal-guid-2e5aeb06-e1f7-06a6-663b-93c217e243b7\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">This is another post in our </span><a href=\"https://testing.googleblog.com/2017/04/code-health-googles-internal-code.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">Code Health</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> series. A version of this post originally appeared in Google bathrooms worldwide as a Google </span><a href=\"https://testing.googleblog.com/2007/01/introducing-testing-on-toilet.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">Testing on the Toilet</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> episode. You can download a </span><a href=\"https://docs.google.com/document/d/1ZDlgl15g5PHBZssnW_EHktx1gvfud0inVwQ4fmXQrL8/edit?usp=sharing\" rel=\"nofollow\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">printer-friendly version</span></a><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> to display in your office.</span></span></span><br /><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"><br /></span></span><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\">By </span></span><span style=\"color: #222222; font-family: "times" , "times new roman" , serif;\"><span style=\"white-space: pre-wrap;\">Marc Eaddy</span></span><br /><span style=\"color: #222222; font-family: "times" , "times new roman" , serif;\"><span style=\"white-space: pre-wrap;\"><br /></span></span><span id=\"docs-internal-guid-6eaa5349-e1fc-8117-bf44-2d81283878fb\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">The majority of software development costs are due to maintenance.</span><span style=\"color: purple;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">One way to reduce maintenance costs is to </span><span style=\"background-color: white; font-style: italic; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">implement something only when you actually need it</span><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">, a.k.a. the </span><span style=\"background-color: white; font-style: italic; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">“You Aren't Gonna Need It”</span><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"> (YAGNI) design principle.</span></span><span style=\"background-color: white; color: #980000; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">How do you spot unnecessary code? Follow your nose!</span></span></span><br /><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"><br /></span></span><span id=\"docs-internal-guid-6eaa5349-e1fd-1c9f-0067-350ede75aa2d\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">A </span><span style=\"background-color: white; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">code smell</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> is a code pattern that usually indicates a design flaw. For example, creating a base class or interface with only one subclass may indicate a speculation</span><span style=\"background-color: white; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">that more subclasses will be needed in the future. Instead, </span><span style=\"color: purple;\"><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">practice </span><span style=\"background-color: white; font-style: italic; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">incremental development and design</span></span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">: don't add the second subclass until it is actually needed.</span></span></span><br /><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"><br /></span></span><span id=\"docs-internal-guid-6eaa5349-e1fd-bee8-4106-0eb06fd3b57e\"><span style=\"color: purple; font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">The following C++ code has many YAGNI smells</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">:</span></span></span><br /><div style=\"overflow-x: auto;\"><table class=\"my-bordered-table\" style=\"width: 613px;\"><tbody><tr><td style=\"background-color: #cfe2f3; vertical-align: top; width: 607px;\"><pre style=\"background-color: #cfe2f3; border: 0px; color: black; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-top: 0px;\"><span style=\"font-family: "courier new" , "courier" , monospace;\">class Mammal { ...<br /> virtual Status Sleep(bool hibernate) = 0;<br />};<br />class Human : public Mammal { ...<br /> virtual Status Sleep(bool hibernate) {<br /> age += hibernate ? kSevenMonths : kSevenHours;<br /> return OK;<br /> }<br />};</span></pre></td></tr></tbody></table></div><br /><span id=\"docs-internal-guid-6eaa5349-e206-b27d-31ae-50bf28cffdf8\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">Maintainers are burdened with understanding, documenting, and testing both classes when only one is really needed. Code must handle the case when </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">hibernate</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> is true, even though all callers pass </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">false</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">, as well as the case when</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">Sleep</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">returns an error, even though that never happens. This results in unnecessary code that never executes.</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\"> </span><span style=\"color: purple;\"><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\">Eliminating those smells simplifies the code</span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">:</span></span></span></span><br /><div><br /><div style=\"overflow-x: auto;\"><table class=\"my-bordered-table\" style=\"width: 613px;\"><tbody><tr><td style=\"background-color: #d9ead3; vertical-align: top; width: 607px;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-top: 0px;\"><span style=\"font-family: "courier new" , "courier" , monospace;\">class Human { ...<br /> void Sleep() { age += kSevenHours; }<br />};</span></pre></td></tr></tbody></table></div></div><div><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\"><br /></span></span></span><span id=\"docs-internal-guid-6eaa5349-e20a-75df-ea9f-425d9248d2b8\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">Here are some other YAGNI smells</span></span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">:</span></span></span></div><div><ul><li><span style=\"white-space: pre-wrap;\"><span style=\"font-family: Times, Times New Roman, serif;\">Code that has never been executed other than by tests (a.k.a. code that is dead on arrival)</span></span></li><li><span style=\"white-space: pre-wrap;\"><span style=\"font-family: Times, Times New Roman, serif;\">Classes designed to be subclassed (have virtual methods and/or protected members) that are not actually subclassed</span></span></li><li><span style=\"white-space: pre-wrap;\"><span style=\"font-family: Times, Times New Roman, serif;\">Public or protected methods or fields that could be private</span></span></li><li><span style=\"font-family: Times, Times New Roman, serif; white-space: pre-wrap;\"><span style=\"font-family: "times" , "times new roman" , serif;\">Parameters, variables, or flags that always have the same valu</span>e</span></li></ul><div><span id=\"docs-internal-guid-6eaa5349-e20c-160d-42e8-867621960b75\" style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">Thankfully, </span><span style=\"background-color: white; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">YAGNI smells, and code smells in general, are often easy to spot by looking for simple patterns and are easy to eliminate using simple refactorings</span></span><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">.</span></span></div></div><div><span id=\"docs-internal-guid-6eaa5349-e20c-8481-d93e-91a798eaf368\"></span><br /><div dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 10pt; margin-top: 10pt;\"><span id=\"docs-internal-guid-6eaa5349-e20c-8481-d93e-91a798eaf368\"><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; vertical-align: baseline; white-space: pre-wrap;\">Are you thinking of adding code that won't be used today? Trust me, </span><span style=\"background-color: white; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\">you aren't gonna need it!</span></span></span></div><span id=\"docs-internal-guid-6eaa5349-e20c-8481-d93e-91a798eaf368\"></span><br /><div><span id=\"docs-internal-guid-6eaa5349-e20c-8481-d93e-91a798eaf368\"><span style=\"background-color: white; font-size: 13pt; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"><br /></span></span></div><span id=\"docs-internal-guid-6eaa5349-e20c-8481-d93e-91a798eaf368\"></span></div><div class=\"feedflare\">\r\n<a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=zQwgFkJ8VWQ:aZMaLSvghkM:yIl2AUoC8zA\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?d=yIl2AUoC8zA\" border=\"0\"></img></a> <a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=zQwgFkJ8VWQ:aZMaLSvghkM:V_sGLiPBpWU\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?i=zQwgFkJ8VWQ:aZMaLSvghkM:V_sGLiPBpWU\" border=\"0\"></img></a>\r\n</div><img src=\"http://feeds.feedburner.com/~r/blogspot/RLXA/~4/zQwgFkJ8VWQ\" height=\"1\" width=\"1\" alt=\"\"/>",
"contentSnippet": "This is another post in our Code Health series. A version of this post originally appeared in Google bathrooms worldwide as a Google Testing on the Toilet episode. You can download a printer-friendly version to display in your office.By Marc EaddyThe majority of software development costs are due to maintenance. One way to reduce maintenance costs is to implement something only when you actually need it, a.k.a. the “You Aren't Gonna Need It” (YAGNI) design principle. How do you spot unnecessary code? Follow your nose!A code smell is a code pattern that usually indicates a design flaw. For example, creating a base class or interface with only one subclass may indicate a speculation that more subclasses will be needed in the future. Instead, practice incremental development and design: don't add the second subclass until it is actually needed.The following C++ code has many YAGNI smells:class Mammal { ... virtual Status Sleep(bool hibernate) = 0;};class Human : public Mammal { ... virtual Status Sleep(bool hibernate) { age += hibernate ? kSevenMonths : kSevenHours; return OK; }};Maintainers are burdened with understanding, documenting, and testing both classes when only one is really needed. Code must handle the case when hibernate is true, even though all callers pass false, as well as the case when Sleep returns an error, even though that never happens. This results in unnecessary code that never executes. Eliminating those smells simplifies the code:class Human { ... void Sleep() { age += kSevenHours; }};Here are some other YAGNI smells:Code that has never been executed other than by tests (a.k.a. code that is dead on arrival)Classes designed to be subclassed (have virtual methods and/or protected members) that are not actually subclassedPublic or protected methods or fields that could be privateParameters, variables, or flags that always have the same valueThankfully, YAGNI smells, and code smells in general, are often easy to spot by looking for simple patterns and are easy to eliminate using simple refactorings.Are you thinking of adding code that won't be used today? Trust me, you aren't gonna need it!",
"id": "tag:blogger.com,1999:blog-15045980.post-1547713588878071210"
},
{
"title": "Code Health: To Comment or Not to Comment?",
"link": "http://feedproxy.google.com/~r/blogspot/RLXA/~3/grfVWQaCJak/code-health-to-comment-or-not-to-comment.html",
"pubDate": "2017-07-25T19:56:50.399Z",
"author": "Google Testing Bloggers",
"content": "<span id=\"docs-internal-guid-f12e4fdc-518c-da84-eea8-b6a4be0fe25f\"><i><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\">This is another post in our </span><a href=\"https://testing.googleblog.com/2017/04/code-health-googles-internal-code.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; vertical-align: baseline; white-space: pre-wrap;\">Code Health</span></a><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\"> series. A version of this post originally appeared in Google bathrooms worldwide as a Google </span><a href=\"https://testing.googleblog.com/2007/01/introducing-testing-on-toilet.html\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; vertical-align: baseline; white-space: pre-wrap;\">Testing on the Toilet</span></a><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\"> episode. You can download a </span><a href=\"https://docs.google.com/document/d/1ZgxLPQfKAfdwU-07sYplTWWnlzk6MaAxPMB1HpuOYdM/edit?usp=sharing\" style=\"text-decoration-line: none;\"><span style=\"background-color: white; color: #1155cc; vertical-align: baseline; white-space: pre-wrap;\">printer-friendly version</span></a><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\"> to display in your office. </span></span></i></span><br /><span style=\"background-color: white; color: #222222; font-family: "arial"; font-size: 9.5pt; font-style: italic; vertical-align: baseline; white-space: pre-wrap;\"><br /></span><span style=\"font-family: "times" , "times new roman" , serif;\"><span style=\"background-color: white; color: #222222; vertical-align: baseline; white-space: pre-wrap;\">By </span><span style=\"color: #222222;\"><span style=\"white-space: pre-wrap;\">Dori Reuveni and Kevin Bourrillion</span></span></span><br /><span style=\"color: #222222; font-family: "arial";\"><span style=\"font-size: 12.6667px; white-space: pre-wrap;\"><i><br /></i></span></span><span id=\"docs-internal-guid-80f4df1e-5195-7562-ccca-33b91dee58da\"><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\">While reading code, </span><span style=\"font-size: 13pt; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">often there is nothing more helpful than a well-placed comment.</span></span><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\"> However, </span><span style=\"font-size: 13pt; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">comments are not always good.</span></span><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\"> Sometimes the need for a comment can be a sign that the code should be refactored.</span></span><br /><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\"><br /></span><span id=\"docs-internal-guid-80f4df1e-5199-e564-da1d-a76a06c36dc4\"><span style=\"font-size: 13pt; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">Use a comment when it is infeasible to make your code self-explanatory.</span></span><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\"> If you think you need a comment to explain what a piece of code does, first try one of the following:</span></span><br /><ul style=\"padding-right:0;\"><div dir=\"ltr\" style=\"margin-left: 36pt;\"></div><li style=\"overflow-x: auto;\"><span style=\"white-space: pre-wrap;\"><span id=\"docs-internal-guid-80f4df1e-519a-69a9-6808-90426cacd365\"><span style=\"vertical-align: baseline;\"><span style=\"font-size: 13pt;\">Introduce an explaining variable.</span><table class=\"my-bordered-table\"> <tbody><tr> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Subtract discount from price.</span><br />finalPrice = (numItems * itemPrice)<br /> - min(5, numItems) * itemPrice * 0.1;</pre></td> <td style=\"background-color: #d9ead3; vertical-align: top; width: 50%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">price = numItems * itemPrice;<br />discount =<br /> min(5, numItems) * itemPrice * 0.1;<br />finalPrice = price - discount;</pre></td> </tr></tbody></table></span></span></span></li><li style=\"overflow-x: auto;\"><span style=\"white-space: pre-wrap;\"><span style=\"vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-519f-4335-f8b0-d5a33dcb9da9\"><span style=\"font-size: 13pt; vertical-align: baseline;\">Extract a method. <table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Filter offensive words.</span><br />for (String word : words) { ... }</pre></td> <td style=\"background-color: #d9ead3; vertical-align: top; width: 50%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">filterOffensiveWords(words);</pre></td> </tr></tbody></table></span></span></span></span></li><li style=\"overflow-x: auto;\"><span style=\"white-space: pre-wrap;\"><span style=\"vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a0-170b-6ea9-9f5c5276098e\"><span style=\"vertical-align: baseline;\"><span style=\"font-size: 13pt;\">Use a more descriptive identifier name. </span><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">int width = ...; <span style=\"font-weight: bold;\">// Width in pixels.<br /></span></pre></td> <td style=\"background-color: #d9ead3; vertical-align: top; width: 50%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">int widthInPixels = ...;</pre></td> </tr></tbody></table><span style=\"font-size: 13pt;\"></span></span></span></span></span></li><li style=\"overflow-x: auto;\"><span style=\"white-space: pre-wrap;\"><span style=\"vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a0-2ea1-3c01-7139b77b3d83\"><span style=\"vertical-align: baseline;\"><span style=\"font-size: 13pt;\">Add a check in case your code has assumptions.</span><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Safe since height is always > 0.</span><br />return width / height;</pre></td> <td style=\"background-color: #d9ead3; vertical-align: top; width: 50%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">checkArgument(height > 0);<br />return width / height;<br /></pre></td> </tr></tbody></table><span style=\"font-size: 13pt;\"></span></span></span></span></span></li></ul><span id=\"docs-internal-guid-80f4df1e-51a0-8452-eab1-2cd24d48de26\"><span style=\"font-size: 13pt; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">There are cases where a comment can be helpful:</span></span></span><br /><div><ul style=\"padding-right: 0;\"><li style=\"overflow-x: auto;\"><span style=\"color: #980000;\"><span style=\"font-size: 17.3333px; white-space: pre-wrap;\"><b><span id=\"docs-internal-guid-80f4df1e-51a0-b549-18ae-18357c1b342e\" style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\">Reveal your intent: explain </span><span style=\"color: black; font-size: 13pt; font-style: italic; vertical-align: baseline;\">why</span><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"> the code does something (as opposed to </span><span style=\"color: black; font-size: 13pt; font-style: italic; vertical-align: baseline;\">what</span><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"> it does). <table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #d9ead3; vertical-align: top; width: 100%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Compute once because it’s expensive.</span></pre></td> </tr></tbody></table></span></span></b></span></span></li><li style=\"overflow-x: auto;\"><span style=\"color: #980000;\"><span style=\"font-size: 17.3333px; white-space: pre-wrap;\"><b><span style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a0-df5a-d7f5-d2b802cd8c8a\"><span style=\"font-size: 13pt; vertical-align: baseline;\">Protect a well-meaning future editor from mistakenly “fixing” your code.<b style=\"color: #980000; font-size: 17.3333px;\"><span id=\"docs-internal-guid-80f4df1e-51a0-b549-18ae-18357c1b342e\" style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #d9ead3; vertical-align: top; width: 100%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Create a new Foo instance because Foo is not thread-safe.</span></pre></td> </tr></tbody></table></span></span></b></span></span></span></span></b></span></span></li><li style=\"overflow-x: auto;\"><span style=\"color: #980000;\"><span style=\"font-size: 17.3333px; white-space: pre-wrap;\"><b><span style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><span style=\"font-size: 13pt; vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a1-2bf0-a976-6eff6b40c4c9\"><span style=\"font-size: 13pt; vertical-align: baseline;\">Clarification: a question that came up during code review or that readers of the code might have.<b style=\"color: #980000; font-size: 17.3333px;\"><span style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a0-df5a-d7f5-d2b802cd8c8a\"><span style=\"font-size: 13pt; vertical-align: baseline;\"><b style=\"color: #980000; font-size: 17.3333px;\"><span id=\"docs-internal-guid-80f4df1e-51a0-b549-18ae-18357c1b342e\" style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #d9ead3; vertical-align: top; width: 100%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Note that order matters because...</span></pre></td> </tr></tbody></table></span></span></b></span></span></span></span></b></span></span></span></span></span></b></span></span></li><li style=\"overflow-x: auto;\"><span style=\"vertical-align: baseline;\"><span style=\"vertical-align: baseline;\"><span style=\"font-size: 17.3333px; vertical-align: baseline; white-space: pre-wrap;\">Explain your rationale for what looks like a bad software engineering practice.<b style=\"color: #980000; font-size: 17.3333px;\"><span style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><span style=\"font-size: 13pt; vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a1-2bf0-a976-6eff6b40c4c9\"><span style=\"font-size: 13pt; vertical-align: baseline;\"><b style=\"color: #980000; font-size: 17.3333px;\"><span style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><span id=\"docs-internal-guid-80f4df1e-51a0-df5a-d7f5-d2b802cd8c8a\"><span style=\"font-size: 13pt; vertical-align: baseline;\"><b style=\"color: #980000; font-size: 17.3333px;\"><span id=\"docs-internal-guid-80f4df1e-51a0-b549-18ae-18357c1b342e\" style=\"font-weight: normal;\"><span style=\"color: black; font-size: 13pt; vertical-align: baseline;\"><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #d9ead3; vertical-align: top; width: 100%;\"><pre style=\"background-color: #d9ead3; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\">@SuppressWarnings(\"unchecked\") <span style=\"font-weight: bold;\">// The cast is safe because...</span></pre></td> </tr></tbody></table></span></span></b></span></span></span></span></b></span></span></span></span></span></b></span></span></span></li></ul><span id=\"docs-internal-guid-80f4df1e-51a1-dc5e-5e8a-e7db89713222\"><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\">On the other hand, </span><span style=\"font-size: 13pt; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">avoid comments that just repeat what the code does</span></span><span style=\"font-size: 13pt; vertical-align: baseline; white-space: pre-wrap;\"><span style=\"color: purple;\">.</span> These are just noise:</span></span><br /><div style=\"overflow-x: auto;\"><table class=\"my-bordered-table\" style=\"width: 100%;\"> <tbody><tr> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Get all users.</span><br />userService.getAllUsers();</pre></td> <td style=\"background-color: #f4cccc; vertical-align: top; width: 50%;\"><pre style=\"background-color: #f4cccc; border: 0px; color: black; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; padding-left: 0;\"><span style=\"font-weight: bold;\">// Check if the name is empty.</span><br />if (name.isEmpty()) { ... }</pre></td> </tr></tbody></table></div></div><div class=\"feedflare\">\r\n<a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=grfVWQaCJak:0--XfkbfS5s:yIl2AUoC8zA\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?d=yIl2AUoC8zA\" border=\"0\"></img></a> <a href=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?a=grfVWQaCJak:0--XfkbfS5s:V_sGLiPBpWU\"><img src=\"http://feeds.feedburner.com/~ff/blogspot/RLXA?i=grfVWQaCJak:0--XfkbfS5s:V_sGLiPBpWU\" border=\"0\"></img></a>\r\n</div><img src=\"http://feeds.feedburner.com/~r/blogspot/RLXA/~4/grfVWQaCJak\" height=\"1\" width=\"1\" alt=\"\"/>",
"contentSnippet": "This is another post in our Code Health series. A version of this post originally appeared in Google bathrooms worldwide as a Google Testing on the Toilet episode. You can download a printer-friendly version to display in your office. By Dori Reuveni and Kevin BourrillionWhile reading code, often there is nothing more helpful than a well-placed comment. However, comments are not always good. Sometimes the need for a comment can be a sign that the code should be refactored.Use a comment when it is infeasible to make your code self-explanatory. If you think you need a comment to explain what a piece of code does, first try one of the following:Introduce an explaining variable. // Subtract discount from price.finalPrice = (numItems * itemPrice) - min(5, numItems) * itemPrice * 0.1; price = numItems * itemPrice;discount = min(5, numItems) * itemPrice * 0.1;finalPrice = price - discount; Extract a method. // Filter offensive words.for (String word : words) { ... } filterOffensiveWords(words); Use a more descriptive identifier name. int width = ...; // Width in pixels. int widthInPixels = ...; Add a check in case your code has assumptions. // Safe since height is always > 0.return width / height; checkArgument(height > 0);return width / height; There are cases where a comment can be helpful:Reveal your intent: explain why the code does something (as opposed to what it does). // Compute once because it’s expensive. Protect a well-meaning future editor from mistakenly “fixing” your code. // Create a new Foo instance because Foo is not thread-safe. Clarification: a question that came up during code review or that readers of the code might have. // Note that order matters because... Explain your rationale for what looks like a bad software engineering practice. @SuppressWarnings(\"unchecked\") // The cast is safe because... On the other hand, avoid comments that just repeat what the code does. These are just noise: // Get all users.userService.getAllUsers(); // Check if the name is empty.if (name.isEmpty()) { ... }",
"id": "tag:blogger.com,1999:blog-15045980.post-5029073665609132906"
},
{
"title": "Evolution of GTAC and Engineering Productivity",
"link": "http://feedproxy.google.com/~r/blogspot/RLXA/~3/ptSfzdHRC4s/evolution-of-gtac-and-engineering.html",
"pubDate": "2017-07-25T19:55:51.631Z",
"author": "Google Testing Bloggers",
"content": "<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;\"><span style=\"background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;\">When Google first hosted GTAC in 2006, we didn’t know what to expect. We kicked off this conference with the intention to share our innovation in test automation, learn from others in the industry and connect with academia. Over the last decade we’ve had great participation and had the privilege to host GTAC in North America, Europe and Asia -- largely thanks to the many of you who spoke, participated and connected!</span></div><b id=\"docs-internal-guid-b2800243-380a-1c76-0e2a-b9be11aa8164\" style=\"font-weight: normal;\"><br /></b><div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0pt; margin-t