TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

TDD from the Factorio Team

457 pointsby sorahnalmost 4 years ago

18 comments

dgb23almost 4 years ago
Two interesting takeaways:<p>&gt; This is the beautiful thing about having a company that isn&#x27;t on the stock market. Imagine you have a company that goes slower and slower every quarter, and then you confront the shareholders with the statement, that the way to solve it, is to do absolutely no new features for a quarter or two, refactor the code, learn new methodologies etc. I doubt that the shareholders would allow that. Luckily, we don&#x27;t have any shareholders, and we understand the vital importance of this investment in the long run. Not only in the project, but also in our skill and knowledge, so we do better next time.<p>This is reassuring the notion of what I think actually matters, what the real essence is of developing a product, may that be a piece of art and entertainment (like here) or a productivity tool etc.<p>There are creators and there are consumers. We split them up by developers, designers, domain experts and so on, but what matters is that all the other participants, especially those who can exert power traditionally are not part of the essence and if not being careful and responsible, can easily add complexity and limitations that are entirely accidental and can even be harmful.<p>This reminds me of the agile manifesto, modern UX approaches and other processes that are driven by creators, but are often and very unfortunately being bent over backwards to fit into hierarchical power structures.<p>&gt; TDD actually is the constant fast swithing between extending the tests and making them pass continously. So as you write tests, you write code to satisfy them basically at the same time. This allows you to instantly test what you write, and mainly use tests as specifiation of what the code should acctually do, which guides the thought process to make you think about where you are headed to, and to write code that is more structured and testable from the very beginning.<p>The important notion here is that TDD is not about tests and correctness, but about development. It continuously checks assumptions and explores the surrounding code, state and data until a sufficient solution is found.<p>If we squint a little we can see how closely related TDD with REPL Driven Development is. In essence it is the same thing and even has similar results, where the tests or REPL code can be left as an artifact for further, likely historical understanding.<p>We know now that neither is sufficient for a high degree of correctness, but they are certainly useful for understanding and development.
评论 #27549380 未加载
评论 #27550658 未加载
评论 #27554465 未加载
评论 #27550085 未加载
评论 #27550013 未加载
评论 #27549967 未加载
评论 #27551131 未加载
评论 #27550020 未加载
ramblermanalmost 4 years ago
I&#x27;d be curious to hear what kovarex thinks in 2-3 months.<p>TDD is often sold as a fix-all solution, which is incredibly appealing to mgmt and quite fun for most programmers as a new paradigm, allowing for quick adoption.<p>It also has its uses, especially in the enterprise space where requirements aren&#x27;t often clear. But I don&#x27;t know many good programmers that truly stick to the dogma after the honeymoon period. It becomes just another tool in your toolset.<p>Uncle bob is a salesman, not a &quot;craftsman&quot;.
评论 #27551927 未加载
评论 #27550167 未加载
评论 #27549579 未加载
评论 #27549565 未加载
评论 #27549671 未加载
评论 #27549994 未加载
评论 #27551015 未加载
评论 #27550398 未加载
评论 #27557507 未加载
评论 #27550771 未加载
评论 #27549644 未加载
评论 #27549554 未加载
ineedasernamealmost 4 years ago
Every time a Factorio thread makes it to HN I feel like a fully recovered meth addict who suddenly has their old dealer knocking at their door:<p>--<p>Dealer: <i>&quot;Hey? You there? I got some meth for you.&quot;</i><p>Me: &quot;Go away! I don&#x27;t want any!&quot;<p>Dealer: <i>&quot;Oh now don&#x27;t say that. You remember how good it is? I know you do.&quot;</i><p>Me: &quot;I can&#x27;t, I can&#x27;t afford it, the price is too high.&quot;<p>Dealer: <i>&quot;What? Come on, it&#x27;s free! You already paid for it!.</i><p>Me: &quot;I&#x27;ll lose my job, I can&#x27;t, just go away!&quot;<p>Dealer: <i>&quot;Your JOB? This IS your job. Open the damn door, THE FACTORY MUST GROW&quot;</i><p>Me: ::cowers in the closet chanting please leave please leave please leave::<p>--<p>Also it was never <i>good</i>. It was more like a mind virus. Like the sort of problem or project at work you can&#x27;t stop thinking about until it&#x27;s done. Only with Factorio, it&#x27;s never done. Never.<p>My best defense against it are other video games I can stop &amp; start when needed. Or booting up my VPN connection and picking a work task from my back log until the cravings go away.
评论 #27556784 未加载
评论 #27555015 未加载
truncatealmost 4 years ago
&gt; (1) no new features for a quarter or two, refactor the code, learn new methodologies etc<p>&gt; (2) This allows you to instantly test what you write, and mainly use tests as specification<p>&gt; (3) the problem comes when you break something and a lot of tests start to fail suddenly<p>My favorites. Don&#x27;t expect to give away entire quarter, but at-least sometime would definitely be nice. All three so fundamental, and often ignored. In my experience, you get these right, it makes developer life so much easier. As someone earlier mentioned in thread, TDD is kind of like REPL driven development.<p>I think, one immediate benefit of companies focusing on good code is that engineers can aim for much more ambitious projects, and they can be more brave with the codebase. Instead we often end up with 100 over-engineered components with no well defined&#x2F;enforced contracts, and a set of monolithic tests which runs the entire stack to test the most basic case.
评论 #27549949 未加载
评论 #27550504 未加载
blindmutealmost 4 years ago
I&#x27;m not sure I understand why they&#x27;re committing to such a long term refactor for a game which has already reached the tail end of its sales curve. As far as I know there are no internal monetization schemes in Factorio, and I really doubt further updates will boost sales anywhere near enough to justify the dev salaries.
评论 #27552331 未加载
评论 #27551331 未加载
评论 #27552231 未加载
评论 #27551855 未加载
评论 #27551324 未加载
评论 #27551340 未加载
评论 #27551627 未加载
评论 #27552492 未加载
IMTDbalmost 4 years ago
&gt; Imagine you have a company that goes slower and slower every quarter, and then you confront the shareholders with the statement, that the way to solve it, is to do absolutely no new features for a quarter or two, refactor the code, learn new methodologies etc. I doubt that the shareholders would allow that<p>&gt; now there are 9 programmers<p>Companies on the stock market don&#x27;t have &quot;9 programmers&quot;. They have a lot of teams of 9 programmers. So while it&#x27;s true that it would probably completely be impossible for a stock market company to completely freeze for a quarter or two, individual teams can still do that.<p>If the factorio team grows to tens of programmers (it probably won&#x27;t and probably shouldn&#x27;t), I would be very surprised if they find the need - and if they manage to - freeze all teams together for a big refactoring round. I am also unsure that it would be the right approach. That observation holds wether they go public or stay private.
评论 #27550153 未加载
tobyhinloopenalmost 4 years ago
I wonder how common TDD is in game development land, especially when you’re using things like Unity or Unreal.<p>I feel like testing your behaviors is pretty hard, and even if you unit-test your behaviors, there’s still integration tests.<p>I only write games as a hobby and never use TDD, even if I’d like to, since the tooling is just either poorly documented or too slow, or both.<p>Usually this ends with me being frustrated with the slow development cycle and pushes me towards more unconventional methods of developing games in Javascript using Mocha to run the tests directly in the browser.
评论 #27552364 未加载
评论 #27549501 未加载
评论 #27549429 未加载
评论 #27549422 未加载
评论 #27549389 未加载
评论 #27549360 未加载
评论 #27550673 未加载
评论 #27549638 未加载
评论 #27549373 未加载
kevmo314almost 4 years ago
&gt; Which is a big improvement already, as adding and maintaining the new logic only requires you to look at one place instead of several, and it makes it generally more readable and less prone to errors.<p>It&#x27;s interesting to think about the other HN thread discussion about comments vs one-time-call function abstractions in this light: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27546135" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27546135</a><p>I&#x27;m a big fan of &quot;put code in one place&quot; too. It was the biggest factor that convinced me that JSX was a great idea compared to separating the templating logic out.
评论 #27549277 未加载
ashtonkemalmost 4 years ago
Honestly, I think the factorio team probably now knows more than Uncle Bob does, based on their blog posts.
nanisalmost 4 years ago
This is a neat article. I do have comments about testing in general though.<p>IME most developer do not understand each test has four possible outcomes:<p>* Code is good and test passes<p>* Code is bad and test fails<p>These are the only two possible outcomes developers focus on: When I ask what they should do if a test that used to pass now fails, they always tell me stories about how to debug the code under test.<p>There are two additional possibilities in test:<p>* Code is bad yet test passes (false negative)<p>* Code is good yet test fails (false positive)<p>Again, IME, most people do not look at the test again once it passes for the first time.<p>As a result, tests which are themselves code, become the largest untested part of the code base. You get these thousands and thousands of lines of untested code yet you have 100% code coverage.<p>Some of my blog posts on testing:<p>* Deception in tests considered harmful <a href="https:&#x2F;&#x2F;www.nu42.com&#x2F;2017&#x2F;02&#x2F;deception-in-tests-harmful.html" rel="nofollow">https:&#x2F;&#x2F;www.nu42.com&#x2F;2017&#x2F;02&#x2F;deception-in-tests-harmful.html</a><p>* Know what you are testing: The case of the test for median in Boost.Accumulators C++ Library &lt;<a href="https:&#x2F;&#x2F;www.nu42.com&#x2F;2016&#x2F;12&#x2F;cpp-boost-median-test.html" rel="nofollow">https:&#x2F;&#x2F;www.nu42.com&#x2F;2016&#x2F;12&#x2F;cpp-boost-median-test.html</a>&gt;<p>* Who is testing the tests? <a href="https:&#x2F;&#x2F;www.nu42.com&#x2F;2015&#x2F;05&#x2F;who-is-testing-the-tests.html" rel="nofollow">https:&#x2F;&#x2F;www.nu42.com&#x2F;2015&#x2F;05&#x2F;who-is-testing-the-tests.html</a><p>* Slashing one&#x27;s feet with tests, or, how to fix 2,950 test failures in one fell swoop <a href="https:&#x2F;&#x2F;www.nu42.com&#x2F;2015&#x2F;08&#x2F;fix-2950-test-failures.html" rel="nofollow">https:&#x2F;&#x2F;www.nu42.com&#x2F;2015&#x2F;08&#x2F;fix-2950-test-failures.html</a>
harryfalmost 4 years ago
Came here hoping they’d turned Factorio into a tool of creating tests in other codebaes. Like literal gamification of work.
评论 #27549406 未加载
tgtweakalmost 4 years ago
Damn I misread TTD and got excited that they were building it into factorio... Great article though, was not dissapointed.
评论 #27550816 未加载
achairapartalmost 4 years ago
Warning: This page almost crashed my browser (FireFox on MacOS) and put my CPU on fire.
评论 #27550213 未加载
评论 #27549250 未加载
评论 #27549476 未加载
评论 #27549365 未加载
评论 #27551767 未加载
bluGillalmost 4 years ago
&gt; Imagine you have a company that goes slower and slower every quarter, and then you confront the shareholders with the statement, that the way to solve it, is to do absolutely no new features for a quarter or two, refactor the code, learn new methodologies etc. I doubt that the shareholders would allow that.<p>It is called restructuring and big companies do it all the time. Investors allow it, though they are rightly suspicious - sometimes it is good, but often it is change for the sake of change and not change for better.
happyweaselalmost 4 years ago
You can TDD as much as you want to once the initial game mechanics are in place and a gameprotoype shows enough promise to be realized until completion. Because then most of the core stuff&#x2F;ideas&#x2F;principles won&#x27;t wildly change and won&#x27;t be thrown away.. The core mechanics are in place. But would TDD help you reach that stage? I guess it is simply too much overhead. So yeah, this is TDD after the fact ;-). I still love TDD :)
评论 #27549491 未加载
评论 #27550803 未加载
Aardwolfalmost 4 years ago
I used to follow friday facts until it stopped being weekly. I&#x27;m glad that every friday fact now gets posted on hacker news, that serves as my notification for new ones :)<p>I also misread TDD as TTD (related to the trains in factorio) first
评论 #27550387 未加载
AwaAwaalmost 4 years ago
While I&#x27;m ambivalent on TDD, there seems to be an attempt at cancellation brewing for his invocation of Uncle Bob.
swileyalmost 4 years ago
Factorio convinced me that some people still write good closed commercial games. I wish the best for the authors and hope they don&#x27;t stop any time soon.