<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>ThrustVectoring</author><text>&amp;gt; ensuring that knowledge isn&amp;#x27;t repeated&lt;p&gt;The most fun bug I&amp;#x27;ve encountered as a web developer is of this category. Two pages, both check for a logged-in user and redirects to the other if found or not found, respectively. The bug was a subtle difference in how these were calculated, the details of which are unfortunately lost to the sands of time. The end result was that if you sat on one of the pages and waited for your user session to time out, you&amp;#x27;d get stuck in a redirect loop between the &amp;quot;logged in&amp;quot; and &amp;quot;please log in&amp;quot; versions of the page.&lt;p&gt;Anyhow, the point of this is that when you calculate the same fact two different ways, you will occasionally build something that makes an unwarranted assumption that because it&amp;#x27;s the &amp;quot;same fact&amp;quot; you wind up with the same answer. This is an entire category of easily missed and often subtle bugs.</text><parent_chain><item><author>thisiszilff</author><text>I think this misses the point of DRY a little bit. DRY isn&amp;#x27;t about not copy pasting code, it&amp;#x27;s about ensuring that knowledge isn&amp;#x27;t repeated. If two parts of the system need to know the same thing (for example, who the currently logged in user is, or what elasticsearch instance to send queries to, etc.), then there should be a single way to &amp;quot;know&amp;quot; that fact. Put that way, DRY violations are repetitions of knowledge and make the system more complex because different parts know the same fact but in different ways and you need to maintain all of them, understand all of them, etc. etc.&lt;p&gt;Code blocks that look to be syntactically the same are the lowest expression of &amp;quot;this might be the same piece of knowledge&amp;quot; insofar as they express knowledge about &amp;quot;how to do X&amp;quot;, but the key is identifying the knowledge that is duplicated and working from there. Sometimes it comes out that the &amp;quot;duplication&amp;quot; is something like &amp;quot;this is a for loop iterating over the elements of this list in this field in this object&amp;quot; and that is the kind of code block that contains very little knowledge in terms of our system. But supposing that that list had a special structure (ie, maybe we&amp;#x27;ve parsed text into tokens and have information about whitespace, punctuation, etc in that list) and we start to notice we&amp;#x27;re repeating code to iterate over elements of the list and ignore the whitespace, punctuation elements in it, then we&amp;#x27;ve got a piece of knowledge worth DRYing out given that all the clients now need to know what whitespace &amp;amp; punctuation look like even when they&amp;#x27;d like to filter them out.&lt;p&gt;It&amp;#x27;s worth pointing out that DRYing out something isn&amp;#x27;t necessarily &amp;quot;abstracting&amp;quot;, it is more like consolidating knowledge into one place.</text></item></parent_chain></comment><story><title>DRY Is a Trade-Off</title><url>https://orbifold.xyz/dry-trade-off.html</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>majormajor</author><text>I haven&amp;#x27;t seen this &amp;quot;don&amp;#x27;t repeat knowledge&amp;quot; take before, it&amp;#x27;s pretty interesting. I see why you don&amp;#x27;t want mutated various versions of the same information all over the place, but you still have dangers.&lt;p&gt;Especially if you &amp;quot;overly reduce&amp;quot; your knowledge. If your common recipe is &amp;quot;do A, B, C, D, E&amp;quot; and you reduce that to just &amp;quot;do X,&amp;quot; for instance.&lt;p&gt;I&amp;#x27;ve seen this often turn into &amp;quot;now, instead of the knowledge being repeated in several places, it&amp;#x27;s hidden in one place and only one person knows it.&amp;quot; Everybody else just relies on the library doing its magic, and when someone needs to do something differently, they have this huge mountain to climb to figure out how to modify the code to also do &amp;quot;J&amp;quot; for certain cases without breaking everyone else.</text><parent_chain><item><author>thisiszilff</author><text>I think this misses the point of DRY a little bit. DRY isn&amp;#x27;t about not copy pasting code, it&amp;#x27;s about ensuring that knowledge isn&amp;#x27;t repeated. If two parts of the system need to know the same thing (for example, who the currently logged in user is, or what elasticsearch instance to send queries to, etc.), then there should be a single way to &amp;quot;know&amp;quot; that fact. Put that way, DRY violations are repetitions of knowledge and make the system more complex because different parts know the same fact but in different ways and you need to maintain all of them, understand all of them, etc. etc.&lt;p&gt;Code blocks that look to be syntactically the same are the lowest expression of &amp;quot;this might be the same piece of knowledge&amp;quot; insofar as they express knowledge about &amp;quot;how to do X&amp;quot;, but the key is identifying the knowledge that is duplicated and working from there. Sometimes it comes out that the &amp;quot;duplication&amp;quot; is something like &amp;quot;this is a for loop iterating over the elements of this list in this field in this object&amp;quot; and that is the kind of code block that contains very little knowledge in terms of our system. But supposing that that list had a special structure (ie, maybe we&amp;#x27;ve parsed text into tokens and have information about whitespace, punctuation, etc in that list) and we start to notice we&amp;#x27;re repeating code to iterate over elements of the list and ignore the whitespace, punctuation elements in it, then we&amp;#x27;ve got a piece of knowledge worth DRYing out given that all the clients now need to know what whitespace &amp;amp; punctuation look like even when they&amp;#x27;d like to filter them out.&lt;p&gt;It&amp;#x27;s worth pointing out that DRYing out something isn&amp;#x27;t necessarily &amp;quot;abstracting&amp;quot;, it is more like consolidating knowledge into one place.</text></item></parent_chain></comment><story><title>DRY Is a Trade-Off</title><url>https://orbifold.xyz/dry-trade-off.html</url></story>